UNPKG

cordova-plugin-mfp

Version:

IBM MobileFirst Platform Foundation Cordova Plugin

1,074 lines (962 loc) 76.8 kB
/** * ================================================================= * Source file taken from :: analytics.d.ts * ================================================================= */ declare module WL.Analytics { /** * Turns on the capture of analytics data. * * The Promise returned by enable must be resolved prior to any WL.Analytics API call. * * It is not necessary to wait for the returned Promise to be resolved to continue using the * WL.Analytics API. * * @example * WL.Analytics.enable() * * .then(function () { * //Capture of analytics data is fully enabled. * }) * * .fail(function (errObj) { * //errObj.src = function that failed * //errObj.res = error message * }); * * * @returns {Promise} Resolved with no parameters, rejected with an error object. * @methodOf WL.Analytics# */ function enable():WLPromise; /** * Turns off the capture of analytics data. * * @example * WL.Analytics.disable() * * .then(function () { * //Capture of analytics data is fully disabled. * }) * * .fail(function (errObj) { * //errObj.src = function that failed * //errObj.res = error message * }); * * @returns {Promise} Resolved with no parameters, rejected with an error object. * @methodOf WL.Analytics# */ function disable():WLPromise; /** * * Logs a message with additional contextual information. * * Log messages are automatically added to a persistent queue. The accumulated data is sent * to IBM® MobileFirst® server on the next explicit WL.Analytics.send function call. * * @example * WL.Analytics.log('my record'); * // or * WL.Analytics.log({data: [1,2,3]}); * // or * WL.Analytics.log({data: [1,2,3]}, 'MyData'); * * @param {string|Object} message The message to log. * @param {string} name The name of the message to log. * * @returns {Promise} Resolved with no parameters, rejected with an error object. * @methodOf WL.Analytics# * @name WL.Analytics#log */ function log(message:string|Object, name?:string):WLPromise; /** * Get the current state of WL.Analytics. * * The state object is kept by WL.Analytics and contains the following key: * * enabled (boolean) - Value is true if capture is enabled, false otherwise. * * Changing the state object that is returned does not affect the state object that is kept internally. * * WL.Analytics.state() * * .then(function (state) { * // {enabled: true} * }) * * .fail(function (errObj) { * //errObj.src = function that failed * //errObj.res = error message * }); * * @returns {Promise} Resolved with state object parameters, rejected with an error object. * @methodOf WL.Analytics# */ function state():WLPromise; /** * * Send any analytics data collected up to this point to the IBM MobileFirst server. * * @returns {Promise} Resolved with success status, rejected with an error message. * * @methodOf WL.Analytics# * @name WL.Analytics#send */ function send():WLPromise; /** * * Trigger In APP Feedback Mode to send feedback to bluemix server * * @returns {Promise} Resolved with success status, rejected with an error message. * * @methodOf WL.Analytics# * @name WL.Analytics#triggerFeedbackMode */ function triggerFeedbackMode():WLPromise; /** * * Specify current application user. If you want user-based analytics, you must use this method * call. For example, use it when the user logs in, and call the unsetUserContext method when the * user logs out. Or if your application supports user profiles, call this method when the user * profile changes. * * @param {string} user User id for current app user. * * @returns {Promise} Resolved with success status, rejected with an error message. * @methodOf WL.Analytics# * @name WL.Analytics#setUserContext */ function setUserContext(user:String):WLPromise; /** * * Unset any user context previously set. * * @returns {Promise} Resolved with success status, rejected with an error message. * * @methodOf WL.Analytics# * @name WL.Analytics#unsetUserContext */ function unsetUserContext():WLPromise; } /** * ================================================================= * Source file taken from :: securityutils.d.ts * ================================================================= */ declare module WL.SecurityUtils { /** * Generates a key by using the PBKDF2 algorithm. * * @param {Object} options Required. * @param {string} options.password Required. Password that is used to generate the key. * @param {string} options.salt Required. Salt that is used to to generate the key. * @param {number} options.iterations Required. Number of iterations that is used for the key generation algorithm. * * @return {Promise} Resolved when the operation succeeds, first parameter is the hex encoded key. * Rejected when there is a failure. * * @methodOf WL.SecurityUtils# */ function keygen(options: Object): WLPromise; /** * Encrypts text with a key. * * @param {Object} options Required. * @param {string} options.key Required. Text to encrypt. * @param {string} options.text Required. Key that is used for encryption. * * @return {Promise} Resolved when the operation succeeds, first parameter is an object which includes the cipher text. * Rejected when there is a failure. * * @methodOf WL.SecurityUtils# */ function encrypt(options: Object): WLPromise; /** * Decryption function. * * @param {Object} options Required. * @param {string} options.key Required. Key. * @param {string} options.ct Required. Cipher Text. * @param {string} options.iv Required. Initialization Vector. * @param {string} options.src Required. Source ('obj' = iOS, 'java' = Android, 'js' = Web). * @param {number} options.v Required. Version. * * @return {Promise} Resolved when the operation succeeds, first parameter is the decrypted text. * Rejected when there is a failure. * * @methodOf WL.SecurityUtils# */ function decrypt(options: Object): WLPromise; /** * Generates a random hex string locally. * * @param {number} [bytes] Optional. Number of bytes that is used to generate the string. Default is 32 bytes. * * @return {Promise} Resolved when the operation succeeds, first parameter is the random hex string. * Rejected when there is a failure. * * @methodOf WL.SecurityUtils# */ function localRandomString(bytes?: number): WLPromise; /** * Encodes input as base64 string. * * @param {string} input Required. Input string. * * @return {Promise} Resolved when the operation succeeds, first parameter is the input string encoded. * Rejected when there is a failure. * * @methodOf WL.SecurityUtils# */ function base64Encode(input: string): WLPromise; /** * Decodes input base64 string to a non base64 encoded string. * * @param {string} input Required. Input base64 encoded string. * * @return {Promise} Resolved when the operation succeeds, first parameter is the input string decoded. * Rejected when there is a failure. * * @methodOf WL.SecurityUtils# */ function base64Decode(input: string): WLPromise; /** * ONLY FOR IOS * Choose wether internal/native or openssl basaed encryption will be applied. * * @param {boolean} enable Required. true native false openssl. * * @return {Promise} Resolved when the operation succeeds. * Rejected when there is a failure. * * @methodOf WL.SecurityUtils# */ function enableOSNativeEncryption(enable: boolean): WLPromise; } /** * ================================================================= * Source file taken from :: wlapp.d.ts * ================================================================= */ declare module WL.App { /** * @deprecated Since version 8.0 * @description Shows the default IBM MobileFirst splash screen on the activity that was passed as a parameter * @methodOf WL.App# * @name WL.App#showSplashScreen */ function showSplashScreen(): void; /** * @deprecated Since version 8.0 * @description Hides the default IBM MobileFirst splash screen if it is shown, * and does nothing if the default MobileFirst splash screen is already hidden * @methodOf WL.App# * @name WL.App#hideSplashScreen */ function hideSplashScreen(): void; /** * This method is applicable to iOS, Android and WP8. * @description * Sets the MobileFirst server URL to the specified URL. * * Changes the MobileFirst server URL to the new URL, cleans the HTTP client context, and calls successCallback when finished. * After calling this method, the application is not logged in to any server. * If the specified URL is malformed, then failCallback is called and the MobileFirst server URL remains unchanged. * * Notes: * The responsibility for checking the validity of the URL is on the developer. * When using this function you might want to perform additional clean-up, for example partial or full wipe of JSONStore or HTML5 LocalStorage. * For more information on clean-up, see {@link WL.JSONStore}. * * @example * WL.App.setServerUrl("http://9.148.23.88:10080/context", successCallback, failCallback); * * @param {string} url Mandatory. The URL of the new server, including protocol, IP, port, and context. * @param successCallback Optional. The callback function that is called after the MobileFirst URL is set to the specified URL. * @param failCallback Optional. The callback function that is called if this method fails or is not supported. * @methodOf WL.App# */ function setServerUrl(url: string, successCallback?: Function, failCallback?: Function ): void; /** * @description * Gets MobileFirst server URL. * This method is asynchronous, so the MobileFirst server URL is returned as an argument to the successCallback function. * * @param successCallback Mandatory. The callback function that is called with the MobileFirst server URL as an argument. * @param failCallback Optional. The callback function that is called if this method fails. * @methodOf WL.App# */ function getServerUrl(successCallback: Function , failCallback?: Function): void; /** * Extracts a string that contains an error message. * @description * * Extracts a string that contains the error message within the specified exception object. * Use for exceptions that are thrown by the IBM MobileFirst client runtime framework. * @param {exception} exception Mandatory. The exception object from which the error string is extracted. * @methodOf WL.App# * @name WL.App#getErrorMessage */ function getErrorMessage(exception: any): string; } declare module WL.NativePage { /** * @deprecated Since version 8.0 * Switches the currently displayed, web-based screen with a natively written page * @param className Mandatory. String. The name of the native class. For iOS, the name of the class (for example, BarCodeController). * For Android, the complete name of the class and package (for example, com.neebula.barcode.Scanner). * @param callback Mandatory. Function. A function object that is called when the native page switches back to the web view. * This function is passed a single JSON object parameter when invoked. * @param data Optional. Object. A JSON object that is sent to the native class. For iOS, The data must be single string or a flat record of strings. * * @example * // Good * WL.NativePage.show("com.scan.BarCode", function(data){alert(data);}, {key1 : 'value1'}); * WL.NativePage.show("com.scan.BarCode", function(data){alert(data);}, {key1 : 'value1', key2 : 'value2'}); * * // Bad * WL.NativePage.show("com.scan.BarCode", function(data){alert(data);}, {key1 : 'value1', innerStruct : {innerKey1 : 'innervalue1'}}); * * @methodOf WL.NativePage# * @name WL.NativePage#show */ function show(className: string, callback: Function, data?: Object): void; } /** * ================================================================= * Source file taken from :: wlauthorizationmanager.d.ts * ================================================================= */ declare module WLAuthorizationManager { /** * @description Obtains an access token for the specified resource scope from the MobileFirst authorization server. * @param {String} scope Optional. Scope for which to obtain the access token. * @returns A promise object that can be used to receive the access token asynchronously. * The access token is sent as an object with the following properties: * scope - the scope which the access token was obtained for. * value - the access token value. * asAuthorizationRequestHeaderField - the access token value required for an authorization header. * asFormEncodedBodyParameter - the access token value required for the HTTP-request entity body. * @example * WLAuthorizationManager.obtainAccessToken(scope) * .then ( * function(accessToken) { * // success flow with the access token * }, * function(error) { * // failure flow * } * }; * * @methodOf WLAuthorizationManager# */ function obtainAccessToken(scope?: string): WLPromise; /** * @description Logs into the specified security check. * @param {String} securityCheck Mandatory. Name of the security check to log into. * @param {Object} credentials Mandatory. Credentials for logging into the specified security check. * @returns A promise object that can be used to login asynchronously. * @methodOf WLAuthorizationManager# */ function login(securityCheck: string, credentials: Object): WLPromise; /** * @description Logs out of the specified security check. * @param {String} securityCheck Mandatory. Name of the security check to log out of. * @returns A promise object that can be used to logout asynchronously. * @methodOf WLAuthorizationManager# */ function logout(securityCheck: string): WLPromise; /** * @description Checks whether the provided response status and headers represent a protected resource that requires authorization. * @param {Integer} responseStatus Mandatory. Specifies the response status code. * @param {String} responseHeaders Mandatory. A String representation of the response headers separated by CRLF, as returned from XMLHttpRequest.getAllResponseHeaders(). * @returns A boolean value, indicating whether authorization is required (<code>true</code>), or not (<code>false</code>). * @methodOf WLAuthorizationManager# */ function isAuthorizationRequired(responseStatus: number, responseHeaders: Object): boolean; /** * @description Checks whether the provided response status and headers represent a protected resource that requires authorization. * @param {Integer} responseStatus Mandatory. Specifies the response status code. * @param {String} responseHeaders Mandatory. A String representation of the response headers separated by CRLF, as returned from XMLHttpRequest.getAllResponseHeaders(). * @returns A boolean value, indicating whether authorization is required (<code>true</code>), or not (<code>false</code>). * @methodOf WLAuthorizationManager# */ function clearAccessToken(accessToken: Object): WLPromise; /** * @description Returns the scope of the protected resource for the provided response headers.<br/> * Note: Call this method only for response headers for which {@link #isAuthorizationRequired(int, Map)} * returns {@code true}, indicating that the resource is protected. * @param {String} responseHeaders Mandatory. A String representation of the response headers separated by CRLF, as returned from XMLHttpRequest.getAllResponseHeaders(). * @returns The protecting scope of the target resource, as returned in the {@code WWW-Authenticate} HTTP response header. * @methodOf WLAuthorizationManager# */ function getResourceScope(responseHeaders: string): string; /** * @description Sets the URL of the authorization server. * When this method is not called, the MobileFirst Server URL is used. * @param {String} url Mandatory. URL of the authorization server to set. * @returns A promise object. * @methodOf WLAuthorizationManager# */ function setAuthorizationServerUrl(url: string): WLPromise; /** * @description Retrieves the URL of the authorization server. * @returns Returns the URL of the current authorization server, as a String. * @returns A promise object. * @methodOf WLAuthorizationManager# */ function getAuthorizationServerUrl(): WLPromise; /** * @description Sets the authorization flow time out. * if this value is not set by user, then default 10s is considered as the default timeout. * @param {number} timeOut Mandatory. URL of the authorization server to set. * @returns A promise object. * @methodOf WLAuthorizationManager# */ function setLoginTimeout(timeOut: number): WLPromise; } /** * ================================================================= * Source file taken from :: wlclient.d.ts * ================================================================= */ declare module WL.Client { /** * @deprecated Since version 8.0 * Adds an HTTP header to be used in server requests issued by an IBM MobileFirst framework. * @description * The HTTP header is used in all requests until removed by the WL.Client.removeGlobalHeader API call. * @example * WL.Client.addGlobalHeader("MyCustomHeader","abcdefgh"); * @param headerName Mandatory. The name of the header to be added. * @param headerValue Mandatory. The value of the header to be added. * @methodOf WL.Client# */ function addGlobalHeader(headerName: string, headerValue: string): void; /** * @deprecated Since version 8.0 * Identifies the type of environment in which the application is running. Such as iPhone, Android, or Windows. * @description * @returns A constant that identifies the type of environment. The valid values are defined in the WL.Environment variable in the worklight.js file, and are as follows: * * WL.Environment.ANDROID * WL.Environment.IPAD * WL.Environment.IPHONE * WL.Environment.MOBILE_WEB * WL.Environment.PREVIEW (when the application runs in Preview mode) * WL.Environment.WINDOWS_PHONE_8 * WL.Environment.WINDOWS8 * WL.Environment.DESKTOPBROWSER * * When an app is running in Preview mode, this method returns WL.Environment.PREVIEW, regardless of the previewed environment. * There are two reasons for this behavior: * * Environment - specific code can fail when invoked from the browser (because the environment might support features that are not available in the browser). *WL.Client behaves differently in different environments (for example, cookie management). * *A good practice is to rely on the IBM MobileFirst UI optimization framework and separate environment-dependent JS to separate files rather than using the WL.Client.getEnvironment() function. * @methodOf WL.Client# */ function getEnvironment(): string; /** * Initializes the WL.Client object. The options of this method reside in the initOptions.js file. * @description * @param options An optional options object augmented with the following additional optional properties: * * Timeout: * An integer value, denoting the timeout in milliseconds. * The timeout affects all calls from the app to the MobileFirst Server. If not specified, a timeout of 30,000 milliseconds (30 seconds) is used. * * messages: * A dictionary object for localizing texts, located in the messages.js file. If not specified, the default object Messages (in the same file) is used. * * * heartBeatIntervalInSecs: * An integer value, denoting the interval in seconds between heartbeat messages automatically sent by WLClient to the MobileFirst Server. The default value is 420 (7 minutes). * * connectOnStartup: * Deprecated: The connectOnStartup init option is deprecated. MobileFirst applications by default are configured to not connect to the MobileFirst Server. If you would like your application to connect to the MobileFirst Server, use WL.Client.connect(). * * onConnectionFailure: * A failure-handling function invoked when connection to the MobileFirst Server, performed on initialization by default, or if the connectOnStartup flag is true, fails. * * onUnsupportedVersion * A failure-handling function invoked when the current version of the application is no longer supported (a newer application has been deployed to the server). For more information about the signature of failure-handling functions, see The Options Object. * * onRequestTimeout * A failure-handling function invoked when the init() request times out. For more information about the signature of failure-handling functions, see The Options Object. * * * onUserInstanceAccessViolation: * A failure-handling function invoked when the user is trying to access an application that was provisioned to a different user. * For more information about the signature of failure-handling functions, see The Options Object. * * onErrorRemoteDisableDenial: * A failure-handling function invoked when the server denies access to the application, according to rules defined in the IBM MobileFirst Console. * If this function is not provided, the application opens a dialog box, which displays an error message defined in the IBM MobileFirst Console. * When used, the function can provide an application-specific dialog box, or can be used to implement additional behavior in situations where the server denies access to the application. * It is important to ensure that the application remains offline (not connected). * * Parameters: * message: This parameter contains the notification text that you defined in the MobileFirst Console, which indicates that an application is denied access to the MobileFirst Server. * downloadLink: This parameter contains the URL that you defined in the MobileFirst Console to download the new version of the application, that users can find in the appropriate application store. * * Example * var wlInitOptions = { * connectOnStartup : true, * onErrorRemoteDisableDenial : function (message, downloadLink) { * WL.SimpleDialog.show( * "Application Disabled", * message, * [{text: "Close application", handler: function() {WL.App.close();}}, * {text: "Download new version", handler: function() {WL.App.openURL(downloadLink, "_blank");}}] * ); * } * }; * * onErrorAppVersionAccessDenial: * A failure-handling function invoked when the server denies access to the application, according to rules defined in the IBM MobileFirst Console. * If this function is used, the developer takes full ownership of the implementation and handling if Remote Disable took place. * If the failure-handling function is not provided, the application opens a dialog box, which displays an error message defined in the IBM MobileFirst Console. * Note: onErrorAppVersionAccessDenial is deprecated since V5.0.6. Instead, use onErrorRemoteDisableDenial. * * validateArguments: * A Boolean value, indicating whether the IBM MobileFirst Client runtime library validates the number and type of method parameters. The default is true. * * autoHideSplash: * A Boolean value, indicating whether the IBM MobileFirst splash-screen will be auto-hidden. To disable automatic hiding of the splash screen set this property to false. Default is true. * * * @note {Note} The onSuccess function is used to initialize the application. * If an onFailure function is not passed, a default onFailure function is called. If onFailure is passed, it overrides any specific failure-handling function. * @methodOf WL.Client# * @name WL.Client#init */ function init(initOptions?: Object): void; /** * @deprecated Since version 8.0. Use WLResourceRequest instead * * Invokes a procedure that is exposed by an IBM MobileFirst adapter. Prior to invoking a procedure, a connect request to the MobileFirst Server is first initiated. * @description * @param invocationData Mandatory. A JSON block of parameters. For a description of the structure of the parameter block. * The WL.Client invokeProcedure function accepts the following JSON block of parameters: * { * adapter : 'adapter-name', * procedure : 'procedure-name', * parameters : [] * } * * adapter: * Mandatory. A string that contains the name of the adapter as specified when the adapter was defined. * * procedure: * Mandatory. A string that contains the name of the procedure as specified when the adapter was defined. * * parameters: * Optional. An array of parameters that is passed to the back-end procedure. * * @param options Optional. A standard options object, augmented with the following property: * * The success handler response object can contain the following properties: * * invocationContext: * The invocationContext object that was originally passed to the MobileFirst Server in the callback object. * * invocationResult: * * An object that contains the data that is returned by the invoked procedure, and the invocation status. Its format is as follows: * invocationResult = { * isSuccessful: Boolean, * errors : "Error Message" * // Procedure results go here * } * * Where: * isSuccessful – Contains true if the procedure invocation succeeded, false otherwise. * If the invocation failed, the failure handler for the request is called. * errors – An optional array of strings containing error messages. * * parameters: * Optional. An array of parameters that is passed to the back-end procedure. * * timeout: Integer. Number of milliseconds to wait for the server response before failing with a request timeout. The default timeout value is 30000 milliseconds (30 seconds). * * The maximum timeout value in any Windows Phone environment is 60000 milliseconds (60 seconds). * * The failure handler of this call is called in two cases: * * The procedure was called but failed. In this case, the invocationResult property is added to the response received by the failure handler. * This property has the same structure as the invocationResult property returned to the success handler, * but the value of the isSuccessful attribute is false. For the structure of the invocationResult property, see invocationResult. * A technical failure resulted in the procedure not being called. In this case, the failure handler receives a standard response object. * * @return {Promise} Resolved when the operation is successful. Rejected when there is a failure. * * @methodOf WL.Client# */ function invokeProcedure(invocationData: Object, options?: Object): WLPromise; /** * @deprecated Since version 8.0. Use WLAuthorizationManager.obtainAccessToken() to check connectivity to the server and apply application management rules. * * This method sends an initialization request to the MobileFirst Platform Server, establishes a connection with the server, validates the application version and provides and Access Token. * @description * @param options Optional. A standard options object. * * @methodOf WL.Client# */ function connect(options?: Object); /** * Pins the host X509 certificate public key to the client application. * Secured calls to the pinned remote host will be checked for a public key match. * Secured calls to other hosts containing other certificates will be rejected. * Some mobile operating systems might cache the certificate validation check results. * Your app must call the certificate pinning method before making a secured request. * Calling this method a second time overrides any previous pinning operation. * @param certificateFilename - name of the certificate file that is located under * the certificate folder in the application root * @return {Promise} Resolved when the operation is successful and the certificate is pinned. Rejected if any of the certificateFilename is undefined, not found or is not in DER format. * @methodOf WL.Client# */ function pinTrustedCertificatePublicKey(certificateFilename: string): WLPromise; /** * Pins the host X509 certificate public key to the client application. * Secured calls to the pinned remote host will be checked for a public key match. * Secured calls to other hosts containing other certificates will be rejected. * Some mobile operating systems might cache the certificate validation check results. * Your app must call the certificate pinning method before making a secured request. * Calling this method a second time overrides any previous pinning operation. * @param certificateFilenames - array of names of certificate file that is located under * the certificate folder in the application root * @return {Promise} Resolved when the operation is successful and the certificates are pinned. Rejected if any of the certificateFilename is undefined, not found or is not in DER format. * @methodOf WL.Client# */ function pinTrustedCertificatePublicKey(certificateFilenames: string[]): WLPromise; /** * Reloads the application * @description It can be used to recover an application from errors. It is preferable to avoid using it and to use alternative error handling mechanisms instead. * The method is mainly available for compatibility with earlier versions. * @methodOf WL.Client# */ function reloadApp(): void; /** * @deprecated Since version 8.0 * Removes the global HTTP header added by the WL.Client.addGlobalHeader API call * @description * @param headerName Mandatory. The name of the header to be removed. * @example * WL.Client.removeGlobalHeader("MyCustomHeader"); * @methodOf WL.Client# */ function removeGlobalHeader(headerName: string): void; /** * Sets the interval of the heartbeat signal. * @description Sets the interval of the heartbeat signal sent to the MobileFirst Server to the specified number of seconds. * The heartbeat is used to ensure that the session with the server is kept alive when the app does not issue any call to the server (such as invokeProcedure). * @param interval Mandatory. An integer value, denoting the interval in seconds between heartbeat messages automatically sent by WLClient to the MobileFirst Server. * An interval value of -1 disables the heartbeat: * WL.Client.setHeartBeatInterval(-1) * @methodOf WL.Client# */ function setHeartBeatInterval(interval: number): void; /** * Retrieves cookies from the native HTTP client. * @description This function is asynchronous and returns a promise. * * The array of cookies will be passed as a parameter to resolve callback. * @example * WL.Client.getCookies().then(function(cookies){...}) * @note {Note} HttpOnly and Secure cookies are not returned. * @returns Promise * @methodOf WL.Client# */ function getCookies(): WLPromise; /** * Adds a cookie to the native HTTP client. * @description This function is asynchronous and returns a promise. * @example * WL.Client.setCookie(myCookie).then(successFlow); * @param cookie Mandatory. JSON object with required cookie properties: name, value, domain, path, expires * @returns Promise * @methodOf WL.Client# */ function setCookie(cookie: Object): WLPromise; /** * Deletes a cookie from the native HTTP client cookie storage. * @description This function is asynchronous and returns a promise. * @example * WL.Client.deleteCookie(myCookie).then(successFlow); * @param name Mandatory. Cookie name. * @returns Promise * @methodOf WL.Client# */ function deleteCookie(name: string): WLPromise; /** /** * Clear all the cookies from persistence and from the cache. * @description This function is asynchronous and returns a promise. * @example * WL.Client.clearCookie().then(successFlow); * @returns Promise * @methodOf WL.Client# */ function clearCookie(): WLPromise; /** * Clear all the session cookies while maintaining the persisted ones. * This function is asynchronous and returns deferred object. * Example: WL.Client.clearCookieSession().then(successFlow); * @returns promise object * @methodOf WL.Client# */ function clearCookieSession(): WLPromise; /** * Returns the previously saved value associated with key. * @description Retrieves a previously saved value associated with key from application participating in simple shared data who are in the same application family, * defined by the same family name and same application signing key. * @note {Note} This API call is only applicable in Android and IOS environments. It is a safe, but no-op, call in other environments. * @param Object Mandatory. Object containing the key to retrieve, like {key: 'myKey'} * @returns Promise containing the retrieved value, or null if no value is found * @methodOf WL.Client# */ function getSharedToken(Key: Object): WLPromise; /** * Saves a key/value pair such that it is available to other applications. * @description Saves a key/value pair such that it is available to other applications participating in simple shared data who are in the same application family, * defined by the same family name and same application signing key. * @note {Note} This API call is only applicable in Android and IOS environments. It is a safe, but no-op, call in other environments. * @param Object Mandatory. Object containing the key/value pair to share, like {key: 'myKey', value: 'myValue'} * @returns Promise * @methodOf WL.Client# */ function setSharedToken(keyvaluepair: Object): WLPromise; /** * Clears a previously saved value associated with key. * @description Clears a previously saved value associated with key from applications participating in simple shared data who are in the same application family, * defined by the same family name and same application signing key. * @note {Note} This API call is only applicable in Android and IOS environments. It is a safe, but no-op, call in other environments. * @param Object Mandatory. Object containing the key to clear, like {key: 'myKey'} * @returns Promise * @methodOf WL.Client# */ function clearSharedToken(Key: Object): WLPromise; /** * @deprecated Since version 8.0 * Return the language code of the language being used. * @description This method returns the language or dialect code of the language currently being used for the application. * @note {Note} This method is not relevant for mobile operating systems. Use mobile locale methods instead. * @returns The language or dialect code of the currently set language, or NULL if no language is set. The language or dialect code has the format ll or ll-cc, * where ll is a two-letter ISO 639-1 language code and cc is a two-letter ISO 3166-1-alpha-2 country or region code. * * @methodOf WL.Client# */ function getLanguage(): string; /** * Creates a challenge handler responsible for handling responses from a third party gateway. * An arbitrary name must be supplied as a parameter. * * When you create a GatewayCheckChallengeHandler, you must implement the following methods: * * - canHandleResponse() - Called each time that a response is received from the server. It is used to detect whether the response contains data that is related to this challenge handler, and returns TRUE if so, and FALSE if not. If this method returns TRUE, the framework will call handleChallenge. * - handleChallenge() - The MobileFirst framework calls this method only when canHandleResponse(). This function is used to perform required actions, such as hiding the application screen, displaying the login screen, or other actions required to pass the challenge successfully. * * The following APIs are available on the generated GatewayCheckChallengeHandler: * * - cancel() - Notifies the MobileFirst framework that the authentication process needs to be canceled. * The MobileFirst framework then disposes of the original request that triggered the authentication. * - submitLoginForm(reqURL, options, submitLoginFormCallback) - Call this method to send collected credentials to a specific URL. The developer can also specify request parameters, headers, and callback. * - submitSuccess - Call this method to notify the MobileFirst framework that the authentication successfully finished. * The MobileFirst framework then automatically issues the original request that triggered the authentication. * * @param gatewayName An arbitrary name representing the challenge. * @methodOf WL.Client# */ function createGatewayChallengeHandler(gatewayName: string): WL.Client.GatewayChallengeHandler; /** * Creates a challenge handler object to handle challenges that are sent by the MobileFirst Server. * * A SecurityCheckChallengeHandler works only with a security check that is based on the MobileFirst authentication protocol, * that is, server side security check instance extends one of the MobileFirst provided security checks, * There must be only one challenge handler per security check. To comply with the MobileFirst authentication protocol, * the challenge that the challenge handler receives must be a JSON object. * <p> * When you create a SecurityCheckChallengeHandler, you must implement the following methods: * * - handleChallenge() - The MobileFirst framework calls this method only for the relevant challenge. This function is used to perform required actions, * such as hiding the application screen, displaying the login screen, or other actions required to pass the challenge successfully. * - handleSuccess() - This method is called when the MobileFirst Server reports an authentication success. * - handleFailure() - This method is called when the MobileFirst Server reports an authentication failure. * * * The following APIs are available on the generated GatewayCheckChallengeHandler: * * - cancel() - Notifies the MobileFirst framework that the authentication process needs to be canceled. * The MobileFirst framework then disposes of the original request that triggered the authentication. * - submitChallengeAnswer(answer) - Call this method to send an answer back to the security check that triggered this challenge. The answer should be in a JSON format. * * @param securityCheckName security check name that represents the challenge, * Used to identify which security check requires authentication. * * @methodOf WL.Client# * */ function createSecurityCheckChallengeHandler(securityCheckName: string): WL.Client.SecurityCheckChallengeHandler; class AbstractChallengeHandler { isWLHandler: boolean; activeRequest: Object; requestWaitingList: Object[]; /** * This function is called whenever the response is considered relevant to this challenge. This function is used to perform required actions, * such as hiding the application screen, displaying the login screen, or other actions required to pass the challenge successfully. * @param challenge Challenge to handle * @methodOf WL.Client.AbstractChallengeHandler# * @name WL.Client.AbstractChallengeHandler#handleChallenge */ handleChallenge(challenge: Object): void; /** * Notifies the MobileFirst framework that the authentication process needs to be canceled. * The MobileFirst framework then disposes of the original request that triggered the authentication * @param err Error message if available * @methodOf WL.Client.AbstractChallengeHandler# * @name WL.Client.AbstractChallengeHandler#cancel */ cancel(): void; } class SecurityCheckChallengeHandler extends AbstractChallengeHandler{ MAX_NUMBER_OF_FAILURES: number; numOfFailures: number; /** * This method is called when the MobileFirst Server reports an authentication success. **/ handleSuccess(identity?: any): void; /** * This method is called when the MobileFirst Server reports an authentication failure. **/ handleFailure(err?: any): void; /** * Call this method to send an answer back to the security check that triggered this challenge. The answer should be in a JSON format. **/ submitChallengeAnswer(answer: Object): void; } class GatewayChallengeHandler extends AbstractChallengeHandler{ /** * User calls this function when the the challenge was handled successfully. * When a success is submitted, the state of successes is checked for all challenges issued per original request. * What this means is that, if all challenges are successfully met, the original message would be resent automatically. */ submitSuccess(): void; /** * Must be implemented by developer. * * This method will be invoked by the IBM MobileFirst Platform for every server response. * It is responsible to detect whether server response contains data * that should be processed by this challenge handler. * @param transport Response that arrived from the server * @return true if the response is a challenge that this handler handles */ canHandleResponse(transport: any): boolean; /** * Used to send collected credentials to a specific URL. The developer can also specify request parameters, headers, and callback. * @param reqURL URL to send data to * @param options Other options like timeout, extra headers * @param submitLoginFormCallback Callback method when operation is done */ submitLoginForm(reqURL: string, options: Object, submitLoginFormCallback: Function): void; } /** * Gets the display name of the device. The display name is retrieved from the MobileFirst Server registration data. * Note: Remote disable and active notifying customizations, if any, will be ignored when this API call is made. The default UI will be displayed instead. This limitation is applicable to iOS & Windows only. * * @param {Object} options An object that contains <code>onSucess</code> and <code>onFailure</code> completion callback functions.<br /> * The <code>onSuccess</code> function receives a JSON object parameter that contains the server's response, which includes the * display name of the the device or null if no display name was set. For example: * <ul> * <li>{ responseJSON: { deviceDisplayName: "John's Device" } }</li> * <li>{ responseJSON: { deviceDisplayName: null } }</li> * </ul> * * @methodOf WL.Client# */ function getDeviceDisplayName(options: Object): void; /** * Sets the display name of the device. The display name is stored in the MobileFirst Server registration data. * Note: Remote disable and active notifying customizations, if any, will be ignored when this API call is made. The default UI will be displayed instead. This limitation is applicable to iOS & Windows only. * * @param {String} deviceDisplayName The device display name to set. * @param {Object} options An object that contains <code>onSucess</code> and <code>onFailure</code> completion callback functions. * * @methodOf WL.Client# */ function setDeviceDisplayName(deviceDisplayName: string, options: Object): void; } /** * ================================================================= * Source file taken from :: wlgap.d.ts * ================================================================= */ declare module WL.App { /** * supported only on Android environment * returns the screen height * @returns {number} screen height */ function getScreenHeight(): number; /** * supported only on Android environment * returns the screen width * @returns {number} screen width */ function getScreenWidth(): number; /** * supported only on Android environment * retrieving screen size * @param {Function} callback Mandatory function. The callback function that is invoked when the size is received. */ function getScreenSize(callback: Function): void; /** * supported only on Android, Windows Phone and iOS environments * reset server context */ function resetServerContext(): void; /** * supported only on Android, Windows Phone and iOS environments * returns user preference value for the given key * @param {string} key * @param {Object} options * @param {Function} options.onSuccess * @param {Function} options.onFailure */ function readUserPref(key: string, options: Object): void; /** * supported only on Android, Windows Phone and iOS environments * writes user preference with the give key,value pair * @param {string} key * @param {Object} value */ function writeUserPref(key: string, value: Object): void; /** * supported only on Android, Windows Phone and iOS environments * get init parameters * @param {string} parameters * @param {Function} successCallback Mandatory function. * @param {Function} failCallback Mandatory function. */ function getInitParameters(parameters: string, successCallback: Function, failCallback: Function): void; /** * supported only on Android, Windows Phone and iOS environments * Send an action to the native code. The action will be processed immediately, if the target receiver has been registered. * Otherwise, the action will be stored in the cache and processed as soon as the target receiver becomes available (registered). * @param {string} action - a string that identifies target receivers; all receivers registered with the specified action will receive the message. * @param {Object} data - an optional data object to be passed to target receivers along with action; * @param {string} tag */ function sendActionToNative(action: string, data?: Object, tag?: string): void; /** * supported only on Android, Windows Phone and iOS environments * Registers an action receiver. In JavaScript a receiver should be implemented as a callback that can receive an object. * @param {string} id - a string that identifies the receiver. This string will be specified in the native code when sending notifications to JavaScript. * @param {Function} callback - implementation of receiver. This callback will be called when an action identified by "id" is sent from the native code. * @param {string} tag */ function addActionReceiver(id: string, callback: Function, tag?: string): void; /** * supported only on Android, Windows Phone and iOS environments