diff --git a/src/models/License.ts b/src/models/License.ts index b876c0a..2212b95 100644 --- a/src/models/License.ts +++ b/src/models/License.ts @@ -1,5 +1,6 @@ import {model, ObjectId, Schema, Types} from "mongoose"; -import encrypt from "mongoose-encryption"; +import { fieldEncryption } from "mongoose-field-encryption"; +import process from "process"; export enum ILicenseMetaType { STRING @@ -12,7 +13,7 @@ export interface ILicenseMeta { } export interface ILicense { - id: ObjectId, + _id: ObjectId, projectId: ObjectId, key: string, groups?: string[], @@ -39,9 +40,10 @@ const LicenseSchema = new Schema({ } }); -LicenseSchema.plugin(encrypt, { - encryptionKey: process.env.ENC_KEY, - signingKey: process.env.SIG_KEY +LicenseSchema.plugin(fieldEncryption, { + fields: ["projectId", "key", "groups", "permissions", "meta", "expirationDate"], + secret: process.env.ENC_KEY, + saltGenerator: () => process.env.SIG_KEY }); export const License = model("licenses", LicenseSchema); \ No newline at end of file