Skip to content

Commit 14f550f

Browse files
committed
Merge branch 'feat/otp-banner-on-demand' of https://github.com/devframes/devframe into feat/otp-banner-on-demand
2 parents e2ffb0d + 764d21f commit 14f550f

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

‎packages/devframe/src/recipes/interactive-auth.ts‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,29 +86,30 @@ export function createAuthBanner(options: CreateAuthBannerOptions = {}): AuthBan
8686
const title = options.title ?? 'Devframe'
8787
const palette: CreateAuthBannerColorsOptions = {
8888
border: colors.dim,
89-
title: colors.bold,
89+
title: x => colors.gray(colors.bold(x)),
9090
label: colors.dim,
91-
code: colors.bold,
91+
code: f => colors.green(colors.bold(f)),
9292
url: colors.cyan,
9393
...options.colors,
9494
}
9595

9696
return (info) => {
97-
const minutesLeft = Math.max(1, Math.round((info.expireAt - Date.now()) / 60_000))
9897
const rows: [label: string, value: string, color: ColorFn][] = [
9998
['auth code', info.code, palette.code],
10099
['or open', info.url, palette.url],
101-
['expires', `in ${minutesLeft} minute${minutesLeft === 1 ? '' : 's'}`, palette.label],
100+
['expires at', new Date(info.expireAt).toLocaleTimeString(), palette.label],
102101
]
103-
if (info.requester)
104-
rows.push(['for', `${info.requester.ua} (${info.requester.origin})`, palette.label])
102+
if (info.requester) {
103+
rows.push(['ua', info.requester.ua, palette.label])
104+
rows.push(['origin', info.requester.origin, palette.label])
105+
}
105106
const labelWidth = Math.max(...rows.map(([label]) => label.length))
106107
const contentWidth = Math.max(...rows.map(([, value]) => labelWidth + 2 + value.length))
107-
const titleBarLength = title.length + 3
108+
const titleBarLength = title.length + 2
108109
const lineWidth = Math.max(contentWidth, titleBarLength - 2)
109110

110111
const top = [
111-
palette.border(`╭─`),
112+
palette.border(`╭`),
112113
palette.title(title),
113114
palette.border(`${'─'.repeat(Math.max(lineWidth + 2 - titleBarLength, 0))}╮`),
114115
].join(' ')

0 commit comments

Comments
 (0)