summaryrefslogtreecommitdiff
path: root/src/routers/vault/types/Identity.js
blob: 2a836b2af57a25ba931cef0cd445d33b4daf8bd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"use strict";

const { Sequelize, Model } = require("sequelize");

class Identity extends Model {
    /**
     * primary key
     * @type {number}
     */
    //id;
    /**
     * the Date when the Identity was confirmed
     * @type {Date}
     */
    //addedDate;
    /**
     * the email address of the identity
     * @type {string}
     */
    //email;
    /**
     * the Vault user id
     * @type {number}
     */
    //totp;
    /**
     * TOTP 16-chars base64 secret (optional)
     * @type {string}
     */
    //pass;
    /**
     * Optional PBKDF2 cryptographic secret to use with 2FA.
     * @type {string}
     */
    //userId;

    /**
     * whether it is the primary identity of the vault account
     * @virtual
     */
    isPrimary = false;


    /**
     * initialize the model (must be called prior to first use)
     * @param {Sequelize} sequelize - the Sequelize instance
     */
    static define (sequelize) {
        const {fields, options} = require("../models/vault/identity.js");
        Identity.init(fields, { sequelize, ...options });

        return Identity; // the instantiated Model
    }

    /**
     * serialize for sending over the network
     */
    toJSON () {
        return {
            id: this.id,
            email: this.email,
            added: this.addedDate,
            primary: this.isPrimary,
        };
    }
}

module.exports = Identity;