Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",
);
MARKETING_VERSION = 0.3.0;
PRODUCT_BUNDLE_IDENTIFIER = "foundation.metastate.eid-wallet";
PRODUCT_BUNDLE_IDENTIFIER = foundation.metastate.eid-wallet;
PRODUCT_NAME = "eID for W3DS";
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down Expand Up @@ -464,7 +464,7 @@
"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",
);
MARKETING_VERSION = 0.3.0;
PRODUCT_BUNDLE_IDENTIFIER = "foundation.metastate.eid-wallet";
PRODUCT_BUNDLE_IDENTIFIER = foundation.metastate.eid-wallet;
PRODUCT_NAME = "eID for W3DS";
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
</plist>
154 changes: 97 additions & 57 deletions infrastructure/eid-wallet/src/routes/(app)/scan-qr/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@
requestPermissions,
scan,
} from "@tauri-apps/plugin-barcode-scanner";
import {
exists,
generate,
getPublicKey,
signPayload,
// verifySignature
} from "@auvo/tauri-plugin-crypto-hw-api";

import { KeyManagerFactory } from "$lib/crypto/KeyManagerFactory";
import axios from "axios";
import { getContext, onDestroy, onMount } from "svelte";
import type { SVGAttributes } from "svelte/elements";
Expand Down Expand Up @@ -167,7 +162,52 @@
if (!vault || !redirect) return;

try {
await axios.post(redirect, { ename: vault.ename, session });
// Get the appropriate key manager for authentication
const keyManager = await KeyManagerFactory.getKeyManagerForContext(
vault.ename,
"signing",
);

// Ensure the key exists
if (!(await keyManager.exists(vault.ename))) {
await keyManager.generate(vault.ename);
}

// Get the W3ID (public key)
const w3idResult = await keyManager.getPublicKey(vault.ename);
if (!w3idResult) {
throw new Error("Failed to get W3ID");
}

// Create the session payload to sign
const sessionPayload = JSON.stringify({
session: session,
ename: vault.ename,
timestamp: Date.now(),
});

// Sign the session payload
const signature = await keyManager.signPayload(
vault.ename,
sessionPayload,
);

// Create the auth payload with W3ID and signature
const authPayload = {
ename: vault.ename,
session: session,
w3id: w3idResult,
signature: signature,
};

console.log("🔐 Auth payload with signature:", {
ename: authPayload.ename,
session: authPayload.session,
w3id: authPayload.w3id,
signatureLength: authPayload.signature.length,
});

await axios.post(redirect, authPayload);
codeScannedDrawerOpen = false;

// Check if this was from a deep link
Expand Down Expand Up @@ -435,6 +475,23 @@
throw new Error("No vault available for signing");
}

// Get the appropriate key manager for signing
const keyManager = await KeyManagerFactory.getKeyManagerForContext(
vault.ename,
"signing",
);

// Ensure the key exists
if (!(await keyManager.exists(vault.ename))) {
await keyManager.generate(vault.ename);
}

// Get the W3ID (public key)
const w3idResult = await keyManager.getPublicKey(vault.ename);
if (!w3idResult) {
throw new Error("Failed to get W3ID");
}

// Create the message to sign based on type
let messageToSign: string;

Expand All @@ -444,7 +501,8 @@
pollId: signingData.pollId,
voteData: signingData.voteData,
userId: signingData.userId,
// Removed timestamp since backend doesn't verify it
sessionId: signingSessionId,
timestamp: Date.now(),
});
} else {
// Generic signature request
Expand All @@ -455,40 +513,23 @@
});
}

// 🔐 REAL CRYPTOGRAPHIC SIGNING using Tauri crypto plugin
console.log("🔐 Starting cryptographic signing process...");

// Check if crypto hardware exists
const cryptoExists = await exists("default");
if (!cryptoExists) {
throw new Error("Cryptographic hardware not available");
}

// Generate default key if it doesn't exist
try {
await generate("default");
console.log("✅ Default key generated/verified");
} catch (error) {
console.log(
"Default key already exists or generation failed:",
error,
);
}

// Get the public key
const publicKey = await getPublicKey("default");
console.log("🔑 Public key retrieved:", publicKey);

// Sign the message payload
// 🔐 REAL CRYPTOGRAPHIC SIGNING using KeyManager factory
console.log(
"🔐 Starting cryptographic signing process with KeyManager...",
);
console.log("✍️ Signing message:", messageToSign);
const signature = await signPayload("default", messageToSign);

const signature = await keyManager.signPayload(
vault.ename,
messageToSign,
);
console.log("✅ Message signed successfully");

// Create the signed payload with real signature
// Create the signed payload with real signature and W3ID
const signedPayload = {
sessionId: signingSessionId,
signature: signature,
publicKey: vault?.ename || "unknown_public_key", // Use eName as public key
w3id: w3idResult,
message: messageToSign,
};

Expand Down Expand Up @@ -644,33 +685,32 @@
throw new Error("No vault available for blind voting");
}

// 🔐 Get the real public key for voter identification
// 🔐 Get the real public key for voter identification using KeyManager
let voterPublicKey: string;
try {
const cryptoExists = await exists("default");
if (!cryptoExists) {
throw new Error("Cryptographic hardware not available");
// Get the appropriate key manager for blind voting
const keyManager =
await KeyManagerFactory.getKeyManagerForContext(
vault.ename,
"signing",
);

// Ensure the key exists
if (!(await keyManager.exists(vault.ename))) {
await keyManager.generate(vault.ename);
}

// Generate default key if it doesn't exist
try {
await generate("default");
console.log(
"✅ Default key generated/verified for blind voting",
);
} catch (edit) {
console.log(
"Default key already exists or generation failed:",
edit,
);
// Get the W3ID (public key)
const w3idResult = await keyManager.getPublicKey(vault.ename);
if (!w3idResult) {
throw new Error("Failed to get W3ID");
}
voterPublicKey = w3idResult;

// Get the public key
voterPublicKey = await getPublicKey("default");
console.log("🔑 Voter public key retrieved:", voterPublicKey);
console.log("🔑 Voter W3ID retrieved:", voterPublicKey);
} catch (error) {
console.error("Failed to get cryptographic public key:", error);
// Fallback to ename if crypto fails
console.error("Failed to get W3ID using KeyManager:", error);
// Fallback to ename if KeyManager fails
voterPublicKey = vault.ename || "unknown_public_key";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export class AuthController {
try {
const { ename, session } = req.body;

console.log(req.body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Remove debug log that may expose sensitive data.

Logging the entire request body (req.body) can expose sensitive information such as user identifiers (ename) and session tokens in production logs, creating compliance risks (GDPR/CCPA violations) and security vulnerabilities if logs are compromised.

Apply this diff to remove the debug log:

-
-            console.log(req.body)
-
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log(req.body)
🤖 Prompt for AI Agents
In platforms/blabsy-w3ds-auth-api/src/controllers/AuthController.ts around line
56, remove the debug console.log(req.body) which can leak sensitive user/session
data; simply delete that logging statement (or replace it with a non-sensitive,
structured audit log if needed—e.g., log only request ID or sanitized fields)
and ensure no other debug prints of full request bodies remain in the
controller.


if (!ename) {
return res.status(400).json({ error: "ename is required" });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Chat = {
type: "direct" | "group"; // Always set by webhook based on participant count
name?: string;
participants: string[];
admins: string[];
ename?: string; // eVault identifier (w3id)
createdAt: Timestamp;
updatedAt: Timestamp;
Expand Down Expand Up @@ -287,6 +288,10 @@ export class WebhookController {
const participants = data.participants.map(
(p: string) => p.split("(")[1].split(")")[0],
) || [];
const admins = (data.admins ?? []).map(
(p: string) => p.split("(")[1].split(")")[0],
) || [];


// Derive type from participant count
const type = participants.length > 2 ? "group" : "direct";
Expand All @@ -301,6 +306,7 @@ export class WebhookController {
name: data.name,
participants,
ename: data.ename || null, // Include eVault identifier if available
admins: admins,
createdAt: data.createdAt
? Timestamp.fromDate(new Date(data.createdAt))
: now,
Expand Down
15 changes: 15 additions & 0 deletions platforms/dreamSync/client/public/W3DS.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 9 additions & 18 deletions platforms/dreamSync/client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { Switch, Route } from "wouter";
import { queryClient } from "./lib/queryClient";
import { QueryClientProvider } from "@tanstack/react-query";
import { AuthProvider } from "./lib/auth-context";
import { Toaster } from "@/components/ui/toaster";
import { TooltipProvider } from "@/components/ui/tooltip";
import { useAuth } from "@/hooks/useAuth";
import { Heart } from "lucide-react";
import NotFound from "@/pages/not-found";
import Login from "@/pages/login";
import Dashboard from "@/pages/dashboard";
import Profile from "@/pages/profile";
import MatchesNew from "@/pages/matches-new";
import Suggestions from "@/pages/suggestions";
import Wishlist from "@/pages/wishlist";
import WishlistItem from "@/pages/wishlist-item";
import WishlistEditor from "@/pages/wishlist-editor";

function Router() {
const { isAuthenticated, isLoading } = useAuth();
Expand All @@ -35,14 +31,7 @@ function Router() {
{!isAuthenticated ? (
<Route path="/" component={Login} />
) : (
<>
<Route path="/" component={Dashboard} />
<Route path="/profile" component={Profile} />
<Route path="/matches" component={MatchesNew} />
<Route path="/suggestions" component={Suggestions} />
<Route path="/wishlist" component={Wishlist} />
<Route path="/wishlist/:id" component={WishlistItem} />
</>
<Route path="/" component={WishlistEditor} />
)}
<Route component={NotFound} />
</Switch>
Expand All @@ -52,10 +41,12 @@ function Router() {
function App() {
return (
<QueryClientProvider client={queryClient}>
<TooltipProvider>
<Toaster />
<Router />
</TooltipProvider>
<AuthProvider>
<TooltipProvider>
<Toaster />
<Router />
</TooltipProvider>
</AuthProvider>
</QueryClientProvider>
);
}
Expand Down
Loading