Client side Browser plugin / extension
For "eParaksts Token Signing" functionality, a custom plugin/Extension must be installed on the end user's computer for browsers that communicate with the smart card.
End user plugin/extension installation are distributed with eParakstītājs 3.0 software package
Using the JavaScript API function getBackendInfo, it is possible to determine the state of the installed plugin/extension. In situations where the plugin/extension is not installed or its version is out of date.
JavaScript API (HWCrypto)
Components
JavaScript API (HWCrypto) consists of three files:
- eparaksts-hwcrypto.js – main functions;
- eparaksts-hwcrypto-legacy.js – additional functionality to provide compatibility with IE8+;
- eparaksts-jquery.js – additional compatibility functions.
JavaScript API functions
getBackendInfo
Function
Returns information about end user plugin/extension
Promise window.eparakstshwcrypto.getBackendInfo()
Parameters
none
Result
Returns the Promise object that corresponds to the BackendInfo data type.
Errors
Expected errors:
- technical_error.
See section JavaScript API Error Handling.
getCertificate
Function
Prompts the user to select a certificate from the list of available certificates. Connection to a browser plugin/extension that allows certificate data to be read from the user's smart card.
Promise window.eparakstshwcrypto.getCertificate(object options)
Parameters
Property | Type | Mandatory | Description | |
---|---|---|---|---|
options | object | no | Conditions for certificate selection. | |
lang | string | no | Preferred user interface language (ISO-639-1 code). Supported languages: en - English (default value); lv - Latvian; ru - Russian. The user interface language is not fully affected because the language used can be determined by the operating system or browser. | |
operation | string | no | Type of operation: sign - document signing (signing certificate will be returned) (default value); auth - user authentication (authentication certificate will be returned) |
Result
Returns the Promise object that corresponds to the Certificate data type.
Errors
Expected errors:
- no_implementation;
- no_certificates;
- user_cancel;
- technical_error.
See section JavaScript API Error Handling.
sign
Funcion
Requires the user to sign the prepared HASH value (signable data for example). Connection to a browser plugin/extension that provides signing on the user's smart card.
Promise window.eparakstshwcrypto.sign(object certificate, object hash, object options)
Parameters
Property | Object properties | Type | Mandatory | Description |
---|---|---|---|---|
certificate | object | yes | Certificate to use the corresponding private key for signing. An object corresponding to the Certificate data type was obtained using the getCertificate function. | |
hash | object | yes | Prepared signable HASH value | |
type | string | yes | The value of the type field is not interpreted, but it is saved for backwards compatibility. In all cases it is recommended to use the constant "SHA" | |
hex | string | yes | Signable HASH value in HEX encoding.* * or in case of multiple document (batch) signing, signable HASH values must be included in JSON object, which contains one or more "key:value" pairs, where: "key" - signed document identifier; "value" - Signable HASH value in HEX encoding | |
options | object | no | Signing conditions | |
lang | string | no | Preferred user interface language (ISO-639-1 code). Supported languages: en - English (default value); lv - Latvian; The user interface language is not fully affected because the language used can be determined by the operating system or browser. | |
operation | string | no | Type of operation: sign - document signing (default value); auth - user authentication | |
info | string | no | Informative text (document title, transaction amount, etc.). |
Result
Returns the Promise object that corresponds to the Signature data type.
Errors
Expected errors:
- no_implementation;
- invalid_argument;
- user_cancel;
- technical_error;
- pin_blocked.
See section JavaScript API Error Handling.
Data Types
BackendInfo
Contains information about the end user plugin/extension installed in the browser.
Attributes
Property | Type | Description |
---|---|---|
type | string | Plugin/extension type: - NO_IMPLEMENTATION - Plugin/extension is blocked or not installed - FAILING_CHROME - Plugin/extension is not working, end user must enable plugin/extension and restart browser - FAILING_NPAPI - Plugin/extension is not working, end user must enable plugin/extension and restart browser - Plugin/extension name - Plugin/extension is working. Plugin/extension version is additionally available. |
version | string | Plugin/extension version |
Certificate
Contains X509 certificate data.
Attributes
Property | Type | Description |
---|---|---|
encoded | Uint8Array | The binary value of the certificate in DER encoding. |
hex | string | The value of the certificate in HEX encoding. (Optional) |
Signature
Contains signed data.
Attributes
Property | Type | Description |
---|---|---|
hex | string | Signed data in HEX encoding.* *If request contains "JSON" type, signed data are included in JSON object, which contains one or more "key:value" pairs, where: "key" - signed document identifier; "value" - signed data in HEX encoding. The order in which the "key:value" pairs are returned may not be identical to the order in which the signature request was built. |
Updated 11 months ago