7
0
forked from yvv/decision

Auth Duniter v2 : vérification réelle + extension signing + titres outils
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Backend :
- Vérification Sr25519/Ed25519 réelle via substrateinterface (bypass démo)
- Message signé : <Bytes>{challenge}</Bytes> (convention polkadot.js)
- DEV_PROFILES : Charlie → Référent structure, Dave → Auteur (WoT member)

Frontend :
- Signing via extension polkadot.js / Cesium2 (_signWithExtension)
- @polkadot/extension-dapp + @polkadot/util installés
- Vite : global=globalThis + optimizeDeps pour les packages polkadot
- Boîte à outils : titres complets des 4 sections

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Yvv
2026-03-24 03:36:51 +01:00
parent 02629c4e68
commit 224e5b0f5e
6 changed files with 2831 additions and 24 deletions

View File

@@ -23,7 +23,7 @@ interface ToolSection {
const sections: ToolSection[] = [
{
key: 'documents',
title: 'Documents',
title: 'Documents de référence',
icon: 'i-lucide-book-open',
color: 'var(--mood-accent)',
tools: [
@@ -36,7 +36,7 @@ const sections: ToolSection[] = [
},
{
key: 'decisions',
title: 'Décisions',
title: 'Décisions et consultation d\'avis',
icon: 'i-lucide-scale',
color: 'var(--mood-secondary, var(--mood-accent))',
tools: [
@@ -49,7 +49,7 @@ const sections: ToolSection[] = [
},
{
key: 'mandats',
title: 'Mandats',
title: 'Mandats et nominations',
icon: 'i-lucide-user-check',
color: 'var(--mood-success)',
tools: [
@@ -61,7 +61,7 @@ const sections: ToolSection[] = [
},
{
key: 'protocoles',
title: 'Protocoles',
title: 'Protocoles et fonctionnement',
icon: 'i-lucide-settings',
color: 'var(--mood-tertiary, var(--mood-accent))',
tools: [

View File

@@ -5,6 +5,40 @@
* The identity object mirrors the backend IdentityOut schema.
*/
/**
* Sign a challenge using the injected Duniter/Substrate wallet extension
* (Cesium2, polkadot.js extension, Talisman, etc.).
*
* The extension signs <Bytes>{challenge}</Bytes> to match the backend verifier.
*/
async function _signWithExtension(address: string, challenge: string): Promise<string> {
const { web3Enable, web3FromAddress } = await import('@polkadot/extension-dapp')
const { stringToHex } = await import('@polkadot/util')
const extensions = await web3Enable('libreDecision')
if (!extensions.length) {
throw new Error('Aucune extension Duniter détectée. Installez Cesium² ou Polkadot.js.')
}
let injector
try {
injector = await web3FromAddress(address)
} catch {
throw new Error(`Adresse ${address.slice(0, 10)}… introuvable dans l'extension.`)
}
if (!injector.signer?.signRaw) {
throw new Error("L'extension ne supporte pas la signature de messages bruts.")
}
const { signature } = await injector.signer.signRaw({
address,
data: stringToHex(challenge),
type: 'bytes',
})
return signature
}
export interface DuniterIdentity {
id: string
address: string
@@ -65,15 +99,12 @@ export const useAuthStore = defineStore('auth', {
},
)
// Step 2: Sign the challenge
// In production, signFn would use the Duniter keypair to produce an Ed25519 signature.
// For development, we use a placeholder signature.
// Step 2: Sign the challenge via polkadot.js / Cesium2 extension
let signature: string
if (signFn) {
signature = await signFn(challengeRes.challenge)
} else {
// Development placeholder -- backend currently accepts any signature
signature = 'dev_signature_placeholder'
signature = await _signWithExtension(address, challengeRes.challenge)
}
// Step 3: Verify and get token

View File

@@ -45,4 +45,13 @@ export default defineNuxtConfig({
nitro: {
compressPublicAssets: true,
},
vite: {
define: {
// Polkadot packages expect a Node-like global
global: 'globalThis',
},
optimizeDeps: {
include: ['@polkadot/extension-dapp', '@polkadot/util'],
},
},
})

File diff suppressed because it is too large Load Diff

View File

@@ -14,6 +14,8 @@
"@nuxt/content": "^3.11.2",
"@nuxt/ui": "^3.1.0",
"@pinia/nuxt": "^0.11.0",
"@polkadot/extension-dapp": "^0.46.9",
"@polkadot/util": "^13.5.9",
"@unocss/nuxt": "^66.6.0",
"@vueuse/nuxt": "^14.2.1",
"nuxt": "^4.3.1",