示例#1
0
export const initInviteWithKeys = async ({
  hostIdentityKeys,
  ...attrs
}) => {
  // Generate keys
  const keys = await createECDHKey()
  const code = getInviteCode({
    identityKeys: hostIdentityKeys,
    inviteKeys: keys,
  })
  return Invite({
    keys,
    code,
    ...attrs,
  })
}
示例#2
0
const loadConfigForm = async (configPath) => {
  if (!fs.existsSync(configPath)) {
    // const devPath = path.join(__dirname, '../../../development.config')
    // eslint-disable-next-line global-require, import/no-dynamic-require
    const devConfig = require('../development.config')
    if (devConfig.auth.hostIdentityKeys == null) {
      devConfig.auth.hostIdentityKeys = await createECDHKey()
    }
    writeFileAtomic.sync(configPath, JSON.stringify(devConfig, null, 2))
  }
  try {
    // eslint-disable-next-line global-require, import/no-dynamic-require
    return JSON.parse(fs.readFileSync(configPath))
  } catch (e) {
    throw new Error(`Unable to load config file ${configPath}\n${e.message}`, e)
  }
}