• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tsmx / mongoose-encrypted-string / 14890491554

07 May 2025 06:21PM UTC coverage: 100.0%. Remained the same
14890491554

push

github

tsmx
Dependencies updated

10 of 10 relevant lines covered (100.0%)

19.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/mongoose-encrypted-string.js
1
const SchemaType = require('mongoose').SchemaType;
4✔
2
const sc = require('@tsmx/string-crypto');
4✔
3

4
class EncryptedString extends SchemaType {
5
    constructor(key, options) {
6
        options.get = (v) => { return sc.decrypt(v, { key: EncryptedString.options.key, passNull: true }); };
40✔
7
        options.set = (v) => { return sc.encrypt(v, { key: EncryptedString.options.key, passNull: true }); };
52✔
8
        super(key, options, 'EncryptedString');
8✔
9
    }
10

11
    cast(val) {
12
        return String(val);
68✔
13
    }
14

15
    static options = {
4✔
16
        key: null
17
    };
18

19
}
20

21
module.exports.registerEncryptedString = function (mongoose, key) {
4✔
22
    EncryptedString.options.key = key;
4✔
23
    mongoose.Schema.Types.EncryptedString = EncryptedString;
4✔
24
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc