Skip to content

Commit

Permalink
Merge pull request #93 from serenity-kit/upgrade-prettier
Browse files Browse the repository at this point in the history
upgrade prettier
  • Loading branch information
nikgraf authored Jan 27, 2024
2 parents 6714925 + ca69db2 commit b1a7d59
Show file tree
Hide file tree
Showing 62 changed files with 505 additions and 246 deletions.
8 changes: 4 additions & 4 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ opaque.ready.then(() => {
function build_wbg() {
sh.exec("cargo build --target=wasm32-unknown-unknown --release");
sh.exec(
"wasm-bindgen --out-dir=build/wbg_ristretto --target=web --omit-default-module-path target/wasm32-unknown-unknown/release/opaque.wasm"
"wasm-bindgen --out-dir=build/wbg_ristretto --target=web --omit-default-module-path target/wasm32-unknown-unknown/release/opaque.wasm",
);
sh.exec(
"cargo build --target=wasm32-unknown-unknown --release --features p256"
"cargo build --target=wasm32-unknown-unknown --release --features p256",
);
sh.exec(
"wasm-bindgen --out-dir=build/wbg_p256 --target=web --omit-default-module-path target/wasm32-unknown-unknown/release/opaque.wasm"
"wasm-bindgen --out-dir=build/wbg_p256 --target=web --omit-default-module-path target/wasm32-unknown-unknown/release/opaque.wasm",
);
}

Expand All @@ -84,7 +84,7 @@ function tsc(entry) {
// Our inputs are only ts files because we need to re-export types.
// The target option is not that important because the result will be used as entry point for rollup.
sh.exec(
`pnpm tsc ${entry} --declaration --module es2020 --target es2020 --moduleResolution nodenext --removeComments`
`pnpm tsc ${entry} --declaration --module es2020 --target es2020 --moduleResolution nodenext --removeComments`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/client-simple-vite/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
2 changes: 1 addition & 1 deletion examples/client-simple-vite/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function handleSubmit(e) {
const sessionKey = await login(username, password);
if (sessionKey) {
alert(
`User "${username}" logged in successfully; sessionKey = ${sessionKey}`
`User "${username}" logged in successfully; sessionKey = ${sessionKey}`,
);
} else {
alert(`User "${username}" login failed`);
Expand Down
2 changes: 1 addition & 1 deletion examples/client-simple-webpack/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
2 changes: 1 addition & 1 deletion examples/client-simple-webpack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function handleSubmit(e) {
const sessionKey = await login(username, password);
if (sessionKey) {
alert(
`User "${username}" logged in successfully; sessionKey = ${sessionKey}`
`User "${username}" logged in successfully; sessionKey = ${sessionKey}`,
);
} else {
alert(`User "${username}" login failed`);
Expand Down
4 changes: 2 additions & 2 deletions examples/client-simple-webpack/tests/full-flow.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test("full registration & login flow", async ({ page }) => {
// first login attempt
page.once("dialog", async (dialog) => {
expect(dialog.message()).toContain(
'User "jane_doe" logged in successfully'
'User "jane_doe" logged in successfully',
);
await dialog.dismiss().catch(() => {
throw new Error("Dialog not dismissed");
Expand All @@ -32,7 +32,7 @@ test("full registration & login flow", async ({ page }) => {
// second login attempt
page.once("dialog", async (dialog) => {
expect(dialog.message()).toContain(
'User "jane_doe" logged in successfully'
'User "jane_doe" logged in successfully',
);
await dialog.dismiss().catch(() => {
throw new Error("Dialog not dismissed");
Expand Down
2 changes: 1 addition & 1 deletion examples/client-with-password-reset/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
8 changes: 4 additions & 4 deletions examples/client-with-password-reset/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const showPasswordResetFormButton = requireElement("show_password_reset_form");
const runFullFlowDemoButton = requireElement("run_full_flow_demo");
const cancelPasswordResetButton = requireElement("cancel_password_reset");
const cancelPasswordResetConfirmButton = requireElement(
"cancel_password_reset_confirm"
"cancel_password_reset_confirm",
);

form.addEventListener("submit", handleSubmit);
Expand All @@ -23,7 +23,7 @@ passwordResetForm.addEventListener("submit", handleSubmitPasswordReset);
cancelPasswordResetButton.addEventListener("click", cancelPasswordReset);
passwordResetConfirm.addEventListener(
"submit",
handleSubmitPasswordResetConfirm
handleSubmitPasswordResetConfirm,
);
cancelPasswordResetConfirmButton.addEventListener("click", cancelPasswordReset);

Expand Down Expand Up @@ -145,7 +145,7 @@ async function handleSubmit(e) {
const sessionKey = await login(username, password);
if (sessionKey) {
alert(
`User "${username}" logged in successfully; sessionKey = ${sessionKey}`
`User "${username}" logged in successfully; sessionKey = ${sessionKey}`,
);
} else {
alert(`User "${username}" login failed`);
Expand Down Expand Up @@ -204,7 +204,7 @@ async function handleSubmitPasswordResetConfirm(e) {
userIdentifier,
resetCode,
registrationRequest,
}
},
).then((res) => res.json());

console.log("registrationResponse", registrationResponse);
Expand Down
16 changes: 8 additions & 8 deletions examples/client-with-password-reset/tests/full-flow.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function registerUser(page: Page, name: string, password: string) {
await fillForm(page, name, password);

const dialog = await waitForDialog(page, () =>
page.getByRole("button", { name: "Register" }).click()
page.getByRole("button", { name: "Register" }).click(),
);
expect(dialog.message()).toBe(`User "${name}" registered successfully`);
await dialog.dismiss();
Expand All @@ -36,13 +36,13 @@ test("full registration & login flow", async ({ page }) => {
await registerUser(page, "jane_doe", "hunter42");

let dialog = await waitForDialog(page, () =>
page.getByRole("button", { name: "Login" }).click()
page.getByRole("button", { name: "Login" }).click(),
);
expect(dialog.message()).toContain('User "jane_doe" logged in successfully');
await dialog.dismiss();

dialog = await waitForDialog(page, () =>
page.getByRole("button", { name: "Login" }).click()
page.getByRole("button", { name: "Login" }).click(),
);
expect(dialog.message()).toContain('User "jane_doe" logged in successfully');
await dialog.dismiss();
Expand All @@ -57,7 +57,7 @@ test("forgot password with unknown user", async ({ page }) => {
await username.fill("unknown");

const dialog = await waitForDialog(page, () =>
container.getByText("Request Password Reset").click()
container.getByText("Request Password Reset").click(),
);
expect(dialog.message()).toContain("Error: user not found");
await dialog.dismiss();
Expand All @@ -79,7 +79,7 @@ test("forgot password with invalid reset code", async ({ page }) => {
await page.getByPlaceholder("New Password").fill("foobar");

const dialog = await waitForDialog(page, () =>
page.getByRole("button", { name: "Reset Password" }).click()
page.getByRole("button", { name: "Reset Password" }).click(),
);
expect(dialog.message()).toContain("Error: reset code is invalid or expired");
await dialog.dismiss();
Expand All @@ -101,17 +101,17 @@ test("forgot password happy path", async ({ page }) => {
await page.getByPlaceholder("New Password").fill("foobar");

let dialog = await waitForDialog(page, () =>
page.getByRole("button", { name: "Reset Password" }).click()
page.getByRole("button", { name: "Reset Password" }).click(),
);
expect(dialog.message()).toContain(
`Password reset for "john_doe" successful`
`Password reset for "john_doe" successful`,
);
await dialog.dismiss();

await fillForm(page, "john_doe", "foobar");

dialog = await waitForDialog(page, () =>
page.getByRole("button", { name: "Login" }).click()
page.getByRole("button", { name: "Login" }).click(),
);
expect(dialog.message()).toContain('User "john_doe" logged in successfully');
await dialog.dismiss();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function LoginForm() {
const loginResult = await login(username, password);
if (loginResult) {
console.log(
`User "${username}" logged in successfully; sessionKey = ${loginResult.sessionKey}`
`User "${username}" logged in successfully; sessionKey = ${loginResult.sessionKey}`,
);
storeLoginKeys(loginResult);
redirectPrivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface Datastore {
setSession(
id: string,
entry: SessionEntry,
lifetimeInDays?: number
lifetimeInDays?: number,
): Promise<void>;
getSession(id: string): Promise<SessionEntry | null>;
removeSession(id: string): Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class InMemoryStore implements Datastore {
private data: Schema;
constructor(
data: Partial<Schema> = {},
private listeners: (() => Promise<void>)[] = []
private listeners: (() => Promise<void>)[] = [],
) {
this.data = {
users: {},
Expand Down Expand Up @@ -75,7 +75,7 @@ export default class InMemoryStore implements Datastore {
async setLogin(
name: string,
value: string,
context: string = LOGIN_CONTEXT_SESSION
context: string = LOGIN_CONTEXT_SESSION,
) {
this.data.logins[`${context}:${name}`] = {
value,
Expand Down Expand Up @@ -108,7 +108,7 @@ export default class InMemoryStore implements Datastore {
async setSession(
id: string,
entry: SessionEntry,
lifetimeInDays: number = 14
lifetimeInDays: number = 14,
) {
const expiresAt =
new Date().getTime() + lifetimeInDays * MILLISECONDS_PER_DAY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class RedisStore implements Datastore {

async getSession(id: string) {
const { userIdentifier, sessionKey } = await this.client.hGetAll(
`session:${id}`
`session:${id}`,
);
if (!userIdentifier || !sessionKey) return null;
return { userIdentifier, sessionKey };
Expand All @@ -61,7 +61,7 @@ export default class RedisStore implements Datastore {
async setSession(
id: string,
session: SessionEntry,
lifetimeInDays: number = 14
lifetimeInDays: number = 14,
) {
const expireInSeconds = lifetimeInDays * SECONDS_PER_DAY;
await this.client.hSet(`session:${id}`, /** @type {any} */ session);
Expand Down Expand Up @@ -90,7 +90,7 @@ export default class RedisStore implements Datastore {
await this.client.hSet(`recovery:${name}`, entry.recoveryLockbox);
await this.client.set(
`recovery:registration:${name}`,
entry.registrationRecord
entry.registrationRecord,
);
}

Expand All @@ -102,7 +102,7 @@ export default class RedisStore implements Datastore {
return null;
}
const registrationRecord = await this.client.get(
`recovery:registration:${name}`
`recovery:registration:${name}`,
);
if (registrationRecord == null) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions examples/fullstack-e2e-encrypted-locker-nextjs/app/api/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ async function setupInMemoryStore(): Promise<Datastore> {
const db = await readDatabaseFile(file).catch((err) => {
if ("code" in err && err.code == "ENOENT") {
console.log(
`No database file "${file}" found, initializing with empty store.`
`No database file "${file}" found, initializing with empty store.`,
);
} else {
console.error(
`ERROR: failed to read database file "${file}", initializing with empty store.`
`ERROR: failed to read database file "${file}", initializing with empty store.`,
);
console.error(err);
}
Expand All @@ -43,7 +43,7 @@ async function setupRedis(): Promise<Datastore> {
} catch (err) {
console.error(
"Redis Setup Error:",
err instanceof Error ? err.message : err
err instanceof Error ? err.message : err,
);
process.exit(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import withUserSession from "../withUserSession";
import sodium from "libsodium-wrappers";

function isValidLockerPayload(
data: unknown
data: unknown,
): data is LockerWithServerVerificationMac {
return (
data != null &&
Expand All @@ -30,7 +30,7 @@ export async function POST(req: NextRequest) {
if (!isValidLockerPayload(payload)) {
return NextResponse.json(
{ error: "invalid locker payload" },
{ status: 400 }
{ status: 400 },
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export async function POST(request: NextRequest) {
if (!userIdentifier)
return NextResponse.json(
{ error: "missing userIdentifier" },
{ status: 400 }
{ status: 400 },
);

if (!finishLoginRequest)
return NextResponse.json(
{ error: "missing finishLoginRequest" },
{ status: 400 }
{ status: 400 },
);

const db = await database;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export async function POST(request: NextRequest) {
if (!userIdentifier)
return NextResponse.json(
{ error: "missing userIdentifier" },
{ status: 400 }
{ status: 400 },
);
if (!startLoginRequest)
return NextResponse.json(
{ error: "missing startLoginRequest" },
{ status: 400 }
{ status: 400 },
);

const db = await database;
Expand All @@ -27,7 +27,7 @@ export async function POST(request: NextRequest) {
if (hasLogin)
return NextResponse.json(
{ error: "login already started" },
{ status: 400 }
{ status: 400 },
);

const { serverLoginState, loginResponse } = opaque.server.startLogin({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export async function POST(request: NextRequest) {
if (!userIdentifier)
return NextResponse.json(
{ error: "missing userIdentifier" },
{ status: 400 }
{ status: 400 },
);

if (!finishLoginRequest)
return NextResponse.json(
{ error: "missing finishLoginRequest" },
{ status: 400 }
{ status: 400 },
);

const db = await database;
Expand All @@ -23,7 +23,7 @@ export async function POST(request: NextRequest) {
if (!serverLoginState)
return NextResponse.json(
{ error: "recovery login not started" },
{ status: 400 }
{ status: 400 },
);

const { sessionKey } = opaque.server.finishLogin({
Expand All @@ -47,6 +47,6 @@ export async function POST(request: NextRequest) {
{ recoveryLockbox: recovery.recoveryLockbox, locker },
{
status: 200,
}
},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export async function POST(request: NextRequest) {
if (!userIdentifier)
return NextResponse.json(
{ error: "missing userIdentifier" },
{ status: 400 }
{ status: 400 },
);
if (!startLoginRequest)
return NextResponse.json(
{ error: "missing startLoginRequest" },
{ status: 400 }
{ status: 400 },
);

const db = await database;
Expand All @@ -23,7 +23,7 @@ export async function POST(request: NextRequest) {
if (hasLogin)
return NextResponse.json(
{ error: "login already started" },
{ status: 400 }
{ status: 400 },
);

const recovery = await db.getRecovery(userIdentifier);
Expand Down
Loading

0 comments on commit b1a7d59

Please sign in to comment.