Skip to content
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
10 changes: 5 additions & 5 deletions demos/test-app/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const authWithII = async ({

// Send the request to II
const sessionPublicKey: Uint8Array = new Uint8Array(
sessionIdentity.getPublicKey().toDer()
sessionIdentity.getPublicKey().toDer(),
);

const request = {
Expand Down Expand Up @@ -120,12 +120,12 @@ const identityFromResponse = ({

const delegationChain = DelegationChain.fromDelegations(
delegations,
response.userPublicKey.buffer
response.userPublicKey.buffer,
);

const identity = DelegationIdentity.fromDelegation(
sessionIdentity,
delegationChain
delegationChain,
);

return identity;
Expand All @@ -137,12 +137,12 @@ type ElementOf<Arr> = Arr extends readonly (infer ElementOf)[]
: "argument is not an array";

export const extractDelegation = (
signedDelegation: ElementOf<AuthResponseSuccess["delegations"]>
signedDelegation: ElementOf<AuthResponseSuccess["delegations"]>,
): SignedDelegation => ({
delegation: new Delegation(
signedDelegation.delegation.pubkey,
signedDelegation.delegation.expiration,
signedDelegation.delegation.targets
signedDelegation.delegation.targets,
),
signature: signedDelegation.signature
.buffer as Signature /* brand type for agent-js */,
Expand Down
54 changes: 27 additions & 27 deletions demos/test-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,58 +21,58 @@ import "./main.css";
const signInBtn = document.getElementById("signinBtn") as HTMLButtonElement;
const whoamiBtn = document.getElementById("whoamiBtn") as HTMLButtonElement;
const updateAlternativeOriginsBtn = document.getElementById(
"updateNewAlternativeOrigins"
"updateNewAlternativeOrigins",
) as HTMLButtonElement;
const openIiWindowBtn = document.getElementById(
"openIiWindowBtn"
"openIiWindowBtn",
) as HTMLButtonElement;
const closeIiWindowBtn = document.getElementById(
"closeIIWindowBtn"
"closeIIWindowBtn",
) as HTMLButtonElement;
const invalidDataBtn = document.getElementById(
"invalidDataBtn"
"invalidDataBtn",
) as HTMLButtonElement;
const incompleteMessageBtn = document.getElementById(
"incompleteMessageBtn"
"incompleteMessageBtn",
) as HTMLButtonElement;
const validMessageBtn = document.getElementById(
"validMessageBtn"
"validMessageBtn",
) as HTMLButtonElement;
const customMessageEl = document.getElementById(
"customMessage"
"customMessage",
) as HTMLInputElement;
const customMessageBtn = document.getElementById(
"customMessageBtn"
"customMessageBtn",
) as HTMLButtonElement;
const messagesEl = document.getElementById("messages") as HTMLElement;
const hostUrlEl = document.getElementById("hostUrl") as HTMLInputElement;
const whoAmIResponseEl = document.getElementById(
"whoamiResponse"
"whoamiResponse",
) as HTMLDivElement;
const alternativeOriginsEl = document.getElementById(
"alternativeOrigins"
"alternativeOrigins",
) as HTMLDivElement;
const newAlternativeOriginsEl = document.getElementById(
"newAlternativeOrigins"
"newAlternativeOrigins",
) as HTMLInputElement;
const principalEl = document.getElementById("principal") as HTMLDivElement;
const authnMethodEl = document.querySelector(
'[data-role="authn-method"]'
'[data-role="authn-method"]',
) as HTMLDivElement;
const delegationEl = document.getElementById("delegation") as HTMLPreElement;
const expirationEl = document.getElementById("expiration") as HTMLDivElement;
const iiUrlEl = document.getElementById("iiUrl") as HTMLInputElement;
const maxTimeToLiveEl = document.getElementById(
"maxTimeToLive"
"maxTimeToLive",
) as HTMLInputElement;
const derivationOriginEl = document.getElementById(
"derivationOrigin"
"derivationOrigin",
) as HTMLInputElement;
const autoSelectionPrincipalEl = document.getElementById(
"autoSelectionPrincipal"
"autoSelectionPrincipal",
) as HTMLInputElement;
const allowPinAuthenticationEl = document.getElementById(
"allowPinAuthentication"
"allowPinAuthentication",
) as HTMLInputElement;

let iiProtocolTestWindow: Window | undefined;
Expand Down Expand Up @@ -112,7 +112,7 @@ const idlFactory = ({ IDL }: { IDL: any }) => {
update_alternative_origins: IDL.Func(
[IDL.Text, AlternativeOriginsMode],
[],
[]
[],
),
whoami: IDL.Func([], [IDL.Principal], ["query"]),
});
Expand All @@ -135,7 +135,7 @@ const updateDelegationView = ({
delegationEl.innerText = JSON.stringify(
identity.getDelegation().toJSON(),
undefined,
2
2,
);

// cannot use Math.min, as we deal with bigint here
Expand Down Expand Up @@ -171,7 +171,7 @@ function addMessageElement({
messageTitle.classList.add("postMessage-title");
const messageContent = document.createElement("div");
messageContent.innerText = JSON.stringify(message, (_, v) =>
typeof v === "bigint" ? v.toString() : v
typeof v === "bigint" ? v.toString() : v,
);
if (ty === "received") {
messageTitle.innerText = "Message Received";
Expand Down Expand Up @@ -199,12 +199,12 @@ window.addEventListener("message", (event) => {
const delegations = event.data.delegations.map(extractDelegation);
const delegationChain = DelegationChain.fromDelegations(
delegations,
event.data.userPublicKey.buffer
event.data.userPublicKey.buffer,
);
updateDelegationView({
identity: DelegationIdentity.fromDelegation(
getLocalIdentity(),
delegationChain
delegationChain,
),
});
});
Expand Down Expand Up @@ -301,7 +301,7 @@ const init = async () => {
const validMessage = {
kind: "authorize-client",
sessionPublicKey: new Uint8Array(
getLocalIdentity().getPublicKey().toDer()
getLocalIdentity().getPublicKey().toDer(),
),
derivationOrigin,
maxTimeToLive,
Expand Down Expand Up @@ -330,7 +330,7 @@ const init = async () => {
});
const modeSelection = (
document.querySelector(
'input[name="alternativeOriginsMode"]:checked'
'input[name="alternativeOriginsMode"]:checked',
) as HTMLInputElement
).value;
let mode:
Expand Down Expand Up @@ -430,7 +430,7 @@ function handleFlowReady(evnt: MessageEvent) {

if (opts === undefined) {
return showError(
"Unexpected: received OK from IDP but this test app is not ready"
"Unexpected: received OK from IDP but this test app is not ready",
);
}

Expand Down Expand Up @@ -491,7 +491,7 @@ function handleFlowFinished(evnt: MessageEvent) {
const ver = decodeJwt(verifiablePresentation) as any;
const creds = ver.vp.verifiableCredential;
const [alias, credential] = creds.map((cred: string) =>
JSON.stringify(decodeJwt(cred), null, 2)
JSON.stringify(decodeJwt(cred), null, 2),
);

setLatestPresentation({ alias, credential });
Expand All @@ -504,7 +504,7 @@ function handleFlowFinished(evnt: MessageEvent) {
const App = () => {
// The URL used for connecting to the issuer
const [issuerUrl, setIssuerUrl] = useState<string>(
"http://issuer.localhost:5173"
"http://issuer.localhost:5173",
);

const [issuerCanisterId, setIssuerCanisterId] = useState<string>("");
Expand Down Expand Up @@ -607,5 +607,5 @@ const App = () => {
ReactDOM.createRoot(document.getElementById("root-vc-flow")!).render(
<React.StrictMode>
<App />
</React.StrictMode>
</React.StrictMode>,
);
2 changes: 1 addition & 1 deletion demos/using-dev-build/specs/auth.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("authentication", () => {
(await title.getText()) === "You’ve created an Internet Identity!"
);
},
{ timeout: 20_000 }
{ timeout: 20_000 },
);
});
});
2 changes: 1 addition & 1 deletion demos/using-dev-build/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const readCanisterId = ({
return stdout.toString().trim();
} catch (e) {
throw Error(
`Could not get canister ID for '${canisterName}' with command '${command}', was the canister deployed? ${e}`
`Could not get canister ID for '${canisterName}' with command '${command}', was the canister deployed? ${e}`,
);
}
};
Expand Down
2 changes: 1 addition & 1 deletion demos/using-dev-build/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ export default defineConfig(
"/api": "http://127.0.0.1:4943",
},
},
})
}),
);
2 changes: 1 addition & 1 deletion demos/using-dev-build/vite.plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const readCanisterIds = (): Record<string, string> => {
};

const config: Record<string, Details> = JSON.parse(
readFileSync(canisterIdsJsonFile, "utf-8")
readFileSync(canisterIdsJsonFile, "utf-8"),
);

return Object.entries(config).reduce((acc, current: [string, Details]) => {
Expand Down
2 changes: 1 addition & 1 deletion demos/using-dev-build/webapp/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<style>
Expand Down
2 changes: 1 addition & 1 deletion demos/vc_issuer/app/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
6 changes: 3 additions & 3 deletions demos/vc_issuer/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import "./main.css";
const readCanisterId = (): string => {
// The backend uses a known element ID so that we can pick up the value from here
const setupJs = document.querySelector(
"[data-canister-id]"
"[data-canister-id]",
) as HTMLElement | null;
if (!setupJs || setupJs.dataset.canisterId === undefined) {
throw new Error("canisterId is undefined"); // abort further execution of this script
Expand Down Expand Up @@ -42,7 +42,7 @@ const App = () => {

// The derivation origin to use for authentication
const [derivationOrigin, setDerivationOrigin] = useState<string | undefined>(
undefined
undefined,
);

// The principal, set during auth
Expand Down Expand Up @@ -185,5 +185,5 @@ const App = () => {
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>
</React.StrictMode>,
);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"lint:eslint": "eslint --max-warnings 0 --cache --cache-location node_modules/.cache/eslint 'src/frontend/**/*.ts*' 'src/showcase/**/*.ts'",
"lint:lit": "lit-analyzer -- --rules.no-incompatible-type-binding off --rules.no-invalid-directive-binding off --rules.no-noncallable-event-binding off ./src/showcase ./src/frontend",
"format": "prettier --write src/showcase src/frontend src/vc-api src/sig-verifier-js src/vite-plugins tsconfig.json tsconfig.all.json eslint.config.js vite.config.ts vitest.config.ts demos",
"format-check": "exit 0"
"format-check": "prettier --check src/showcase src/frontend src/vc-api src/sig-verifier-js src/vite-plugins tsconfig.json tsconfig.all.json eslint.config.js vite.config.ts vitest.config.ts demos"
},
"devDependencies": {
"@astrojs/check": "^0.9.4",
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/callback/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/faq.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
10 changes: 5 additions & 5 deletions src/frontend/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function takeLandingScreenshots(browser: WebdriverIO.Browser) {
window.scrollTo(0, i * screenshotHeight);
},
i,
screenshotHeight
screenshotHeight,
);
await browser.saveScreenshot(`${SCREENSHOTS_DIR}/landing_${i + 1}.png`);
}
Expand All @@ -59,7 +59,7 @@ async function takeShowcaseScreenshots(browser: WebdriverIO.Browser) {
await pageLinks.map(async (link) => {
const pageName = await link.getAttribute("data-page-name");
return pageName;
})
}),
);

// Iterate the pages and screenshot them
Expand All @@ -83,7 +83,7 @@ async function takeShowcaseScreenshots(browser: WebdriverIO.Browser) {

/** Create a chrome instance and run callback, deleting session afterwards */
async function withChrome<T>(
cb: (browser: WebdriverIO.Browser) => T
cb: (browser: WebdriverIO.Browser) => T,
): Promise<T> {
// Screenshot image dimension, if specified
const { mobileEmulation } = readScreenshotsConfig();
Expand Down Expand Up @@ -169,15 +169,15 @@ async function visit(browser: WebdriverIO.Browser, url: string) {
{
timeout: 10 * 1000,
timeoutMsg: "Images did not load after 10 seconds",
}
},
);

await browser.waitUntil(
() => browser.execute(() => document.readyState === "complete"),
{
timeout: 10 * 1000,
timeoutMsg: "Browser did not load after 10 seconds",
}
},
);
}

Expand Down
36 changes: 20 additions & 16 deletions src/frontend/src/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,27 @@ export const showWarningIfNecessary = (config: InternetIdentityInit): void => {
const isProduction: boolean = config.is_production[0] ?? false;
const firstUrl: string = config.related_origins[0]?.[0] ?? OFFICIAL_II_URL;
if (anyFeatures()) {
showWarning(html`Test only. Do not use your regular Internet Identity!
<a
class="features-warning-btn"
target="_blank"
rel="noopener noreferrer"
href="https://github.com/dfinity/internet-identity#build-features"
>more</a
>`);
showWarning(
html`Test only. Do not use your regular Internet Identity!
<a
class="features-warning-btn"
target="_blank"
rel="noopener noreferrer"
href="https://github.com/dfinity/internet-identity#build-features"
>more</a
>`,
);
} else if (!isProduction) {
showWarning(html`This is not the official Internet Identity.
<a
class="features-warning-btn"
target="_blank"
rel="noopener noreferrer"
href=${firstUrl}
>go to official</a
>`);
showWarning(
html`This is not the official Internet Identity.
<a
class="features-warning-btn"
target="_blank"
rel="noopener noreferrer"
href=${firstUrl}
>go to official</a
>`,
);
}
};

Expand Down
Loading