lightcrypto-link-node provides 100% type serialization compatibility with the Java LightCrypto-Link ecosystem.
| Java Type | _t Marker |
Node.js Type | Serialization |
|---|---|---|---|
| String | STR | String | UTF-8 |
| Integer | INT | Number | toString() |
| Long | LONG | mongoose-long | toString() |
| Short | SHORT | Number | toString() |
| Byte | BYTE | Number | toString() |
| Float | FLOAT | Number | toString() |
| Double | DOUBLE | Number | toString() |
| BigDecimal | DEC | Decimal128 | toPlainString() |
| Boolean | BOOL | Boolean | "true"/"false" |
| LocalDate | LDATE | Date | YYYY-MM-DD |
| LocalDateTime | LDT | Date | YYYY-MM-DDTHH:mm:ss |
| byte[] | BYTES | Buffer | Base64 (RFC 4648) |
| Enum | ENUM | String | Enum name |
| Document / POJO | DOC | Object | BSON binary (serialize()) |
| Collection / List | COL | Array | BSON binary (serialize({ _v: [...] })) |
| Map / Dictionary | MAP | Object | BSON binary (serialize()) |
- All numeric types are serialized via
toString()to match Java'sString.valueOf() - Deserialization parses back to JavaScript
Number - Precision warning is logged for values exceeding
Number.MAX_SAFE_INTEGER
- Requires optional
mongoose-longpackage for full precision - Without
mongoose-long, values exceeding2^53 - 1will lose precision with a warning
- LocalDate: Serialized as
YYYY-MM-DD(UTC midnight), deserialized toDate - LocalDateTime: Serialized as
YYYY-MM-DDTHH:mm:ss(milliseconds truncated), deserialized toDate
byte[]is Base64-encoded (RFC 4648, no line breaks)- Deserialized to Node.js
Buffer(no string conversion)
- Serialized as the enum name (String)
- Deserialized as String (no Java class reconstruction in Node.js)
Structured types use BSON binary serialization instead of string serialization. The entire value is serialized as a BSON document, encrypted as a single ciphertext, and stored with the corresponding _t marker.
- DOC (sub-document / POJO): Plain objects are serialized via
BSON.serialize(obj). Used for Mongoose sub-document fields (Schemainstances) and nested object definitions. - COL (collection / array): Arrays are wrapped as
{ _v: [...] }before BSON serialization. On decryption, the_vfield is unwrapped to restore the original array. - MAP (key-value map): Plain objects serialized identically to DOC, but semantically represents a dynamic key-value map rather than a fixed-schema sub-document.
Note: Structured types do not support blind indexes. The
bfield is never generated for DOC/COL/MAP encrypted sub-documents.
Interoperability: BSON binary output matches Java's
DocumentCodec.encode()byte-for-byte, ensuring cross-platform compatibility.
Blind indexes are deterministic — the same input always produces the same HMAC output. This enables exact-match queries on encrypted fields without decryption.
// Blind index is HMAC-SHA-256 → Base64URL (no padding)
// Same field name + same value → same blind index across Java and Node.js