@neurosell/securedts
v1.0.0
Published
A lightweight dependency-free library for secured types and local storage items. Compare field values and storage data using device fingerprinting
Maintainers
Readme
SecuredTS

SecuredTS - A lightweight pure typescript and dependency-free library for protecting local storage, class fields, and cryptography in your client-side web applications. The library also includes a simple method for collecting the user's device fingerprint to generate secure storage keys.
Get Started | Other Libraries | Telegram | Contacts
❓ Why SecuredTS? 🔹 Lightweight Library with zero dependencies; 🔹 Powerful secured fields with AES-encryption written in Typescript; 🔹 Simple encrypted local storage; 🔹 Device fingerprint based; 🔹 Cross-platform Support;
Table of Contents
- Installation
- Use Cases
- Secured Storage (Encrypted Local Storage)
- Secured Fields
- Device Fingerprint
- Crypto Classes
Installation
The process of installing the NS Storage library for your web applications is quite simple.
Just import from npm:
npm install @neurosell/securedtsOr from CDN:
<script src="https://cdn.jsdelivr.net/npm/@neurosell/[email protected]/browser/securedts.global.js"></script>
<script type="text/javascript">
// Will be connected as Global
const { NStorage } = window.SecuredTS;
</script>Or from GitHub (for developers):
git clone https://github.com/Neurosell/SecuredTSUse Cases
You can use SecuredTS library in case of:
- Secure your local storage data with device fingerprint key;
- Store Secured (Encrypted) Fields into any objects;
- Get Device fingerprinting;
- Work with objects and text using different AES encryption;
Secured Storage Usage
The NS Storage Library may be used instead basic local storage with encrypted by device fingerprint keys and values. Use this to protect your local storage objects.
Usage Example:
// Create a storage instance
const exampleStorage = new NStorage();
// Save Item
exampleStorage.SetItem("exampleKey", "exampleValue"); // Will be saved in storage as "95ef95887680ac20b53f":"d2f28c846b9ca50e8627ddcc890f"
// Read Item
exampleStorage.GetItem("exampleKey"); // Returns Decrypted "exampleValue"Secured Fields
The NS Storage Library has own Secured Fields implementation for any your objects. You can store secured values to protect memory hacking (for example with CheatEngine). This field is not store un-encrypted values.
Example Class with Secured Fields:
class MyClass {
construtor(){
this.unencryptedField = "My Unencrypted Field"; // Raw value can be found and changed in memory
this.securedField = new SecuredField("My Secured Field"); // Raw value can't be found and changed in memory
}
}Now you can use your Secured Fields:
// Create our Object Instance
const myObj = new MyClass();
// Get RAW Value
const rawValue = myObj.securedField.Value;
// Update Value (will be stored in memory with encryption)
myObj.securedField.Value = "new value to be encrypted";Device Fingerprint Class
The NS Storage Library has own simple Device Fingerprint Class Implementation. Use this class to collect device information, UUID and device fingerprint by one line of code.
Example Usage:
// Get Device Data, Fingerprint and UUID
const fingerprintData = NDeviceFingerprint.GetDeviceFingerprint();
console.log(fingerprintData.Data, fingerprintData.Key, fingerprintData.UUID);Collected Information:
- User Agent;
- Browser Information (Name and Version);
- OS Information (Name and Version);
- Sceen Information (Resolution and Color Depth);
- Mobile Detection;
- Cookie Support Detection;
- HTML5 Features Detection;
- Language;
- Timezone Data;
- Device Memory;
- Do Not Track Flag;
- Browser Mime Types and Plugins List;
- WebGL Features List;
- Canvas Fingerprint;
Crypto Classes
The NS Storage Library has own AES-Based Crypto Classes Implementation. You can use any of these classes for your projects or NEncryptor helper class.
Example Usage (with Encryptor):
// Create Encryptor Object
const myEncryptor = new NEncryptor("My Encryption Key", { Mode: NEncryptor.Mode.CTR });
// Get Encrypted HEX
const encryptedHEX = myEncryptor.Encrypt("My Decrypted Text");
// Get Decrypted Text
const decryptedText = myEncryptor.Decrypt(encryptedHEX);Example Usage:
// Prepare AES Encryption Key
const key = "myencryptionkey";
const hashedKey = new NCryptoMD5(key).GetHEX();
const bytes = new Array(16);
for (var i = 0; i < hashedKey.length;) {
var hexByte = hashedKey[i++] + hashedKey[i++];
var byte = parseInt(hexByte, 16);
bytes[i / 2 - 1] = byte;
}
// Create Your Encryptor with converted to bytes array Encryption Key
const encryptor = new NCryptoCTR(bytes, new NCryptoCounter(1));
// Encrypt Some Text
const decryptedText = "My Decrypted Text"; // Here your Decrypted Text
const decryptedBytes = encryptor._textToBytes(decryptedText); // Convert to Decrypted Bytes Array
const encryptedBytes = encryptor.Encrypt(decryptedBytes); // Encrypt your Decrypted Bytes Array
const encryptedHEX = encryptor._bytesToHex(encryptedBytes); // Convert Encrypted Bytes Array to HEX String
// Decrypt Some Text
const encryptedBytes = encryptor._hexToBytes(encryptedHEX); // Convert Encrypted HEX String to Encrypted Bytes Array
const decryptedBytes = encryptor.Decrypt(encryptedBytes); // Decrypt Bytes Array
console.log(encryptor._bytesToText(decryptedBytes)); // Convert Decrypted Bytes to TextList of Available Classes:
- NEncryptor - Multi-Method Encryption Helper;
- NCrypto - Base class with Utils Methods;
- NCryptoAES - Basic AES Implementation;
- NCryptoECB - AES in ECB Mode Implementation;
- NCryptoCBC - AES in CBC Mode Implementation;
- NCryptoCFB - AES in CFB Mode Implementation;
- NCryptoOFB - AES in OFB Mode Implementation;
- NCryptoCTR (Recommended) - AES in CTR Mode Implementation;
- NCryptoCounter - Util class for AES Counter;
- NCryptoMD5 - MD5 Hash Implementation;
Encryption Classes Methods:
- Name - Returns {string} Encryption Method Name;
- Encrypt - Returns {bytes} Encrypted UTF8 Bytes Array;
- Decrypt - Returns {bytes} Decrypted UTF8 Bytes Array;
