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

Clean up and clarify authz landing #1570

Merged
merged 2 commits into from
May 8, 2023
Merged
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
Binary file modified screenshots/desktop/authorizeNew.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/desktop/authorizeNewAlt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/desktop/authorizePick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/desktop/authorizePickAlt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/desktop/authorizePickAltOpen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/desktop/authorizePickMany.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/desktop/authorizeUseExisting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/mobile/authorizeNew.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/mobile/authorizeNewAlt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/mobile/authorizePick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/mobile/authorizePickAlt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/mobile/authorizePickAltOpen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/mobile/authorizePickMany.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/mobile/authorizeUseExisting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/frontend/src/flows/authorize/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
"auth_failed": "Something went wrong during authentication. Authenticating service was notified and you may close this page.",
"auth_success": "Authentication successful. You may close this page.",

"create_to_continue_to": "Create an Internet Identity to connect to",
"to_continue_to": "to connect to",
"is_alternative_of": "is an alternative domain of",
"auth_same_identity": "and you will be authenticated to both with the same identity.",

"first_time_create": "Securely connect to dapps on the Internet Computer",
"first_time_create": "Securely connect with Internet Identity",
Copy link
Member

Choose a reason for hiding this comment

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

asked my self if it should be phrased "Securely connect with an Internet Identity" so just sharing, just in case

Choose a reason for hiding this comment

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

Hm, I think it depends whether the product is also still called Internet Identity...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Product did consider it, then went for the current wording

"first_time_use": "Use existing",
"first_time_create_text": "Create Internet Identity",

Expand Down
65 changes: 28 additions & 37 deletions src/frontend/src/flows/authorize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import {
import { displayError } from "$src/components/displayError";
import { caretDownIcon, spinner } from "$src/components/icons";
import { showMessage } from "$src/components/message";
import { DappDescription, getDapps } from "$src/flows/dappsExplorer/dapps";
import { dappsHeader } from "$src/flows/dappsExplorer/teaser";
import { recoveryWizard } from "$src/flows/recovery/recoveryWizard";
import { DynamicKey, I18n } from "$src/i18n";
import { Connection } from "$src/utils/iiConnection";
import { TemplateElement } from "$src/utils/lit-html";
import { Chan, shuffleArray, unreachable } from "$src/utils/utils";
import { Chan, unreachable } from "$src/utils/utils";
import { html, render, TemplateResult } from "lit-html";
import { asyncReplace } from "lit-html/directives/async-replace.js";
import { authenticationProtocol } from "./postMessageInterface";
Expand All @@ -21,52 +19,45 @@ import copyJson from "./index.json";

/* Template for the authbox when authenticating to a dapp */
export const authnTemplateAuthorize = ({
origin,
origin: origin_,
derivationOrigin,
dapps,
i18n,
}: {
origin: string;
derivationOrigin?: string;
dapps: DappDescription[];
i18n: I18n;
}): AuthnTemplates => {
const copy = i18n.i18n(copyJson);
const chasm =
nonNullish(derivationOrigin) && derivationOrigin !== origin
const origin = html` <strong class="t-strong">${origin_}</strong>`;
const originInfo =
nonNullish(derivationOrigin) && derivationOrigin !== origin_
? mkChasm({
info: "shared identity",
info: origin,
message: html`<span class="t-strong">${origin}</span>
${copy.is_alternative_of} <br /><span class="t-strong"
>${derivationOrigin}</span
><br />${copy.auth_same_identity}`,
})
: undefined;
: origin;

const wrap = ({
showDapps = false,
firstTime = false,
title,
}: {
showDapps?: boolean;
firstTime?: boolean;
title: DynamicKey;
}) => html`
${showDapps ? dappsHeader({ dapps, clickable: false }) : undefined}
<div class="l-stack">
<h1 class="t-title t-title--main" style="text-align: left;">${title}</h1>
<p class="t-lead l-stack">
${copy.to_continue_to}
<div class="l-stack l-stack--tight">
<strong class="t-strong"
>${origin}</strong
>
</div>
${firstTime ? copy.create_to_continue_to : copy.to_continue_to}
</p>
${chasm}
${originInfo}
</div>
`;
return {
firstTime: {
slot: wrap({ showDapps: true, title: copy.first_time_create }),
slot: wrap({ firstTime: true, title: copy.first_time_create }),
useExistingText: copy.first_time_use,
createAnchorText: copy.first_time_create_text,
},
Expand Down Expand Up @@ -111,14 +102,12 @@ export const authFlowAuthorize = async (
);
const result = await authenticationProtocol({
authenticate: async (authContext) => {
const dapps = shuffleArray(await getDapps());
const authSuccess = await authenticateBox(
connection,
i18n,
authnTemplateAuthorize({
origin: authContext.requestOrigin,
derivationOrigin: authContext.authRequest.derivationOrigin,
dapps,
i18n,
})
);
Expand Down Expand Up @@ -185,7 +174,7 @@ export const authFlowAuthorize = async (

/** Options to display a "chasm" in the authbox */
type ChasmOpts = {
info: string;
info: TemplateElement;
message: TemplateResult;
};

Expand All @@ -198,18 +187,20 @@ const mkChasm = ({ info, message }: ChasmOpts): TemplateResult => {
);

return html`
<p class="t-centered t-paragraph t-weak"><span id="alternative-origin-chasm-toggle" class="t-action" @click=${() =>
chasmToggle()}>${info} <span class="t-link__icon c-chasm__button ${asyncReplace(
btnFlipped
)}">${caretDownIcon}</span></span>
<div class="c-chasm" aria-expanded=${asyncReplace(ariaExpanded)}>
<div class="c-chasm__inner">
<div class="c-chasm__arrow"></div>
<div class="t-weak c-chasm__content">
${message}
</div>
</div>
<span
id="alternative-origin-chasm-toggle"
class="t-action"
@click=${() => chasmToggle()}
>${info}
<span class="t-link__icon c-chasm__button ${asyncReplace(btnFlipped)}"
>${caretDownIcon}</span
></span
>
<div class="c-chasm" aria-expanded=${asyncReplace(ariaExpanded)}>
<div class="c-chasm__inner">
<div class="c-chasm__arrow"></div>
<div class="t-weak c-chasm__content">${message}</div>
</div>
</p>
`;
</div>
`;
};
2 changes: 1 addition & 1 deletion src/frontend/src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,7 @@ a:hover,
}

.c-chasm__arrow {
margin: auto;
margin-left: calc(1.25 * var(--rs-card-bezel));
Copy link
Member

Choose a reason for hiding this comment

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

side note:

@meodai 1.25 * var(--rs-card-bezel) comes few times in the CSS file, four exactly, should a variable be extracted?

width: 0;
height: 0;
background: var(--rc-input);
Expand Down
4 changes: 2 additions & 2 deletions src/showcase/src/showcase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,11 @@ const dapps = await getDapps();

const authzTemplates = authnTemplateAuthorize({
origin: "https://nowhere.com",
dapps,
i18n,
});
const authzTemplatesAlt = authnTemplateAuthorize({
origin: "https://nowhere.com",
derivationOrigin: "http://fgte5-ciaaa-aaaad-aaatq-cai.ic0.app",
dapps,
i18n,
});

Expand Down Expand Up @@ -155,6 +153,8 @@ const iiPages: Record<string, () => void> = {

authorizeNew: () =>
authz.firstTime({ useExisting: () => console.log("Use existing") }),
authorizeNewAlt: () =>
authzAlt.firstTime({ useExisting: () => console.log("Use existing") }),
authorizeUseExisting: () => authz.useExisting(),
authorizePick: () =>
authz.pick({
Expand Down