Skip to content

Commit

Permalink
Merge branch 'main' into bot-release-readme-update
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuntaner authored Jan 7, 2025
2 parents 6dbe877 + 0d59af9 commit 0fc64b6
Show file tree
Hide file tree
Showing 41 changed files with 2,010 additions and 385 deletions.
3 changes: 3 additions & 0 deletions .github/repo_policies/BOT_APPROVED_FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# List of approved files that can be changed by a bot via an automated PR
# This is to increase security and prevent accidentally updating files that shouldn't be changed by a bot
src/frontend/src/flows/dappsExplorer/dapps.json
562 changes: 245 additions & 317 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"private": true,
"license": "SEE LICENSE IN LICENSE.md",
"scripts": {
"dev": "II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=1 vite",
"host": "II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=1 vite --host",
"dev": "II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=1 II_OPENID_GOOGLE_CLIENT_ID=45431994619-cbbfgtn7o0pp0dpfcg2l66bc4rcg7qbu.apps.googleusercontent.com vite",
"host": "II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=1 II_OPENID_GOOGLE_CLIENT_ID=45431994619-cbbfgtn7o0pp0dpfcg2l66bc4rcg7qbu.apps.googleusercontent.com vite --host",
"showcase": "astro dev --root ./src/showcase",
"build": "tsc --noEmit && vite build",
"check": "tsc --project ./tsconfig.all.json --noEmit",
Expand Down Expand Up @@ -43,7 +43,7 @@
"@typescript-eslint/parser": "6.7.5",
"@vitejs/plugin-basic-ssl": "^1.1.0",
"@wdio/globals": "^8.39.0",
"astro": "4.16.1",
"astro": "4.16.18",
"eslint": "8.51.0",
"fake-indexeddb": "^4.0.2",
"lit-analyzer": "^2.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/canister_tests/src/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ xr-spatial-tracking=()",
let rgx = Regex::new(
"^default-src 'none';\
connect-src 'self' https:;\
img-src 'self' data:;\
img-src 'self' data: https://\\*.googleusercontent.com;\
script-src 'strict-dynamic' ('[^']+' )*'unsafe-inline' 'unsafe-eval' https:;\
base-uri 'none';\
form-action 'none';\
Expand Down
38 changes: 35 additions & 3 deletions src/frontend/src/components/authenticateBox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
InvalidCaller,
LoginSuccess,
NoRegistrationFlow,
PossiblyWrongRPID,
RateLimitExceeded,
RegisterNoSpace,
UnexpectedCall,
Expand All @@ -50,6 +51,8 @@ import {
import { DerEncodedPublicKey } from "@dfinity/agent";
import { isNullish, nonNullish } from "@dfinity/utils";
import { TemplateResult, html, render } from "lit-html";
import { infoToastTemplate } from "../infoToast";
import infoToastCopy from "../infoToast/copy.json";

/** Template used for rendering specific authentication screens. See `authnScreens` below
* for meaning of "firstTime", "useExisting" and "pick". */
Expand Down Expand Up @@ -86,6 +89,7 @@ export const authenticateBox = async ({
connection: AuthenticatedConnection;
newAnchor: boolean;
authnMethod: "pin" | "passkey" | "recovery";
showAddCurrentDevice: boolean;
}> => {
const promptAuth = async (autoSelectIdentity?: bigint) =>
authenticateBoxFlow<PinIdentityMaterial>({
Expand Down Expand Up @@ -189,7 +193,12 @@ export const authenticateBoxFlow = async <I>({
loginPasskey: (
userNumber: bigint
) => Promise<
LoginSuccess | AuthFail | WebAuthnFailed | UnknownUser | ApiError
| LoginSuccess
| AuthFail
| WebAuthnFailed
| PossiblyWrongRPID
| UnknownUser
| ApiError
>;
loginPinIdentityMaterial: ({
userNumber,
Expand Down Expand Up @@ -218,6 +227,7 @@ export const authenticateBoxFlow = async <I>({
newAnchor: boolean;
authnMethod: "pin" | "passkey" | "recovery";
})
| PossiblyWrongRPID
| FlowError
| { tag: "canceled" }
| { tag: "deviceAdded" }
Expand Down Expand Up @@ -267,6 +277,7 @@ export const authenticateBoxFlow = async <I>({
newAnchor: boolean;
authnMethod: "pin" | "passkey" | "recovery";
})
| PossiblyWrongRPID
| FlowError
| { tag: "canceled" }
| { tag: "deviceAdded" }
Expand Down Expand Up @@ -345,7 +356,7 @@ export type FlowError =
| RegisterNoSpace;

export const handleLoginFlowResult = async <E>(
result: (LoginSuccess & E) | FlowError
result: (LoginSuccess & E) | PossiblyWrongRPID | FlowError
): Promise<
({ userNumber: bigint; connection: AuthenticatedConnection } & E) | undefined
> => {
Expand All @@ -354,6 +365,21 @@ export const handleLoginFlowResult = async <E>(
return result;
}

if (result.kind === "possiblyWrongRPID") {
const i18n = new I18n();
const copy = i18n.i18n(infoToastCopy);
toast.info(
infoToastTemplate({
title: copy.title_possibly_wrong_rp_id,
messages: [
copy.message_possibly_wrong_rp_id_1,
copy.message_possibly_wrong_rp_id_2,
],
})
);
return undefined;
}

result satisfies FlowError;

toast.error(flowErrorToastTemplate(result));
Expand Down Expand Up @@ -657,7 +683,12 @@ const useIdentityFlow = async <I>({
loginPasskey: (
userNumber: bigint
) => Promise<
LoginSuccess | AuthFail | WebAuthnFailed | UnknownUser | ApiError
| LoginSuccess
| AuthFail
| WebAuthnFailed
| PossiblyWrongRPID
| UnknownUser
| ApiError
>;
allowPinLogin: boolean;
verifyPinValidity: (opts: {
Expand All @@ -680,6 +711,7 @@ const useIdentityFlow = async <I>({
})
| AuthFail
| WebAuthnFailed
| PossiblyWrongRPID
| UnknownUser
| ApiError
| BadPin
Expand Down
26 changes: 26 additions & 0 deletions src/frontend/src/components/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,29 @@ export const cypherIcon = html`
/>
</svg>
`;

export const googleIcon = html`
<svg
xmlns="http://www.w3.org/2000/svg"
height="24"
viewBox="0 0 24 24"
width="24"
>
<path
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
fill="#4285F4"
/>
<path
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
fill="#34A853"
/>
<path
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
fill="#FBBC05"
/>
<path
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
fill="#EA4335"
/>
</svg>
`;
7 changes: 7 additions & 0 deletions src/frontend/src/components/infoToast/copy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"en": {
"title_possibly_wrong_rp_id": "Please try again",
"message_possibly_wrong_rp_id_1": "The wrong domain was set for the passkey and the browser couldn't find it.",
"message_possibly_wrong_rp_id_2": "Try again and another domain will be used."
}
}
16 changes: 16 additions & 0 deletions src/frontend/src/components/infoToast/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { DynamicKey } from "$src/i18n";
import { html } from "lit-html";

export const infoToastTemplate = ({
title,
messages,
}: {
title: string | DynamicKey;
messages: string[] | DynamicKey[];
}) => html`
<h3 class="t-title c-card__title">${title}</h3>
${messages.map(
(message) =>
html`<p data-role="info-message" class="t-paragraph">${message}</p>`
)}
`;
2 changes: 2 additions & 0 deletions src/frontend/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export const VERSION = import.meta.env.II_VERSION ?? "";
export const FETCH_ROOT_KEY = import.meta.env.II_FETCH_ROOT_KEY === "1";
export const DUMMY_AUTH = import.meta.env.II_DUMMY_AUTH === "1";
export const DUMMY_CAPTCHA = import.meta.env.II_DUMMY_CAPTCHA === "1";
export const II_OPENID_GOOGLE_CLIENT_ID = import.meta.env
.II_OPENID_GOOGLE_CLIENT_ID;
4 changes: 3 additions & 1 deletion src/frontend/src/featureFlags/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Feature flags with default values
const FEATURE_FLAGS_WITH_DEFAULTS = {
DOMAIN_COMPATIBILITY: false,
OPENID_AUTHENTICATION: false,
} as const satisfies Record<string, boolean>;

const LOCALSTORAGE_FEATURE_FLAGS_PREFIX = "ii-localstorage-feature-flags__";
Expand Down Expand Up @@ -63,4 +64,5 @@ const initializedFeatureFlags = Object.fromEntries(
window.__featureFlags = initializedFeatureFlags;

// Export initialized feature flags as named exports
export const { DOMAIN_COMPATIBILITY } = initializedFeatureFlags;
export const { DOMAIN_COMPATIBILITY, OPENID_AUTHENTICATION } =
initializedFeatureFlags;
9 changes: 9 additions & 0 deletions src/frontend/src/flows/addDevice/addCurrentDevice.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"en": {
"title": "Add Current Device",
"paragraph": "Please add the current device to your identity to improve the user experience with Internet Identity.",
"skip": "Skip",
"add": "Add",
"label_icon": "Recommended Action"
}
}
46 changes: 46 additions & 0 deletions src/frontend/src/flows/addDevice/addCurrentDevice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { infoScreenTemplate } from "$src/components/infoScreen";
import { I18n } from "$src/i18n";
import { renderPage } from "$src/utils/lit-html";
import { TemplateResult } from "lit-html";
import copyJson from "./addCurrentDevice.json";

const addCurrentDeviceTemplate = ({
add,
skip,
i18n,
}: {
add: () => void;
skip: () => void;
i18n: I18n;
}): TemplateResult => {
const copy = i18n.i18n(copyJson);

return infoScreenTemplate({
cancel: skip,
cancelText: copy.skip,
next: add,
nextText: copy.add,
title: copy.title,
paragraph: copy.paragraph,
scrollToTop: true,
icon: "info",
pageId: "add-current-device",
label: copy.label_icon,
});
};

export const addCurrentDevicePage = renderPage(addCurrentDeviceTemplate);

// Prompt the user to add the current device (with the current origin).
// Adding the current device to the current origin improves the UX of the user when they come back to this origin.
export const addCurrentDevice = (): Promise<{
action: "skip" | "add-current-device";
}> => {
return new Promise((resolve) =>
addCurrentDevicePage({
i18n: new I18n(),
add: () => resolve({ action: "add-current-device" }),
skip: () => resolve({ action: "skip" }),
})
);
};
12 changes: 6 additions & 6 deletions src/frontend/src/flows/dappsExplorer/dapps.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
[
{
"name": "DecideAI",
"oneLiner": "A fullstack decentralized AI platform",
"website": "https://decideai.xyz",
"logo": "decideai_logo.png"
},
{
"name": "Bitfinity EVM",
"website": "https://bitfinity.network/",
Expand Down Expand Up @@ -119,12 +125,6 @@
"website": "https://boomdao.xyz/",
"logo": "boom-dao-logo.png"
},
{
"name": "DecideAI",
"oneLiner": "A fullstack decentralized AI platform",
"website": "https://decideai.xyz",
"logo": "decideai_logo.png"
},
{
"name": "AutoRoyale",
"website": "https://cm6iy-sqaaa-aaaam-abmxq-cai.icp0.io/",
Expand Down
Loading

0 comments on commit 0fc64b6

Please sign in to comment.