+ return info.age_limit && info.age_limit >= 16
+}
+
+function normalizeTargetUrl (url: string) {
+ let normalizedUrl = url.replace(/\/+$/, '')
+
+ if (!normalizedUrl.startsWith('http://') && !normalizedUrl.startsWith('https://')) {
+ normalizedUrl = 'https://' + normalizedUrl
+ }
+
+ return normalizedUrl
+}
+
+async function promptPassword () {
+ return new Promise<string>((res, rej) => {
+ prompt.start()
+ const schema = {
+ properties: {
+ password: {
+ hidden: true,
+ required: true
+ }
+ }
+ }
+ prompt.get(schema, function (err, result) {
+ if (err) {
+ return rej(err)
+ }
+ return res(result.password)
+ })
+ })
+}
+
+async function getAccessTokenOrDie (url: string, user: UserInfo) {
+ const resClient = await getClient(url)
+ const client = {
+ id: resClient.body.client_id,
+ secret: resClient.body.client_secret
+ }