Skip to content

Commit e8c7503

Browse files
authored
Fix/sandbox env and data parameter (#814)
* feat: update database configurations and environment path for evoting and registry platforms * feat: enhance QR code handling and improve message signing logic
1 parent 53bda10 commit e8c7503

4 files changed

Lines changed: 24 additions & 9 deletions

File tree

docker-compose.databases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
environment:
1111
- POSTGRES_USER=${POSTGRES_USER:-postgres}
1212
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
13-
- POSTGRES_MULTIPLE_DATABASES=registry,provisioner
13+
- POSTGRES_MULTIPLE_DATABASES=registry,provisioner,evoting
1414
volumes:
1515
- postgres_data:/var/lib/postgresql/data
1616
- ./db/init-multiple-databases.sh:/docker-entrypoint-initdb.d/init-multiple-databases.sh

infrastructure/dev-sandbox/src/routes/+page.svelte

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,11 @@
331331
if (text) {
332332
w3dsInput = text.trim();
333333
actionError = null;
334-
addLog("info", "Decoded QR", text.slice(0, 50) + (text.length > 50 ? "" : ""));
334+
addLog(
335+
"info",
336+
"Decoded QR",
337+
text.slice(0, 50) + (text.length > 50 ? "" : ""),
338+
);
335339
} else {
336340
qrDecodeError = "No QR code found in image.";
337341
}
@@ -354,8 +358,8 @@
354358
}
355359
356360
function handlePaste(e: ClipboardEvent) {
357-
const item = Array.from(e.clipboardData?.items ?? []).find(
358-
(it) => it.type.startsWith("image/"),
361+
const item = Array.from(e.clipboardData?.items ?? []).find((it) =>
362+
it.type.startsWith("image/"),
359363
);
360364
const file = item?.getAsFile();
361365
if (file) {
@@ -428,21 +432,31 @@
428432
} else {
429433
const sessionId = url.searchParams.get("session") ?? "";
430434
const redirectUri = url.searchParams.get("redirect_uri") ?? "";
435+
const dataParam = url.searchParams.get("data") ?? "";
431436
if (!sessionId || !redirectUri) {
432437
actionError = "w3ds://sign needs session and redirect_uri.";
433438
return;
434439
}
440+
// Decode base64 data if present, otherwise fallback to sessionId
441+
let messageToSign = sessionId;
442+
if (dataParam) {
443+
try {
444+
messageToSign = atob(dataParam);
445+
} catch {
446+
messageToSign = dataParam;
447+
}
448+
}
435449
const signature = await signPayload({
436450
cryptoAdapter: adapter,
437451
keyId: selectedIdentity.keyId,
438452
context: "onboarding",
439-
payload: sessionId,
453+
payload: messageToSign,
440454
});
441455
const body = {
442456
sessionId,
443457
signature,
444458
w3id: selectedIdentity.w3id,
445-
message: sessionId,
459+
message: messageToSign,
446460
};
447461
const res = await fetch(redirectUri, {
448462
method: "POST",
@@ -578,7 +592,8 @@
578592
<p>
579593
Paste a <code>w3ds://auth</code> or
580594
<code>w3ds://sign</code> URI (or HTTP URL with session/redirect_uri).
581-
You can also upload or paste an image of a QR code to decode the request.
595+
You can also upload or paste an image of a QR code to decode
596+
the request.
582597
</p>
583598
<div class="w3ds-qr-actions">
584599
<input

platforms/evoting/api/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { CronManagerService } from "./services/CronManagerService";
1818
config({ path: path.resolve(__dirname, "../../../.env") });
1919

2020
const app = express();
21-
const port = process.env.PORT || 4000;
21+
const port = process.env.EVOTING_API_PORT || process.env.PORT || 4001;
2222

2323
// Initialize database connection and adapter
2424
AppDataSource.initialize()

platforms/registry/api/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fs.watchFile(path.resolve(__dirname, "../motd.json"), (_curr, _prev) => {
2626
motd = loadMotdJSON();
2727
});
2828

29-
dotenv.config({ path: path.resolve(__dirname, "../../../.env") });
29+
dotenv.config({ path: path.resolve(__dirname, "../../../../.env") });
3030

3131
const server = fastify({ logger: true });
3232

0 commit comments

Comments
 (0)