# Extraits de code

# generateUserLicenseToken

const generateUserLicenseToken = async (userId, teamId, domainValidationKey, domainValidationKeyId) => {
  const nonce = await randomString(64)
  const token = (await scrypt(
    Buffer.from(`${userId}@${teamId}-${domainValidationKey}`, 'utf8'),
    Buffer.from(nonce, 'utf8')
  )).toString('hex')
  return `${domainValidationKeyId}:${nonce}:${token}`
}

# scrypt

Arguments:

  • N: 16384
  • r: 8
  • p: 1
  • taille de sortie: 64 octets
import { scrypt as scryptNode } from 'crypto'
import { promisify } from 'util'

const scrypt = (buff, salt) => {
    return promisify(scryptNode)(
      buff,
      salt,
      64,
      { N: 16384, r: 8, p: 1 }
    )
}