Skip to content

Commit

Permalink
Merge branch 'main' into nm-vc-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
nmattia committed Nov 6, 2023
2 parents 41bef12 + 0604b2c commit 63802df
Show file tree
Hide file tree
Showing 23 changed files with 14,423 additions and 9,152 deletions.
23,132 changes: 14,133 additions & 8,999 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"astro": "^2.4.1",
"eslint": "8.51.0",
"express": "^4.18.2",
"extract-zip": "^2.0.1",
"fake-indexeddb": "^4.0.2",
"html-minifier-terser": "^7.2.0",
"prettier": "2.8.0",
Expand All @@ -53,7 +52,7 @@
"vite": "^4.2.1",
"vite-plugin-compression": "^0.5.1",
"vitest": "^0.31.0",
"webdriverio": "^8.6.9"
"webdriverio": "^8.21.0"
},
"dependencies": {
"@dfinity/agent": "^0.19.2",
Expand Down
1 change: 0 additions & 1 deletion src/canister_sig_util/src/signature_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::borrow::Cow;
use std::collections::BinaryHeap;

pub const LABEL_SIG: &[u8] = b"sig";

#[derive(Default)]
struct Unit;

Expand Down
12 changes: 8 additions & 4 deletions src/frontend/screenshots.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node

import { isNullish } from "@dfinity/utils";
import { ChromeOptions } from "@wdio/types/build/Capabilities";
import { existsSync, mkdirSync } from "fs";
import { remote } from "webdriverio";
import { downloadChrome } from "./download-chrome";

const SCREENSHOTS_DIR =
process.env["SCREENSHOTS_DIR"] ?? "./screenshots/custom";
Expand Down Expand Up @@ -91,7 +91,6 @@ async function withChrome<T>(
): Promise<T> {
// Screenshot image dimension, if specified
const { mobileEmulation } = readScreenshotsConfig();
const chromePath = await downloadChrome();

const chromeOptions: ChromeOptions = {
// font-render-hinting causing broken kerning on headless chrome seems to be a
Expand All @@ -102,18 +101,23 @@ async function withChrome<T>(
"disable-gpu",
"font-render-hinting=none",
"hide-scrollbars",
"disable-dev-shm-usage", // disable /dev/shm usage because chrome is prone to crashing otherwise
],
mobileEmulation,
binary: chromePath,
};

const browser = await remote({
capabilities: {
browserName: "chrome",
browserVersion: "119.0.6045.105", // More information about available versions can be found here: https://github.com/GoogleChromeLabs/chrome-for-testing
"goog:chromeOptions": chromeOptions,
},
});

if (isNullish(mobileEmulation)) {
await browser.setWindowSize(1200, 900);
}

const res = await cb(browser);
await browser.deleteSession();
return res;
Expand Down Expand Up @@ -206,7 +210,7 @@ function readScreenshotsConfig(): {
deviceMetrics: {
width: 360,
height: 640,
pixelRatio: 4,
pixelRatio: 1,
touch: true,
},
},
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/test-e2e/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export async function runInBrowser(
"goog:chromeOptions": chromeOptions,
},
automationProtocol: "webdriver",
// explicitly set host and port, because otherwise webdriverio will start their own chromedriver
hostname: "127.0.0.1",
port: 4444,
path: "/wd/hub",
logLevel: "info",
// outputDir pipes all webdriver log output into ./wdio.log
Expand Down
4 changes: 2 additions & 2 deletions src/internet_identity/src/delegation.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::assets::CertifiedAssets;
use crate::ii_domain::IIDomain;
use crate::state::persistent_state_mut;
use crate::{hash, state, update_root_hash, DAY_NS, LABEL_SIG, MINUTE_NS};
use crate::{hash, state, update_root_hash, DAY_NS, MINUTE_NS};
use candid::Principal;
use canister_sig_util::get_canister_sig_pk_der;
use canister_sig_util::signature_map::SignatureMap;
use canister_sig_util::signature_map::{SignatureMap, LABEL_SIG};
use ic_cdk::api::{data_certificate, time};
use ic_cdk::{id, trap};
use ic_certified_map::{Hash, HashTree};
Expand Down
3 changes: 2 additions & 1 deletion src/internet_identity/src/http.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::assets::{ContentType, EXACT_MATCH_TERMINATOR, IC_CERTIFICATE_EXPRESSION};
use crate::http::metrics::metrics;
use crate::{assets, state, LABEL_SIG};
use crate::{assets, state};
use base64::engine::general_purpose::STANDARD as BASE64;
use base64::Engine;
use canister_sig_util::signature_map::LABEL_SIG;
use ic_cdk::api::data_certificate;
use ic_cdk::trap;
use ic_certified_map::HashTree;
Expand Down
3 changes: 1 addition & 2 deletions src/internet_identity/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::assets::init_assets;
use crate::ii_domain::IIDomain;
use crate::storage::anchor::Anchor;
use candid::{candid_method, Principal};
use canister_sig_util::signature_map::LABEL_SIG;
use ic_cdk::api::{caller, set_certified_data, trap};
use ic_cdk_macros::{init, post_upgrade, pre_upgrade, query, update};
use internet_identity_interface::archive::types::{BufferedEntry, Operation};
Expand Down Expand Up @@ -38,8 +39,6 @@ const MINUTE_NS: u64 = secs_to_nanos(60);
const HOUR_NS: u64 = 60 * MINUTE_NS;
const DAY_NS: u64 = 24 * HOUR_NS;

const LABEL_SIG: &[u8] = b"sig";

// Note: concatenating const &str is a hassle in rust. It seemed easiest to just repeat.
const IC0_APP_DOMAIN: &str = "identity.ic0.app";
const IC0_APP_ORIGIN: &str = "https://identity.ic0.app";
Expand Down
126 changes: 0 additions & 126 deletions src/showcase/src/components.ts

This file was deleted.

57 changes: 57 additions & 0 deletions src/showcase/src/components/ChoosePin.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<choose-pin></choose-pin>

<script>
import { LitComponent } from "./lit";

import { pinInput } from "$src/components/pinInput";
import { Chan } from "$src/utils/utils";
import { html } from "lit-html";
import { asyncReplace } from "lit-html/directives/async-replace.js";

class ChoosePin extends LitComponent {
render() {
const submittedPin = new Chan("N/A");
const pinInputHidden_ = pinInput({
verify: (pin: string) => ({ ok: true, value: pin }),
onSubmit: (pin) => submittedPin.send(pin),
secret: true,
});
const pinInput_ = pinInput({
verify: (pin: string) => ({ ok: true, value: pin }),
onSubmit: (pin) => submittedPin.send(pin),
});

return html` <div
class="c-card"
style="max-width: 30em; margin: 40px auto;"
>
<h2 class="t-title t-title--sub">Regular & Secret PIN inputs</h2>
<div class="c-input--stack">${pinInput_.template}</div>
<div class="c-input--stack">${pinInputHidden_.template}</div>

<output
class="c-input c-input--readonly c-input--stack c-input--fullwidth"
>
Submitted:
<strong class="t-strong">${asyncReplace(submittedPin)}</strong>
</output>
<div class="c-button-group">
<button
@click=${() => pinInput_.submit()}
class="c-button c-input--stack"
>
submit regular
</button>
<button
@click=${() => pinInputHidden_.submit()}
class="c-button c-input--stack"
>
submit hidden
</button>
</div>
</div>`;
}
}

customElements.define("choose-pin", ChoosePin);
</script>
57 changes: 57 additions & 0 deletions src/showcase/src/components/PickAnchor.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<pick-anchor></pick-anchor>

<script>
import { asyncReplace } from "lit-html/directives/async-replace.js";
import { Ref, createRef, ref } from "lit-html/directives/ref.js";
import { Chan, NonEmptyArray, asNonEmptyArray } from "$src/utils/utils";
import { LitComponent } from "./lit";
import { withRef } from "$src/utils/lit-html";
import { TemplateResult, html } from "lit-html";
import { mkAnchorPicker } from "$src/components/anchorPicker";

class PickAnchor extends LitComponent {
render() {
const showSelected: Chan<string> = new Chan("Please pick anchor");
const savedAnchors: Ref<HTMLInputElement> = createRef();
const updateSavedAnchors: Ref<HTMLButtonElement> = createRef();

const mk = (anchors: NonEmptyArray<bigint>): TemplateResult =>
mkAnchorPicker({
savedAnchors: anchors,
pick: (anchor: bigint) => showSelected.send(anchor.toString()),
moreOptions: () => console.log("More options requested"),
focus: false,
}).template;

const chan = new Chan<TemplateResult>(
mk([BigInt(10055), BigInt(1669234)])
);
const update = () =>
withRef(savedAnchors, (savedAnchors) => {
const value = savedAnchors.value;
if (value !== "") {
const values = value.split(",").map((x) => BigInt(x));
const anchors = asNonEmptyArray(values);
if (anchors !== undefined) {
chan.send(mk(anchors));
}
}
});

return html`
<div class="c-card" style="margin: 40px;">
<input class="c-input c-input--fullwidth" ${ref(
savedAnchors
)} placeholder="stored anchors: anchor1, anchor2, ..." ></input>
<button class="c-button c-input--stack" ${ref(
updateSavedAnchors
)} @click="${update}">update</button>
<div>${asyncReplace(chan)}</div>
<div class="c-input c-input--stack c-input--readonly">${asyncReplace(
showSelected
)} </div>
</div>`;
}
}
customElements.define("pick-anchor", PickAnchor);
</script>
Loading

0 comments on commit 63802df

Please sign in to comment.