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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

162 changes: 118 additions & 44 deletions infrastructure/eid-wallet/src/routes/(app)/settings/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,47 +1,100 @@
<script lang="ts">
import { goto } from "$app/navigation";
import { SettingsNavigationBtn } from "$lib/fragments";
import type { GlobalState } from "$lib/global";
import { runtime } from "$lib/global/runtime.svelte";
import { ButtonAction, Drawer } from "$lib/ui";
import {
Key01Icon,
LanguageSquareIcon,
Link02Icon,
PinCodeIcon,
Shield01Icon,
} from "@hugeicons/core-free-icons";
import { getContext } from "svelte";

const globalState = getContext<() => GlobalState>("globalState")();

let isDeleteConfirmationOpen = $state(false);
let isFinalConfirmationOpen = $state(false);

function showDeleteConfirmation() {
isDeleteConfirmationOpen = true;
}

function confirmDelete() {
isDeleteConfirmationOpen = false;
isFinalConfirmationOpen = true;
}

function nukeWallet() {
globalState.userController.user = undefined;
globalState.securityController.clearPin();
isFinalConfirmationOpen = false;
goto("/onboarding");
}

function cancelDelete() {
isDeleteConfirmationOpen = false;
isFinalConfirmationOpen = false;
}

$effect(() => {
runtime.header.title = "Settings";
});
import { goto } from "$app/navigation";
import { SettingsNavigationBtn } from "$lib/fragments";
import type { GlobalState } from "$lib/global";
import { runtime } from "$lib/global/runtime.svelte";
import { ButtonAction, Drawer } from "$lib/ui";
import {
Key01Icon,
LanguageSquareIcon,
Link02Icon,
PinCodeIcon,
Shield01Icon,
} from "@hugeicons/core-free-icons";
import { getContext } from "svelte";

const globalState = getContext<() => GlobalState>("globalState")();

let isDeleteConfirmationOpen = $state(false);
let isFinalConfirmationOpen = $state(false);

// Hidden eVault profile retry functionality
let tapCount = $state(0);
let lastTapTime = $state(0);
let isRetrying = $state(false);
let retryMessage = $state("");

function showDeleteConfirmation() {
isDeleteConfirmationOpen = true;
}

function confirmDelete() {
isDeleteConfirmationOpen = false;
isFinalConfirmationOpen = true;
}

function nukeWallet() {
globalState.userController.user = undefined;
globalState.securityController.clearPin();
isFinalConfirmationOpen = false;
goto("/onboarding");
}

function cancelDelete() {
isDeleteConfirmationOpen = false;
isFinalConfirmationOpen = false;
}

async function handleVersionTap() {
const now = Date.now();

// Reset counter if more than 3 seconds between taps
if (now - lastTapTime > 3000) {
tapCount = 0;
}

tapCount++;
lastTapTime = now;

// Show tap count feedback (only visible to user)
if (tapCount >= 5) {
retryMessage = `Taps: ${tapCount}/10`;
}

// Trigger eVault profile retry after 10 taps
if (tapCount === 10) {
isRetrying = true;
retryMessage = "Retrying eVault profile setup...";

try {
await globalState.vaultController.retryProfileCreation();
retryMessage =
"✅ eVault profile setup completed successfully!";

// Reset after success
setTimeout(() => {
tapCount = 0;
retryMessage = "";
isRetrying = false;
}, 3000);
} catch (error) {
console.error("Failed to retry eVault profile setup:", error);
retryMessage =
"❌ Failed to setup eVault profile. Check console for details.";

// Reset after error
setTimeout(() => {
tapCount = 0;
retryMessage = "";
isRetrying = false;
}, 5000);
}
}
}

$effect(() => {
runtime.header.title = "Settings";
});
</script>

<main>
Expand All @@ -66,7 +119,28 @@ $effect(() => {
>Delete Account</ButtonAction
>

<p class="w-full py-10 text-center">Version v0.1.8.1</p>
<!-- Hidden eVault profile retry - tap version 10 times -->
<div class="w-full py-10 text-center">
<button
class="text-gray-500 hover:text-gray-700 transition-colors cursor-pointer select-none"
on:click={handleVersionTap}
disabled={isRetrying}
>
Version v0.1.8.1
</button>

{#if retryMessage}
<div
class="mt-2 text-sm {isRetrying
? 'text-blue-600'
: retryMessage.includes('✅')
? 'text-green-600'
: 'text-red-600'}"
>
{retryMessage}
</div>
{/if}
</div>
</main>

<!-- First Confirmation Drawer -->
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/evault-core/src/evault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EVault {
this.w3id = process.env.W3ID || null;
const dbService = new DbService(driver);
this.logService = new LogService(driver);
this.graphqlServer = new GraphQLServer(dbService, this.publicKey, this.w3id);
this.graphqlServer = new GraphQLServer(dbService, this.publicKey, this.w3id, this);
this.server = fastify({
logger: true,
});
Expand Down
19 changes: 16 additions & 3 deletions infrastructure/evault-core/src/protocol/graphql-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ export class GraphQLServer {
server?: Server;
private evaultPublicKey: string | null;
private evaultW3ID: string | null;
private evaultInstance: any; // Reference to the eVault instance

constructor(db: DbService, evaultPublicKey?: string | null, evaultW3ID?: string | null) {
constructor(db: DbService, evaultPublicKey?: string | null, evaultW3ID?: string | null, evaultInstance?: any) {
this.db = db;
this.accessGuard = new VaultAccessGuard(db);
this.evaultPublicKey = evaultPublicKey || process.env.EVAULT_PUBLIC_KEY || null;
this.evaultW3ID = evaultW3ID || process.env.W3ID || null;
this.evaultInstance = evaultInstance;
}

public getSchema(): GraphQLSchema {
Expand Down Expand Up @@ -110,6 +112,17 @@ export class GraphQLServer {
}
}

/**
* Gets the current eVault W3ID dynamically from the eVault instance
* @returns string | null - The current eVault W3ID
*/
private getCurrentEvaultW3ID(): string | null {
if (this.evaultInstance && this.evaultInstance.w3id) {
return this.evaultInstance.w3id;
}
return this.evaultW3ID;
}

init() {
const resolvers = {
JSON: require("graphql-type-json"),
Expand Down Expand Up @@ -170,7 +183,7 @@ export class GraphQLServer {
context.tokenPayload?.platform || null;
const webhookPayload = {
id: result.metaEnvelope.id,
w3id: this.evaultW3ID,
w3id: this.getCurrentEvaultW3ID(),
evaultPublicKey: this.evaultPublicKey,
data: input.payload,
schemaId: input.ontology,
Expand Down Expand Up @@ -228,7 +241,7 @@ export class GraphQLServer {
context.tokenPayload?.platform || null;
const webhookPayload = {
id: id,
w3id: this.evaultW3ID,
w3id: this.getCurrentEvaultW3ID(),
evaultPublicKey: this.evaultPublicKey,
data: input.payload,
schemaId: input.ontology,
Expand Down
2 changes: 2 additions & 0 deletions infrastructure/web3-adapter/src/db/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./mapping.db";
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions infrastructure/web3-adapter/src/db/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions infrastructure/web3-adapter/src/db/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions infrastructure/web3-adapter/src/db/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions infrastructure/web3-adapter/src/db/mapping.db.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export declare class MappingDatabase {
private db;
private runAsync;
private getAsync;
private allAsync;
constructor(dbPath: string);
private initialize;
/**
* Store a mapping between local and global IDs
*/
storeMapping(params: {
localId: string;
globalId: string;
}): Promise<void>;
/**
* Get the global ID for a local ID
*/
getGlobalId(localId: string): Promise<string | null>;
/**
* Get the local ID for a global ID
*/
getLocalId(globalId: string): Promise<string | null>;
/**
* Delete a mapping
*/
deleteMapping(localId: string): Promise<void>;
/**
* Get all mappings
*/
getAllMappings(): Promise<Array<{
localId: string;
globalId: string;
}>>;
/**
* Close the database connection
*/
close(): void;
}
//# sourceMappingURL=mapping.db.d.ts.map
1 change: 1 addition & 0 deletions infrastructure/web3-adapter/src/db/mapping.db.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading