async function register (args) { let expiresIn if (args[0] === '--expiresIn') { expiresIn = args[1] args = args.slice(2) } const [ url, email, password = await new Promise(function (resolve) { process.stdout.write('Password: '******'Successfully logged with', xo.user.email) await config.set({ server: url, token: await xo.call('token.create', { expiresIn }), }) }
async function connect () { const { server, token } = await config.load() if (server === undefined) { throw new Error('no server to connect to!') } if (token === undefined) { throw new Error('no token available') } const xo = new Xo({ url: server }) await xo.open() await xo.signIn({ token }) return xo }