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 | 6x 1x 5x 1x 4x 4x 4x 1x 3x 2x 2x 2x 1x | /**
* @file MFKDF Passkey Factor Setup
* @copyright Multifactor, Inc. 2022–2025
*
* @description
* Setup passkey factor for multi-factor key derivation
*
* @author Vivek Nair (https://nair.me) <vivek@nair.me>
*/
/**
* Setup an MFKDF passkey factor
*
* @example
* const prf = await crypto.randomBytes(32)
*
* const setup = await mfkdf.setup.key([
* await mfkdf.setup.factors.passkey(prf)
* ])
*
* const derive = await mfkdf.derive.key(setup.policy, {
* passkey: mfkdf.derive.factors.passkey(prf)
* })
*
* derive.key.toString('hex').should.equal(setup.key.toString('hex'))
*
* @param {Buffer} secret - The 256-bit PRF secret from which to derive an MFKDF factor
* @param {Object} [options] - Configuration options
* @param {string} [options.id='passkey'] - Unique identifier for this factor
* @returns {MFKDFFactor} MFKDF factor information
* @author Vivek Nair (https://nair.me) <vivek@nair.me>
* @since 2.0.0
* @async
* @memberof setup.factors
*/
async function passkey (secret, options) {
if (!Buffer.isBuffer(secret)) {
throw new TypeError('secret must be a Buffer')
}
if (Buffer.byteLength(secret) !== 32) {
throw new RangeError('secret must be 32 bytes (256 bits) in length')
}
options = Object.assign({}, options)
if (options.id === undefined) options.id = 'passkey'
if (typeof options.id !== 'string') {
throw new TypeError('id must be a string')
}
if (options.id.length === 0) throw new RangeError('id cannot be empty')
return {
type: 'passkey',
id: options.id,
entropy: 256,
data: secret,
params: async () => {
return {}
},
output: async () => {
return {}
}
}
}
module.exports.passkey = passkey
|