Implement onboarding reset functionality and enhance backup features

- Added a new method to reset the onboarding state, allowing users to re-initiate the onboarding process.
- Integrated backup creation functionality, enabling users to create encrypted backups of their node identity.
- Updated API endpoints to handle onboarding reset and backup creation requests.
- Enhanced UI components to support the new onboarding reset and backup features, including error handling and user feedback.
- Introduced new dependencies for cryptographic operations and data encoding.
This commit is contained in:
Dorian
2026-03-02 08:34:13 +00:00
parent 94eb1e4283
commit 62d6c13764
23 changed files with 559 additions and 88 deletions
+20 -16
View File
@@ -14,6 +14,7 @@
<!-- Content Area -->
<div class="flex flex-col items-center gap-6 mb-6">
<p v-if="errorMessage" class="text-red-400 text-sm">{{ errorMessage }}</p>
<!-- Sign Button (if not verified yet) -->
<button
v-if="!verified"
@@ -84,32 +85,35 @@
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { completeOnboarding } from '@/composables/useOnboarding'
import { rpcClient } from '@/api/rpc-client'
const router = useRouter()
const verified = ref(false)
const isSigning = ref(false)
const signature = ref('')
const errorMessage = ref('')
/** Generate a cryptographically random challenge (32 bytes, base64) */
function generateChallenge(): string {
const bytes = new Uint8Array(32)
crypto.getRandomValues(bytes)
return btoa(String.fromCharCode(...bytes))
}
async function signChallenge() {
isSigning.value = true
errorMessage.value = ''
// Simulate signing challenge
await new Promise(resolve => setTimeout(resolve, 1500))
const mockSignature = generateMockSignature()
signature.value = mockSignature
verified.value = true
isSigning.value = false
}
function generateMockSignature(): string {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
let result = ''
for (let i = 0; i < 128; i++) {
result += chars.charAt(Math.floor(Math.random() * chars.length))
try {
const challenge = generateChallenge()
const { signature: sig } = await rpcClient.signChallenge(challenge)
signature.value = sig
verified.value = true
} catch (err) {
errorMessage.value = err instanceof Error ? err.message : 'Failed to sign challenge. Please try again.'
} finally {
isSigning.value = false
}
return result
}
async function proceed() {