User Tools

Site Tools


web-integration:client-side

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
web-integration:client-side [2019/08/01 09:58]
tjotov
web-integration:client-side [2019/08/05 12:42]
tjotov [Advanced methods]
Line 1: Line 1:
-====== ADUCID Web Integration Client API Description ======+====== Client API for Web Integration ======
  
 Web Integration API is an essential part of ADUCID for all web browser scenarios. It connects PEIG, AIM and the browser. Integration API is an essential component of [[components:binder|ADUCID Binder]], [[nocode:transactions|No-Code transacations]] and many other components. Web Integration API is an essential part of ADUCID for all web browser scenarios. It connects PEIG, AIM and the browser. Integration API is an essential component of [[components:binder|ADUCID Binder]], [[nocode:transactions|No-Code transacations]] and many other components.
Line 10: Line 10:
 </sxh>      </sxh>     
  
-===== Basic usage with AAA =====+===== Basic usage with No-Code =====
 Create instance of ADUCID object: Create instance of ADUCID object:
 <sxh java> <sxh java>
Line 50: Line 50:
 </sxh> </sxh>
  
-===== Advanced usage ===== +===== Web Integration API - Example ===== 
-advanced method to pass more parameters like transaction amount, description, etc.+ 
 +<code html> 
 + 
 +<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> 
 + 
 +<head> 
 +<script type="text/javascript" src="/aducid-resources/js/jquery.min.js"></script> 
 +<script type="text/javascript" src="/aducid-resources/js/aducid-api.js"></script> 
 + 
 +<script type="text/javascript"> 
 +    var aducid = new ADUCID(); 
 +    $(document).ready(function() { 
 +        aducid.setAuthentication(); 
 +        aducid.setStartOperationUrl("/aducid-binder/open"); 
 +        aducid.setResultOperationUrl("/aducid-binder/openCheck"); 
 +        aducid.setProxyUrl("/aducid-binder/proxy"); 
 +        aducid.setRedirectUrl("/aducid-binder/"); 
 +        aucid.setRedirectUrl("/myapp/authenticated"); 
 +        aducid.setErrorPage("/myapp/errorPage"); 
 +         
 +        aducid.processResult = function(result) { 
 +            if (result.status == "OK") { 
 +                alert("Success - status: " + result.status); 
 +                location.href = result.redirect; 
 +            } 
 +            else { 
 +                alert("Error - status: " + result.status); 
 +                location.href = result.redirect; 
 +            } 
 +        } 
 + 
 +        //handle PEIG not installed error 
 +        aducid.showPeigError = function() { 
 +            alert("peig not found or other error"); 
 +        } 
 + 
 +        //handle communication or other error 
 +        aducid.handleError = function(e) { 
 +            alert(e.data.message); 
 +        } 
 + 
 +        aducid.showQRHint = function(param) { 
 +            $('#qr-code-hint').html("Scan QR or click button to authenticate"); 
 +        } 
 + 
 +        aducid.showRunningHint = function(param) { 
 +            $('#qr-code-hint').html("Operation is runni­ng"); 
 +        }; 
 + 
 +        //GUI mapping 
 +        aducid.setButton($("#main-button")); 
 +        aducid.setQrCode($("#qr-code")); 
 +        aducid.setQrHint($("#qr-code-hint")); 
 + 
 +        //start 
 +        aducid.init(); 
 +    }); 
 +</script> 
 +</head> 
 +<body> 
 + 
 + <h1>LOGIN PAGE</h1> 
 + <div> 
 + <button id="main-button">LOGIN using local PEIG</button> 
 + </div> 
 + <img id="qr-code" alt="" /> 
 + <div id="qr-code-hint"></div> 
 + 
 +</body> 
 +</html> 
 + 
 +</code> 
 + 
 + 
 + 
 +===== Detailed description ===== 
 +See also source file "/aducid-resources/js/aducid-api.js" 
 + 
 +==== Communication ==== 
 +=== Start operation URL === 
 +Tell Web API where your start operation is.
 <sxh java> <sxh java>
-    aducid.setInitParams = function(param) { +    aducid.setStartOperationUrl = function(param) { 
-        initParams = param;+        startOperationUrl = param;
     }     }
 </sxh> </sxh>
-tell server to generate QR / or not to reduce payload+ 
 +=== Check method location provided by server side controller ===
 <sxh java> <sxh java>
-    aducid.setGenerateQr = function(param) { +    aducid.setResultOperationUrl = function(param) { 
-        generateQr = param;+        resultOperationUrl = param;
     }     }
 </sxh> </sxh>
-QR code and animation location jQuery+ 
 +=== Proxy method location ===
 <sxh java> <sxh java>
-    aducid.setQrCode = function(param) { +    aducid.setProxyUrl = function(param) { 
-        qrCode = param;+        proxyUrl = param;
     }     }
 +
 </sxh> </sxh>
  
-QR code hint jQuery+=== Tell AJAX to use GET or POST === 
 +POST is used to deliver more data like transaction parameters
 <sxh java> <sxh java>
-    aducid.setQrHint = function(param) { +    aducid.setAjaxMethod = function(param) { 
-        qrHint = param;+        ajaxMethod = param;
     }     }
 </sxh> </sxh>
  
 +=== Redirect URL for iOS typically provided by server side controler ===
 <sxh java> <sxh java>
-debug DOM to display internal messages +    aducid.setRedirectUrl = function(param) { 
-    aducid.setDebug = function(param) { +        redirectUrl = param;
-        aducidDebug = param;+
     }     }
 </sxh> </sxh>
  
-server URL typically provided by server side controller+==== UI methods ==== 
 +=== Tell server to generate QR / or not to reduce payload ===
 <sxh java> <sxh java>
-    aducid.setStartOperationUrl = function(param) { +    aducid.setGenerateQr = function(param) { 
-        startOperationUrl = param;+        generateQr = param;
     }     }
 </sxh> </sxh>
  
-check method location provided by server side controller+=== QR code targeting using jQuery ===
 <sxh java> <sxh java>
-    aducid.setResultOperationUrl = function(param) { +    aducid.setQrCode = function(param) { 
-        resultOperationUrl = param;+        qrCode = param;
     }     }
 </sxh> </sxh>
-    //URL with proxy method provided  by server 
-    //returns status oft running operation from AIM until finish 
-    aducid.setProxyUrl = function(param) { 
-        proxyUrl = param; 
-    } 
  
-Tell AJAX to use GET or POST +=== QR code text hint jQuery === 
-POST is used to deliver more data like transaction parameters +<sxh java> 
-    aducid.setAjaxMethod = function(param) { +    aducid.setQrHint = function(param) { 
-        ajaxMethod = param;+        qrHint = param;
     }     }
 +</sxh>
  
-Redirect URL for iOS typically provided by server side controler +==Button bound operation === 
-    aducid.setRedirectUrl function(param) { +<sxh java>
-        redirectUrl param; +
-    } +
- +
-Button with bound operation+
     aducid.setButton = function(param) {     aducid.setButton = function(param) {
         aducidButton = param;         aducidButton = param;
Line 122: Line 199:
         });         });
     }     }
- +</sxh> 
-Internal logic to evaluate API binding mode +=== Text hint shown before operation started === 
-    aducid.setSessionBinding function(param) { +<sxh java>
-        if (param == "QR" || param == "URI") { +
-        } +
-        else param = ""; +
-        localStorage['session-binding'] = param; +
-    } +
- +
-Get last binding mode +
-    aducid.getSessionBinding = function() { +
-        return localStorage['session-binding']; +
-    } +
- +
-Is binding URI? +
-    aducid.isURI = function() { +
-        return instance.getSessionBinding() == "URI"; +
-    } +
-     +
-Is binding QR? +
-    aducid.isQR = function() { +
-        return instance.getSessionBinding() == "QR"; +
-    } +
- +
-Is this operation going to be authentication (i.e. first operation in chain)? +
-    aducid.setAuthentication = function() { +
-        instance.setSessionBinding(null); +
-    } +
- +
-Text hint shown before operation started+
     aducid.showQRHint = function(param) {     aducid.showQRHint = function(param) {
         if (qrHint != null) qrHint.html(localize("aducid_common_authenticateComment"));         if (qrHint != null) qrHint.html(localize("aducid_common_authenticateComment"));
     }     }
 +</sxh>
  
-How API can hide text hint+=== How API can hide text hint === 
 +<sxh java>
     aducid.hideQRHint = function(param) {     aducid.hideQRHint = function(param) {
         if (qrHint != null) qrHint.html("");         if (qrHint != null) qrHint.html("");
     }     }
  
-Text hint shown after operation started+=== Text hint shown after operation started === 
 +<sxh java>
     aducid.showRunningHint = function(param) {     aducid.showRunningHint = function(param) {
         if (qrHint != null) qrHint.html(localize("aducid_common_authenticationProgress"));         if (qrHint != null) qrHint.html(localize("aducid_common_authenticationProgress"));
     }     }
 +</sxh>
  
-How API can hide text hint+=== How API can hide text hint === 
 +<sxh java>
     aducid.hideRunningHint = function(param) {     aducid.hideRunningHint = function(param) {
         if (qrHint != null) qrHint.html("");         if (qrHint != null) qrHint.html("");
     }     }
- +</sxh> 
-The most important method - what API should do when operation finishes (not processed on iOS as we use returnUrl directly there) +==Auxiliary method to animate operation in progress === 
-    aducid.processResult function(result) { +<sxh java>
-        alert(result); +
-    } +
- +
-How PEIG not installed is treated, marketplace redirect can be used here +
-    aducid.showPeigError function() { +
-        alert("peig error - override this function"+
-    } +
- +
- +
-Auxiliary method to animate operation in progress+
     aducid.startAnimation = function() {     aducid.startAnimation = function() {
         if (qrCode != null) {         if (qrCode != null) {
Line 189: Line 234:
         }         }
     }     }
 +</sxh>
          
-Stop animation+=== Stop animation === 
 +<sxh java>
     aducid.stopRunningAnimation = function() {     aducid.stopRunningAnimation = function() {
         if (qrCode == null) return;         if (qrCode == null) return;
         qrCode.hide();         qrCode.hide();
     }     }
 +</sxh>
 +==== Advanced methods ====
 +=== Init Params ===
 +Method to pass more parameters like transaction amount, description, etc.
 +<sxh java>
 +    aducid.setInitParams = function(param) {
 +        initParams = param;
 +    }
 +</sxh>
  
 +=== Debug DOM to display internal messages ===
 +<sxh java>
 +    aducid.setDebug = function(param) {
 +        aducidDebug = param;
 +    }
 +</sxh>
  
-This method controll progress bar animation. See aducid-api.js +=== Is binding URI? === 
-   this.startProgressBar = function(animationTime) { +<sxh java> 
-   }+    aducid.isURI = function() { 
 +        return instance.getSessionBinding() == "URI"; 
 +    } 
 +</sxh> 
 +     
 +=== Is binding QR? === 
 +<sxh java> 
 +    aducid.isQR = function() { 
 +        return instance.getSessionBinding() == "QR"; 
 +    }
  
 +=== Is this operation going to be authentication (i.e. first operation in chain)? ===
 +<sxh java>
 +    aducid.setAuthentication = function() {
 +        instance.setSessionBinding(null);
 +    }
 +</sxh>
  
-Hide QR timer progress bar +=== Get last binding mode === 
-    aducid.hideProgressBar = function() { +<sxh java> 
-        if (qrTimer == null) return+    aducid.getSessionBinding = function() { 
-        qrTimer.hide(); +        return localStorage['session-binding'];
-        qrTimer.html("");+
     }     }
 +</sxh>
  
-How errors are treated - use nice dialogues here+=== How PEIG not installed is treated, marketplace redirect can be used here === 
 +<sxh java> 
 +    aducid.showPeigError = function() { 
 +        alert("peig error - override this function"
 +    } 
 +</sxh> 
 + 
 +=== How errors are treated - use nice dialogues here === 
 +<sxh java>
     aducid.handleError = function(e) {     aducid.handleError = function(e) {
         alert(e);         alert(e);
     }     }
- +</sxh>
- +
web-integration/client-side.txt · Last modified: 2020/02/29 10:53 by mpospisek