Skip to content

Commit 0663103

Browse files
committed
fix: auth server ports
1 parent a5e4249 commit 0663103

File tree

8 files changed

+97
-27
lines changed

8 files changed

+97
-27
lines changed

examples/demo-app/playwright.config.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ export default defineConfig({
4444
/* Run your local server before starting the tests */
4545
webServer: [
4646
{
47-
command: "pnpm nx preview demo-app",
48-
url: "http://localhost:3004",
47+
command: "pnpm nx dev auth-server",
48+
url: "http://localhost:3002",
4949
reuseExistingServer: !process.env.CI,
5050
timeout: 180_000,
51+
cwd: "../../",
5152
},
5253
{
53-
command: "pnpm nx preview auth-server",
54-
url: "http://localhost:3002",
54+
command: "PORT=3004 pnpm nuxt dev",
55+
url: "http://localhost:3004",
5556
reuseExistingServer: !process.env.CI,
5657
timeout: 180_000,
5758
},

examples/demo-app/project.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@
8787
},
8888
"dependsOn": ["build:local"]
8989
},
90+
"e2e:setup": {
91+
"executor": "nx:run-commands",
92+
"options": {
93+
"cwd": "examples/demo-app",
94+
"command": "pnpm exec playwright install chromium"
95+
},
96+
"dependsOn": ["deploy-contracts-erc4337"]
97+
},
9098
"e2e:setup:erc4337": {
9199
"executor": "nx:run-commands",
92100
"options": {
@@ -99,15 +107,15 @@
99107
"executor": "nx:run-commands",
100108
"options": {
101109
"cwd": "examples/demo-app",
102-
"command": "playwright test --config=playwright.config.ts"
110+
"command": "PW_TEST_HTML_REPORT_OPEN=never playwright test --config=playwright.config.ts"
103111
},
104112
"dependsOn": ["e2e:setup"]
105113
},
106114
"e2e:erc4337": {
107115
"executor": "nx:run-commands",
108116
"options": {
109117
"cwd": "examples/demo-app",
110-
"command": "playwright test --config=playwright-erc4337.config.ts"
118+
"command": "PW_TEST_HTML_REPORT_OPEN=never playwright test --config=playwright-erc4337.config.ts"
111119
},
112120
"dependsOn": ["e2e:setup:erc4337"]
113121
},

examples/demo-app/tests/create-account.spec.ts

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,37 @@ test("Create passkey account and send ETH", async ({ page }) => {
207207
// Click Sign Up
208208
await popup.getByTestId("signup").click();
209209

210+
// Wait for account deployment to complete
211+
await page.waitForTimeout(3000);
212+
213+
// After deployment, session creation requires WebAuthn signing
214+
// We need to recreate the virtual authenticator with the same credential
215+
client = await popup.context().newCDPSession(popup);
216+
await client.send("WebAuthn.enable");
217+
const resultAuth1 = await client.send("WebAuthn.addVirtualAuthenticator", {
218+
options: {
219+
protocol: "ctap2",
220+
transport: "usb",
221+
hasResidentKey: true,
222+
hasUserVerification: true,
223+
isUserVerified: true,
224+
automaticPresenceSimulation: true,
225+
},
226+
});
227+
await expect(newCredential).not.toBeNull();
228+
await client.send("WebAuthn.addCredential", {
229+
authenticatorId: resultAuth1.authenticatorId,
230+
credential: newCredential!,
231+
});
232+
210233
// Confirm access to your account
211234
await expect(popup.getByText("Connect to ZKsync SSO Demo")).toBeVisible();
212235
await expect(popup.getByText("localhost:3004")).toBeVisible();
213236
await expect(popup.getByText("Let it see your address, balance and activity")).toBeVisible();
214237
await popup.getByTestId("connect").click();
215238

216-
// Waits for session to complete and popup to close
217-
await page.waitForTimeout(2000);
239+
// Wait for session creation (WebAuthn signing) and popup to close
240+
await page.waitForTimeout(3000);
218241

219242
// Check address/balance is shown
220243
await expect(page.getByText("Disconnect")).toBeVisible();
@@ -309,14 +332,37 @@ test("Create passkey account and send ETH with paymaster", async ({ page }) => {
309332
// Click Sign Up
310333
await popup.getByTestId("signup").click();
311334

335+
// Wait for account deployment to complete
336+
await page.waitForTimeout(3000);
337+
338+
// After deployment, session creation requires WebAuthn signing
339+
// We need to recreate the virtual authenticator with the same credential
340+
client = await popup.context().newCDPSession(popup);
341+
await client.send("WebAuthn.enable");
342+
const resultAuth2 = await client.send("WebAuthn.addVirtualAuthenticator", {
343+
options: {
344+
protocol: "ctap2",
345+
transport: "usb",
346+
hasResidentKey: true,
347+
hasUserVerification: true,
348+
isUserVerified: true,
349+
automaticPresenceSimulation: true,
350+
},
351+
});
352+
await expect(newCredential).not.toBeNull();
353+
await client.send("WebAuthn.addCredential", {
354+
authenticatorId: resultAuth2.authenticatorId,
355+
credential: newCredential!,
356+
});
357+
312358
// Confirm access to your account
313359
await expect(popup.getByText("Connect to ZKsync SSO Demo")).toBeVisible();
314360
await expect(popup.getByText("localhost:3004")).toBeVisible();
315361
await expect(popup.getByText("Let it see your address, balance and activity")).toBeVisible();
316362
await popup.getByTestId("connect").click();
317363

318-
// Waits for session to complete and popup to close
319-
await page.waitForTimeout(2000);
364+
// Wait for session creation (WebAuthn signing) and popup to close
365+
await page.waitForTimeout(3000);
320366

321367
// Check address/balance is shown
322368
await expect(page.getByText("Disconnect")).toBeVisible();
@@ -335,7 +381,7 @@ test("Create passkey account and send ETH with paymaster", async ({ page }) => {
335381
// We need to recreate the virtual authenticator to match the previous one
336382
client = await popup.context().newCDPSession(popup);
337383
await client.send("WebAuthn.enable");
338-
const result = await client.send("WebAuthn.addVirtualAuthenticator", {
384+
const resultPaymaster = await client.send("WebAuthn.addVirtualAuthenticator", {
339385
options: {
340386
protocol: "ctap2",
341387
transport: "usb",
@@ -347,7 +393,7 @@ test("Create passkey account and send ETH with paymaster", async ({ page }) => {
347393
});
348394
await expect(newCredential).not.toBeNull();
349395
await client.send("WebAuthn.addCredential", {
350-
authenticatorId: result.authenticatorId,
396+
authenticatorId: resultPaymaster.authenticatorId,
351397
credential: newCredential!,
352398
});
353399

@@ -411,14 +457,37 @@ test("Create passkey account and sign typed data", async ({ page }) => {
411457
// Click Sign Up
412458
await popup.getByTestId("signup").click();
413459

460+
// Wait for account deployment to complete
461+
await page.waitForTimeout(3000);
462+
463+
// After deployment, session creation requires WebAuthn signing
464+
// We need to recreate the virtual authenticator with the same credential
465+
client = await popup.context().newCDPSession(popup);
466+
await client.send("WebAuthn.enable");
467+
const resultAuth3 = await client.send("WebAuthn.addVirtualAuthenticator", {
468+
options: {
469+
protocol: "ctap2",
470+
transport: "usb",
471+
hasResidentKey: true,
472+
hasUserVerification: true,
473+
isUserVerified: true,
474+
automaticPresenceSimulation: true,
475+
},
476+
});
477+
await expect(newCredential).not.toBeNull();
478+
await client.send("WebAuthn.addCredential", {
479+
authenticatorId: resultAuth3.authenticatorId,
480+
credential: newCredential!,
481+
});
482+
414483
// Confirm access to your account
415484
await expect(popup.getByText("Connect to ZKsync SSO Demo")).toBeVisible();
416485
await expect(popup.getByText("localhost:3004")).toBeVisible();
417486
await expect(popup.getByText("Let it see your address, balance and activity")).toBeVisible();
418487
await popup.getByTestId("connect").click();
419488

420-
// Waits for session to complete and popup to close
421-
await page.waitForTimeout(2000);
489+
// Wait for session creation (WebAuthn signing) and popup to close
490+
await page.waitForTimeout(3000);
422491

423492
// Check address/balance is shown
424493
await expect(page.getByText("Disconnect")).toBeVisible();
@@ -438,7 +507,7 @@ test("Create passkey account and sign typed data", async ({ page }) => {
438507
// We need to recreate the virtual authenticator to match the previous one
439508
client = await popup.context().newCDPSession(popup);
440509
await client.send("WebAuthn.enable");
441-
const result = await client.send("WebAuthn.addVirtualAuthenticator", {
510+
const resultTypedData = await client.send("WebAuthn.addVirtualAuthenticator", {
442511
options: {
443512
protocol: "ctap2",
444513
transport: "usb",
@@ -450,7 +519,7 @@ test("Create passkey account and sign typed data", async ({ page }) => {
450519
});
451520
await expect(newCredential).not.toBeNull();
452521
await client.send("WebAuthn.addCredential", {
453-
authenticatorId: result.authenticatorId,
522+
authenticatorId: resultTypedData.authenticatorId,
454523
credential: newCredential!,
455524
});
456525

packages/auth-server-api/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ try {
3030

3131
// Environment schema with optional contract addresses (can fall back to contracts.json)
3232
const envSchema = z.object({
33-
PORT: z.string().default("3004"),
33+
PORT: z.string().default("3005"),
3434
CORS_ORIGINS: z.string().default("http://localhost:3003,http://localhost:3002,http://localhost:3000"),
3535
DEPLOYER_PRIVATE_KEY: z.string().default("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"),
3636
RPC_URL: z.string().default("http://127.0.0.1:8545"),

packages/auth-server-api/src/handlers/deploy-account.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,6 @@ export const deployAccountHandler = async (req: Request, res: Response): Promise
158158
hash: fundingHash,
159159
});
160160
console.log("Account funded with 1 ETH");
161-
162-
// Give the bundler/network a moment to see the updated balance
163-
// This is especially important in CI environments with forked networks
164-
await new Promise((resolve) => setTimeout(resolve, 2000));
165161
} catch (error) {
166162
console.error("Failed to fund account:", error);
167163
// Don't fail the deployment if funding fails

packages/auth-server/components/views/confirmation/RequestSession.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,6 @@ const confirmConnection = async () => {
285285
credentialId: accountData.credentialId,
286286
});
287287
288-
// Give the bundler time to see the funded account balance
289-
// This is especially important in CI environments with forked networks
290-
await new Promise((resolve) => setTimeout(resolve, 3000));
291-
292288
// Create the session on-chain for the new account
293289
// The account is deployed but the session needs to be registered on-chain
294290
const client = getClient({ chainId: requestChainId.value });

packages/auth-server/nuxt.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default defineNuxtConfig({
8585
chainId: parseInt(process.env.NUXT_PUBLIC_DEFAULT_CHAIN_ID || "") || localhost.id,
8686
ssoAccountInterfaceId: "0xb9094997",
8787
appKitProjectId: process.env.NUXT_PUBLIC_APPKIT_PROJECT_ID || "9bc5059f6eed355858cc56a3388e9b50",
88-
authServerApiUrl: process.env.NUXT_PUBLIC_AUTH_SERVER_API_URL || "http://localhost:3004",
88+
authServerApiUrl: process.env.NUXT_PUBLIC_AUTH_SERVER_API_URL || "http://localhost:3005",
8989
prividiumMode: process.env.PRIVIDIUM_MODE === "true",
9090
prividium: {
9191
clientId: process.env.PRIVIDIUM_CLIENT_ID || "",

packages/auth-server/stores/local-node.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"webauthnValidator": "0xE854be130245223cBDD20c85f4F126996669Cf08",
66
"factory": "0x099961116Ba4371a2516034233177Ee3eFcdaf39",
77
"bundlerUrl": "http://localhost:4337",
8-
"paymaster": ""
8+
"paymaster": "0x2ed0D24Bf778Aa0A80B580406f35AaBB607Ccb8F"
99
}

0 commit comments

Comments
 (0)