Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
NCALayer JS
https://seithq.gitbook.io/ncalayerjs
Admin
NCALayer JS is a small wrapper around NCALayer web socket API.
Tokens:
4,154
Snippets:
34
Trust Score:
9.8
Update:
1 month ago
Context
Chat
Benchmark
53.8
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Query documentation via HTTP GET Source: https://seithq.gitbook.io/ncalayerjs/llms.txt Perform a GET request to the documentation index with 'ask' and 'goal' parameters to receive tailored answers. ```http GET https://seithq.gitbook.io/ncalayerjs/master.md?ask=<question>&goal=<end_goal> ``` -------------------------------- ### Initialize and Use NCALayer Client Source: https://seithq.gitbook.io/ncalayerjs Setup a WebSocket connection and initialize the client to invoke API methods. Do not modify the WebSocket's onmessage listener as the client manages it internally. ```javascript import Client from "@seithq/ncalayer" // Initialize websocket connection with running NCALayer. let ws = new WebSocket("wss://127.0.0.1:13579/") // Handle onopen, onerror and onclose events as you want. ws.onopen = (e) => { // your code goes here } ws.onerror = (e) => { // your code goes here } ws.onclose = (e) => { // your code goes here } // Initialize client to work with API. const client = new Client(ws) // Call API method. client.browseKeyStore("PKCS12", "P12", "", (data) => { // on success if (data.isOk()) { // some action } // on failure console.error(data) }) ``` -------------------------------- ### Install NCALayer JS via Package Managers Source: https://seithq.gitbook.io/ncalayerjs Commands to add the library to your project using npm or yarn. ```bash npm install @seithq/ncalayer ``` ```bash yarn add @seithq/ncalayer ``` -------------------------------- ### browseKeyStore Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Browses the key store for a specific storage type and file extension. ```APIDOC ## browseKeyStore(storageName, fileExtension, currentDirectory, callback) ### Description Browses the key store for a specific storage type and file extension. Available storage names include PKCS12, AKKaztokenStore, AKKZIDCardStore, AKEToken72KStore, and AKJaCartaStore. ### Parameters - **storageName** (string) - Required - Storage name. - **fileExtension** (string) - Required - File extension (e.g., P12). - **currentDirectory** (string) - Required - Directory to browse. - **callback** (Callback) - Required - Callback function to be performed on API response. ``` -------------------------------- ### Available Methods Source: https://seithq.gitbook.io/ncalayerjs/reference/method.md A list of all methods available for invocation within the NCALayerJS library. ```APIDOC ## Available Methods The following methods are available for use: - `none` - `browseKeyStore` - `showFileChooser` - `getKeys` - `setLocale` - `getNotBefore` - `getNotAfter` - `getSubjectDN` - `getIssuerDN` - `getRdnByOid` - `signPlainData` - `verifyPlainData` - `createCMSSignature` - `verifyCMSSignature` - `createCMSSignatureFromFile` - `verifyCMSSignatureFromFile` - `signXml` - `verifyXml` - `signXmlByElementId` - `verifyXmlByElementId` - `getHash` ``` -------------------------------- ### showFileChooser Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Opens a file chooser dialog for the user to select a file. ```APIDOC ## showFileChooser(fileExtension, currentDirectory, callback) ### Description Opens a file chooser dialog for the user to select a file. ### Parameters - **fileExtension** (string) - Required - File extension (e.g., ALL). - **currentDirectory** (string) - Required - Directory to browse. - **callback** (Callback) - Required - Callback function to be performed on API response. ``` -------------------------------- ### createCMSSignatureFromFile Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Creates a CMS signature for a file using a specified key storage. ```APIDOC ## createCMSSignatureFromFile ### Description Creates a CMS signature for a file using a specified key storage. ### Parameters - **storageName** (string) - Storage name (PKCS12, AKKaztokenStore, AKKZIDCardStore, AKEToken72KStore, AKJaCartaStore) - **storagePath** (string) - Path to key container - **keyAlias** (string) - Key alias extracted from key - **password** (string) - Key container password - **filePath** (string) - File path of content to be signed - **attached** (boolean) - Attach data into signature or not - **callback** (Callback) - Callback function to be performed on API response ``` -------------------------------- ### getKeys Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Retrieves keys from a specified key container. ```APIDOC ## getKeys(storageName, storagePath, password, type, callback) ### Description Retrieves keys from a specified key container using the provided password and key type. ### Parameters - **storageName** (string) - Required - Storage name. - **storagePath** (string) - Required - Path to key container. - **password** (string) - Required - Key container password. - **type** (string) - Required - Key type (AUTH, SIGN, ALL). - **callback** (Callback) - Required - Callback function to be performed on API response. ``` -------------------------------- ### createCMSSignature Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Creates a CMS signature for the provided plain data using a specified key storage. ```APIDOC ## createCMSSignature ### Description Creates a CMS signature for the provided plain data using a specified key storage. ### Parameters - **storageName** (string) - Required - Storage name. Available values: PKCS12, AKKaztokenStore, AKKZIDCardStore, AKEToken72KStore, AKJaCartaStore - **storagePath** (string) - Required - Path to key container. - **keyAlias** (string) - Required - Key alias extracted from key. - **password** (string) - Required - Key container password - **toSign** (string) - Required - Plain data to be signed - **attached** (boolean) - Required - Attach data into signature or not - **callback** (Callback) - Required - Callback function to be performed on API response ``` -------------------------------- ### verifyPlainData Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Verifies a signature against original plain data using a specified key storage. ```APIDOC ## verifyPlainData ### Description Verifies a signature against original plain data using a specified key storage. ### Parameters - **storageName** (string) - Required - Storage name. Available values: PKCS12, AKKaztokenStore, AKKZIDCardStore, AKEToken72KStore, AKJaCartaStore - **storagePath** (string) - Required - Path to key container. - **keyAlias** (string) - Required - Key alias extracted from key. - **password** (string) - Required - Key container password - **toVerify** (string) - Required - Original plain data - **signature** (string) - Required - Signature to be validated - **callback** (Callback) - Required - Callback function to be performed on API response ``` -------------------------------- ### signXml Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Signs raw XML content using a specified key storage. ```APIDOC ## signXml ### Description Signs raw XML content using a specified key storage. ### Parameters - **storageName** (string) - Storage name (PKCS12, AKKaztokenStore, AKKZIDCardStore, AKEToken72KStore, AKJaCartaStore) - **storagePath** (string) - Path to key container - **keyAlias** (string) - Key alias extracted from key - **password** (string) - Key container password - **toSign** (string) - Raw xml to be signed - **callback** (Callback) - Callback function to be performed on API response ``` -------------------------------- ### getHash Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Generates a hash for the provided input data using a specified digest algorithm. ```APIDOC ## getHash ### Description Generates a hash for the provided input data using a specified digest algorithm. ### Parameters - **input** (string) - Required - Plain data to be hashed. - **digestAlg** (string) - Required - Digest algorithm name (e.g., SHA1, SHA256, GOST34311). - **callback** (Callback) - Required - Callback function to be performed on API response. ``` -------------------------------- ### signPlainData Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Signs plain data using the specified key storage. ```APIDOC ## signPlainData ### Description Signs the provided plain data string using the specified key storage and credentials. ### Parameters - **storageName** (string) - Required - Storage name - **storagePath** (string) - Required - Path to key container - **keyAlias** (string) - Required - Key alias - **password** (string) - Required - Key container password - **toSign** (string) - Required - Plain data to be signed - **callback** (Callback) - Required - Callback function to be performed on API response ``` -------------------------------- ### verifyXml Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Validates a raw signed XML string. ```APIDOC ## verifyXml ### Description Validates a raw signed XML string. ### Parameters - **signature** (string) - Raw signed xml to be validated - **callback** (Callback) - Callback function to be performed on API response ``` -------------------------------- ### setLocale Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Sets the language for the NCALayer interface. ```APIDOC ## setLocale(lang, callback) ### Description Sets the language for the NCALayer interface. Supported values are 'kk', 'ru', and 'en'. ### Parameters - **lang** (string) - Required - Language code. - **callback** (Callback) - Required - Callback function to be performed on API response. ``` -------------------------------- ### getNotBefore Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Retrieves the 'not before' validity date of a certificate from a specified key storage. ```APIDOC ## getNotBefore(storageName, storagePath, keyAlias, password, callback) ### Description Retrieves the start date of the certificate's validity period. ### Parameters - **storageName** (string) - Required - Storage name (e.g., PKCS12, AKKaztokenStore, AKKZIDCardStore, AKEToken72KStore, AKJaCartaStore) - **storagePath** (string) - Required - Path to key container - **keyAlias** (string) - Required - Key alias extracted from key - **password** (string) - Required - Key container password - **callback** (Callback) - Required - Callback function to be performed on API response ``` -------------------------------- ### verifyCMSSignatureFromFile Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Validates a CMS signature for a given file. ```APIDOC ## verifyCMSSignatureFromFile ### Description Validates a CMS signature for a given file. ### Parameters - **filePath** (string) - Original file content - **signature** (string) - Signature to be validated - **callback** (Callback) - Callback function to be performed on API response ``` -------------------------------- ### verifyCMSSignature Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Verifies a CMS signature against the original plain data. ```APIDOC ## verifyCMSSignature ### Description Verifies a CMS signature against the original plain data. ### Parameters - **toVerify** (string) - Required - Original plain data - **signature** (string) - Required - Signature to be validated - **callback** (Callback) - Required - Callback function to be performed on API response ``` -------------------------------- ### getNotAfter Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Retrieves the 'not after' validity date of a certificate from a specified key storage. ```APIDOC ## getNotAfter(storageName, storagePath, keyAlias, password, callback) ### Description Retrieves the expiration date of the certificate's validity period. ### Parameters - **storageName** (string) - Required - Storage name (e.g., PKCS12, AKKaztokenStore, AKKZIDCardStore, AKEToken72KStore, AKJaCartaStore) - **storagePath** (string) - Required - Path to key container - **keyAlias** (string) - Required - Key alias extracted from key - **password** (string) - Required - Key container password - **callback** (Callback) - Required - Callback function to be performed on API response ``` -------------------------------- ### Response Object Methods Source: https://seithq.gitbook.io/ncalayerjs/reference/response.md Methods available on the Response object to retrieve data or validate the status of the operation. ```APIDOC ## Response Object Methods ### getResult() Returns the result field as a string. ### getResultObject() Returns the result field as an any type. ### getSecondResult() Returns the second result field as a string. ### getErrorCode() Returns the error code field as a string. ### isOk() Returns true if the error code is 'NONE'. ### isPasswordAttemptsError() Returns true if the error code is 'WRONG_PASSWORD' and the result contains attempts. ### isPasswordError() Returns true if the error code is 'WRONG_PASSWORD'. ### isKeyTypeError() Returns true if the error code is 'EMPTY_KEY_LIST'. ### isRdnNotFoundError() Returns true if the error code is 'RDN_NOT_FOUND'. ### isXmlParseError() Returns true if the error code is 'XML_PARSE_EXCEPTION'. ### isSignatureValidationError() Returns true if the error code is 'SIGNATURE_VALIDATION_ERROR'. ### isCommonError() Returns true if the error code is 'COMMON'. ### isKeyStoreError() Returns true if the error code is 'LOAD_KEYSTORE_ERROR'. ### isUnknownStorageError() Returns true if the error code is 'UNKNOWN_STORAGE'. ### isFileReadError() Returns true if the error code is 'FILE_READ_ERROR'. ``` -------------------------------- ### getIssuerDN Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Retrieves the issuer distinguished name from a specified key storage. ```APIDOC ## getIssuerDN ### Description Retrieves the issuer distinguished name (DN) from the provided key storage container. ### Parameters - **storageName** (string) - Required - Storage name (e.g., PKCS12, AKKaztokenStore, AKKZIDCardStore, AKEToken72KStore, AKJaCartaStore) - **storagePath** (string) - Required - Path to key container - **keyAlias** (string) - Required - Key alias extracted from key - **password** (string) - Required - Key container password - **callback** (Callback) - Required - Callback function to be performed on API response ``` -------------------------------- ### signXmlByElementId Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Signs a specific XML element within a raw XML string using a specified key storage. ```APIDOC ## signXmlByElementId ### Description Signs a specific XML element within a raw XML string using a specified key storage. ### Parameters - **storageName** (string) - Required - Storage name (e.g., PKCS12, AKKaztokenStore). - **storagePath** (string) - Required - Path to key container. - **keyAlias** (string) - Required - Key alias extracted from key. - **password** (string) - Required - Key container password. - **toSign** (string) - Required - Raw xml. - **elementName** (string) - Required - Element name to be signed. - **idAttrName** (string) - Required - Element attribute. - **parentElementName** (string) - Required - Element parent node. - **callback** (Callback) - Required - Callback function to be performed on API response. ``` -------------------------------- ### getSubjectDN Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Retrieves the Subject Distinguished Name (DN) of a certificate from a specified key storage. ```APIDOC ## getSubjectDN(storageName, storagePath, keyAlias, password, callback) ### Description Retrieves the subject distinguished name associated with the certificate. ### Parameters - **storageName** (string) - Required - Storage name (e.g., PKCS12, AKKaztokenStore, AKKZIDCardStore, AKEToken72KStore, AKJaCartaStore) - **storagePath** (string) - Required - Path to key container - **keyAlias** (string) - Required - Key alias extracted from key - **password** (string) - Required - Key container password - **callback** (Callback) - Required - Callback function to be performed on API response ``` -------------------------------- ### Callback Type Alias Source: https://seithq.gitbook.io/ncalayerjs/reference/callback.md The Callback type is an alias for a function that accepts a Response object and returns nothing. ```APIDOC ## Callback ### Description Defines the signature for a callback function used to process responses from the NCALayer. ### Signature `(resp: Response) => void` ``` -------------------------------- ### verifyXmlByElementId Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Validates a raw signed XML string based on element attributes. ```APIDOC ## verifyXmlByElementId ### Description Validates a raw signed XML string based on element attributes. ### Parameters - **signature** (string) - Required - Raw signed xml to be validated. - **idAttrName** (string) - Required - Element attribute. - **parentElementName** (string) - Required - Element parent node. - **callback** (Callback) - Required - Callback function to be performed on API response. ``` -------------------------------- ### getRdnByOid Source: https://seithq.gitbook.io/ncalayerjs/reference/client.md Retrieves the RDN value for a specific OID from the key storage. ```APIDOC ## getRdnByOid ### Description Retrieves the RDN (Relative Distinguished Name) associated with a specific OID code from the key storage. ### Parameters - **storageName** (string) - Required - Storage name - **storagePath** (string) - Required - Path to key container - **keyAlias** (string) - Required - Key alias - **password** (string) - Required - Key container password - **oid** (string) - Required - OID code - **oidIndex** (number) - Required - OID index (use 0) - **callback** (Callback) - Required - Callback function to be performed on API response ```