Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show device domains if multiple are found #2874

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/frontend/src/flows/manage/authenticatorsSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,16 @@ export const authenticatorsSection = ({
};

export const authenticatorItem = ({
authenticator: { alias, last_usage, dupCount, warn, info, remove, rename },
authenticator: {
alias,
last_usage,
dupCount,
warn,
info,
remove,
rename,
rpId,
},
index,
icon,
}: {
Expand Down Expand Up @@ -160,6 +169,9 @@ export const authenticatorItem = ({
settings,
})}
</div>
${nonNullish(rpId)
? html`<div class="t-discreet">${rpId}</div>`
: undefined}
<div>
${nonNullish(lastUsageFormattedString)
? html`<div class="t-muted">
Expand Down
14 changes: 12 additions & 2 deletions src/frontend/src/flows/manage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ export const devicesFromDevicesWithUsage = ({

const authenticator = {
alias: device.alias,
rpId: domainLabel(device, devices_),
last_usage: device.last_usage,
warn: domainWarning(device),
info: domainInfo(device, devices_),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want the domainInfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll move this tooltip (explanation part of the tooltip) to this domain line itself instead.

Expand Down Expand Up @@ -721,6 +722,16 @@ const domainInfo = (
device: DeviceData,
allDevices: DeviceData[]
): TemplateResult | undefined => {
const label = domainLabel(device, allDevices);
if (nonNullish(label)) {
return html`This passkey was registered in ${label}`;
}
};

const domainLabel = (
device: DeviceData,
allDevices: DeviceData[]
): string | undefined => {
if (!DOMAIN_COMPATIBILITY.isEnabled()) {
return undefined;
}
Expand All @@ -730,8 +741,7 @@ const domainInfo = (
if (nonNullish(commonOrigin)) {
return undefined;
}
return html`This passkey was registered in
${device.origin[0] ?? LEGACY_II_URL}`;
return new URL(device.origin[0] ?? LEGACY_II_URL).hostname;
};

const unknownError = (): Error => {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/flows/manage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TemplateResult } from "lit-html";
export type Authenticator = {
alias: string;
last_usage: [] | [bigint];
rpId?: string;
rename: () => void;
remove?: () => void;
// `warn` is used to show a warning icon when the device was registered in a different oring than current one.
Expand Down
Loading