All files / src/classes/MFKDFDerivedKey index.js

100% Statements 26/26
100% Branches 0/0
100% Functions 1/1
100% Lines 26/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                    495x 495x 495x 495x 495x         1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x     1x 1x     1x 1x     1x 1x 1x   1x  
/**
 * @file Multi-Factor Derived Key Class
 * @copyright Multifactor, Inc. 2022–2025
 *
 * @description
 * Class representing a multi-factor derived key
 *
 * @author Vivek Nair (https://nair.me) <[email protected]>
 */
 
/**
 * Class representing a multi-factor derived key
 * @author Vivek Nair (https://nair.me) <[email protected]>
 * @since 0.8.0
 */
class MFKDFDerivedKey {
  /**
   * Create a MFKDFDerivedKey object
   *
   * @param {Object} policy - The policy for deriving this key
   * @param {Buffer} key - The value of this derived key
   * @param {Buffer} secret - The secret (pre-KDF) value of this derived key
   * @param {Array.<Buffer>} shares - The shares corresponding to the factors of this key
   * @param {Array.<Object>} outputs - The outputs corresponding to the factors of this key
   */
  constructor (policy, key, secret, shares, outputs) {
    this.policy = policy
    this.key = key
    this.secret = secret
    this.shares = shares
    this.outputs = outputs
  }
}
 
// Crypto Functions
const crypto = require('./crypto')
MFKDFDerivedKey.prototype.getSubkey = crypto.getSubkey
 
// Reconstitution Functions
const reconstitution = require('./reconstitution')
MFKDFDerivedKey.prototype.setThreshold = reconstitution.setThreshold
MFKDFDerivedKey.prototype.removeFactor = reconstitution.removeFactor
MFKDFDerivedKey.prototype.removeFactors = reconstitution.removeFactors
MFKDFDerivedKey.prototype.addFactor = reconstitution.addFactor
MFKDFDerivedKey.prototype.addFactors = reconstitution.addFactors
MFKDFDerivedKey.prototype.recoverFactor = reconstitution.recoverFactor
MFKDFDerivedKey.prototype.recoverFactors = reconstitution.recoverFactors
MFKDFDerivedKey.prototype.reconstitute = reconstitution.reconstitute
 
// Persistence Functions
const persistence = require('./persistence')
MFKDFDerivedKey.prototype.persistFactor = persistence.persistFactor
 
// Strengthening Functions
const strengthening = require('./strengthening')
MFKDFDerivedKey.prototype.strenthen = strengthening.strenthen
 
// MFDPG Functions
const mfdpg = require('./mfdpg')
MFKDFDerivedKey.prototype.derivePassword = mfdpg.derivePassword
 
// Hint Functions
const hints = require('./hints')
MFKDFDerivedKey.prototype.getHint = hints.getHint
MFKDFDerivedKey.prototype.addHint = hints.addHint
 
module.exports = MFKDFDerivedKey