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
+25 -12
View File
@@ -5,10 +5,10 @@
<!-- Header -->
<div v-if="!generatedDid" class="text-center flex-shrink-0">
<h1 class="text-[26px] font-semibold text-white/96 mb-6 drop-shadow-[0_2px_6px_rgba(0,0,0,0.4)]">
Take control of your new identity
Your node's identity
</h1>
<p class="text-[20px] text-white/75 leading-relaxed max-w-[600px] mx-auto mb-6">
Generate a Decentralized Identifier (DID) for secure, passwordless authentication. Your identity, your control.
Your node has a Decentralized Identifier (DID) for secure, passwordless authentication. Retrieve it to continue.
</p>
</div>
@@ -16,20 +16,20 @@
<div class="flex flex-col items-center gap-6 mb-6">
<!-- Error message -->
<p v-if="errorMessage" class="text-red-400 text-sm mb-4">{{ errorMessage }}</p>
<!-- Generate Button (if no DID yet) -->
<!-- Fetch Button (if no DID yet) -->
<button
v-if="!generatedDid"
@click="generateDid"
@click="fetchDid"
:disabled="isGenerating"
class="path-action-button path-action-button--continue"
>
<span v-if="!isGenerating">Generate DID</span>
<span v-if="!isGenerating">Retrieve DID</span>
<span v-else class="flex items-center gap-2">
<svg class="animate-spin h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
Generating...
Retrieving...
</span>
</button>
@@ -45,7 +45,7 @@
</div>
</div>
<p class="text-[20px] text-white/80 leading-relaxed max-w-[600px] mx-auto mb-6">
Your decentralized identifier has been generated
Your node's decentralized identifier
</p>
</div>
@@ -59,7 +59,7 @@
</p>
</div>
<p class="text-base text-white/60">
This identifier is stored securely on your device
This identifier is stored securely on your node
</p>
</div>
</div>
@@ -88,7 +88,7 @@
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { rpcClient } from '@/api/rpc-client'
@@ -97,7 +97,13 @@ const generatedDid = ref<string>('')
const isGenerating = ref(false)
const errorMessage = ref<string>('')
async function generateDid() {
/** Store DID state with proper kid (DID#key-1 per W3C) */
function storeDidState(did: string, pubkey: string) {
localStorage.setItem('neode_did', did)
localStorage.setItem('neode_did_state', JSON.stringify({ did, kid: `${did}#key-1`, pubkey }))
}
async function fetchDid() {
isGenerating.value = true
errorMessage.value = ''
@@ -105,8 +111,7 @@ async function generateDid() {
try {
const { did, pubkey } = await rpcClient.getNodeDid()
generatedDid.value = did
localStorage.setItem('neode_did', did)
localStorage.setItem('neode_did_state', JSON.stringify({ did, kid: pubkey }))
storeDidState(did, pubkey)
break
} catch (err) {
errorMessage.value = err instanceof Error ? err.message : 'Server unavailable. Retrying...'
@@ -120,6 +125,14 @@ async function generateDid() {
isGenerating.value = false
}
onMounted(() => {
// Auto-fetch if identity may already exist (e.g. returning to this step)
const cached = localStorage.getItem('neode_did')
if (cached && !cached.includes('...')) {
generatedDid.value = cached
}
})
function proceed() {
if (generatedDid.value && !generatedDid.value.includes('...')) {
router.push('/onboarding/backup').catch(() => {})