Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@acpaas-ui/js-eid-utils

Package Overview
Dependencies
Maintainers
9
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@acpaas-ui/js-eid-utils

[![js-eid-utils-status]][js-eid-utils-package]

  • 1.0.1
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by75%
Maintainers
9
Weekly downloads
 
Created
Source

Eid module

js-eid-utils-status

EidMiddleware

EidMiddleware module wrapper for Dios EidMiddleware

Example usage

In the example repository is an example on how to use eid-middleware.

https://bitbucket.antwerpen.be/projects/AUI/repos/examples/browse/21_eid_middleware

Initialize the middleware


The package puts an eid.middleware on the window object.

(function(eidMiddleware){

    new eidMiddleware()
            .initializeMiddleware()
            .then(onStatusOk, onError);

})(window.eid.middleware)

initializeMiddleware()

This method initializes the necessary services to communicate with the middleware.

Returns:

A Promise.

onStatusOk

This callback receives a statusInfo object which looks like this:

{
    code: 0,
    app: {
        url: '..',
        version: '1.2.1'
    }
}

The code property contains the statuscode returned from the middleware.

If app property is on the object it means that your current version is out of date or not running.

onError

This callback is triggered when the initialisation didn't recieve an OK and receives a statusInfo object which looks like this:

{
    code: 0,
    app: {
        url: '..',
        version: '1.2.1'
    }
}

The code property contains the statuscode returned from the middleware.

If app property is on the object it means that your current version is out of date or not running.

StatusCodes

All status code can be found on window.akit.services.eid.constants.statusCodes. They are the following:

ValueConstantMeaning
0OKEverything is running and ready to communicate with.
1SERVICE_NOT_RUNNINGThe middleware is not running.
2INTERNAL_SERVICE_ERRORAn internal error occured while trying to connect to the middleware.
3SERVICE_OUT_OF_DATE The middleware is out of date, but running.
4EXTENSION_NOT_INSTALLEDThe chrome extension is not installed.
5NATIVE_APP_NOT_INSTALLEDJava applet is not installed.
6SANDBOXEDThe middleware is running sandboxed.

Hooking up events


On the window.akit.services.eid instance there is an onEvent hook where you can listen voor all the events.

    window.akit.services.eid.onEvent('*', onCorrectCardInserted);

Each event callback has his own signature, which you can find in the table below.

Events

All event can be found on window.akit.services.eid.events. They are the following:

ValueConstantMeaningCallback signature
incorrectCardInsertedINCORRECT_CARD_INSERTEDThe inserted card is incorrect.fn(eventName)
cardIncorrectInsertedCARD_INCORRECT_INSERTEDThe card is incorrectly inserted.fn(eventName)
correctCardInsertedCORRECT_CARD_INSERTED The card is correctly inserted.fn(eventName, { eidCard , data})
correctCardRemovedCORRECT_CARD_REMOVEDA correct card has been removed.fn(eventName, { data })
incorrectInsertedCardRemovedINCORRECT_INSERTED_CARD_REMOVEDA incorrectly inserted card has been removed.fn(eventName)
incorrectCardRemovedINCORRECT_CARD_REMOVEDAn incorrect card has been removed.fn(eventName)
noCardReaderFoundNO_CARD_READER_FOUNDThe card reader was not found.fn(eventName)
cardReaderConnected CARD_READER_CONNECTEDA card reader connected.fn(eventName, { name })
cardReaderDisconnectedCARD_READER_DISCONNECTEDA cord reader disconnected.fn(eventName, { name })

Next to all these events you can listen for * which indicate that you want to be notified on all events.

Working with the eID


On the CORRECT_CARD_INSERTED event you get and eIDInstance as parameter. This instance is used to communicate with the eID card itself through the middleware.

readValidationData()

This method allows the reading of all validation data required by eid_login backend.

    eIdInstance
        .readValidationData()
        .then(function onSuccess(data){

        }, function onError(error){

        });

Returns:

A Promise. This promise has the following object if resolved. All the date is base64 encoded.

    {
        authenticationCertificate: ... ,
        nonRepudiationCertificate: ... ,
        rnCertificate: ... ,
        rawAddressData: ... ,
        addressDataSignature: ... ,
        rawRnData: ... ,
        rnDataSignature: ... ,
        citizenCertificate: ...
    }

If the promise is rejected it will contain the error where things went wrong.

signWithAuthenticationToken(token)

This method creates a signed authenticated signature with the provided token.

    eIdInstance
        .signWithAuthenticationToken(token)
        .then(function onSuccess(signedData){

        }, function onError(error){

        });

Returns:

A Promise. This promise has the signed data if resolved.

If the promise is rejected it will contain the error where things went wrong.

setupPinRequestFlow

When the middleware requires the insertion of the pincode, it has a default dialog (in dutch). You can use setupPinRequestflow to overwrite that dialog.

    eIdInstance
        .setupPinRequestFlow(
            requestCallback,
            onCorrectPin,
            onError,
            onTriesLeftUpdated
        );

requestCallback

Construct your dialog logic here. Use checkPin to ask the middleware to check the pinCode.

    ...
    requestCallback : function(checkPin, pinTriesLeft){
        // show dialog

        if(ok){
            checkPin(enteredPinCode, null);
        } else {
            var error = {
                message: 'user cancelled pin entry',
                code: 2004
            };
            checkPin(null, error);
        }
    },
    ...

onCorrectPin

This callback will be called if the pincode was correct.

    ...
    onCorrectPin: function(){
        // close dialog
    },
    ...

onError

This callback will be called if the pincode was incorrect.

    ...
    onError: function(error){
        // Display the error
    },
    ...

onTriesLeftUpdated

This callback will be called when the amount of tries changed.

    ...
    onTriesLeftUpdated: function(tries){
        // update ui with the remaining tries
    }

Error codes

When working with the eIdInstance and errors return the following object structure will be returned:

{
    message: '...',
    code: 0000
}

All error codes are listed below.

EIdInstance Error codes
CodeMeaning
2000No card in reader
2001Communication error (with card).
2002Parsing error: could not interpret date from the card.
2003Timeout occurered (e.g. pin code entry).
2004Operation cancelled by the user (e.g. with entry of the pin code).
2005Operation aborded (e.g. removing card while entering pin code).
2100Wrong pin, 2 tries left.
2101Wrong pin, 1 try left.
2102Wrong pin, card blocked.

FAQs

Package last updated on 20 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc