Compare commits
No commits in common. "0ef94ef5e60ce4c414645aad90c24f670818b0ef" and "16383491b494e05e691334ba1c4d1bb15333f8ea" have entirely different histories.
0ef94ef5e6
...
16383491b4
108
.gitignore
vendored
108
.gitignore
vendored
@ -1,11 +1,19 @@
|
|||||||
# ============================
|
|
||||||
# 4NK Environment - Git Ignore
|
# 4NK Environment - Git Ignore
|
||||||
# ============================
|
# ============================
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# Configuration
|
|
||||||
# ----------------------------
|
|
||||||
confs/
|
confs/
|
||||||
|
# Dossiers de sauvegarde des scripts
|
||||||
|
**/backup/
|
||||||
|
**/*backup*
|
||||||
|
|
||||||
|
**/.cargo/
|
||||||
|
|
||||||
|
# Fichiers temporaires
|
||||||
|
**/*.tmp*
|
||||||
|
**/*.temp*
|
||||||
|
**/*.log*
|
||||||
|
**/*.pid*
|
||||||
|
|
||||||
|
# Fichiers de configuration locale
|
||||||
**/*.env*
|
**/*.env*
|
||||||
**/*.conf*
|
**/*.conf*
|
||||||
**/*.yaml*
|
**/*.yaml*
|
||||||
@ -15,71 +23,57 @@ confs/
|
|||||||
**/*.toml*
|
**/*.toml*
|
||||||
**/*.lock*
|
**/*.lock*
|
||||||
|
|
||||||
# ----------------------------
|
# Données et logs
|
||||||
# Backups
|
|
||||||
# ----------------------------
|
|
||||||
**/backup/
|
|
||||||
**/*backup*
|
|
||||||
**/*wallet*
|
|
||||||
**/*keys*
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# Temporary files & logs
|
|
||||||
# ----------------------------
|
|
||||||
**/*.tmp*
|
|
||||||
**/*.temp*
|
|
||||||
**/*.log*
|
|
||||||
**/*.logs*
|
**/*.logs*
|
||||||
**/*.pid*
|
**/*.data
|
||||||
*.db
|
*.db
|
||||||
*.sqlite
|
*.sqlite
|
||||||
**/*.data
|
|
||||||
|
|
||||||
# ----------------------------
|
# Certificats et clés
|
||||||
# Certificates & keys
|
|
||||||
# ----------------------------
|
|
||||||
ssl/
|
|
||||||
certs/
|
|
||||||
**/*.key
|
**/*.key
|
||||||
**/*.pem
|
**/*.pem
|
||||||
**/*.crt
|
**/*.crt
|
||||||
**/*.p12
|
**/*.p12
|
||||||
**/*.pfx
|
**/*.pfx
|
||||||
|
ssl/
|
||||||
|
certs/
|
||||||
|
|
||||||
# ----------------------------
|
# Docker
|
||||||
# Build / Cache
|
**/*.docker*
|
||||||
# ----------------------------
|
|
||||||
**/node_modules/
|
# Cache et build
|
||||||
**/dist/
|
**/*.node_modules/
|
||||||
**/build/
|
**/*.dist/
|
||||||
**/target/
|
**/*build/
|
||||||
package-lock.json
|
**/*target/
|
||||||
**/*.o
|
**/*.*.o
|
||||||
**/*.so
|
**/*.so
|
||||||
**/*.dylib
|
**/*.dylib
|
||||||
|
|
||||||
# ----------------------------
|
# IDE et éditeurs
|
||||||
# IDE / Editors
|
**/*.vscode/
|
||||||
# ----------------------------
|
**/*.idea/
|
||||||
.vscode/
|
**/*.swp
|
||||||
.idea/
|
**/*.swo
|
||||||
*.swp
|
**/*~
|
||||||
*.swo
|
|
||||||
*~
|
|
||||||
|
|
||||||
# ----------------------------
|
# OS
|
||||||
# OS files
|
**/*.DS_Store
|
||||||
# ----------------------------
|
**/*Thumbs.db
|
||||||
.DS_Store
|
**/*tmp*
|
||||||
Thumbs.db
|
|
||||||
*tmp*
|
|
||||||
|
|
||||||
# ----------------------------
|
# Git
|
||||||
# Docker
|
**/*.git/
|
||||||
# ----------------------------
|
**/*.orig*
|
||||||
**/*.docker*
|
|
||||||
|
|
||||||
# ----------------------------
|
# Backup des projets existants
|
||||||
# Git internals
|
**/*backup*
|
||||||
# ----------------------------
|
|
||||||
*.orig
|
|
||||||
|
**/*wallet*
|
||||||
|
**/*keys*
|
||||||
|
|
||||||
|
**/*node_modules*
|
||||||
|
**/*cursor*
|
||||||
|
**/*pid*
|
||||||
|
**/*next*
|
||||||
3155
package-lock.json
generated
Normal file
3155
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
72
src/App.tsx
72
src/App.tsx
@ -7,7 +7,7 @@ import ProfileModal from './components/ProfileModal'
|
|||||||
import AuthModal from './sdk/AuthModal';
|
import AuthModal from './sdk/AuthModal';
|
||||||
import MessageBus from './sdk/MessageBus';
|
import MessageBus from './sdk/MessageBus';
|
||||||
import EventBus from './sdk/EventBus';
|
import EventBus from './sdk/EventBus';
|
||||||
import UserStore from './sdk/UserStore';
|
import UserStore from './sdk/UserStrore';
|
||||||
import Iframe from './sdk/Iframe'
|
import Iframe from './sdk/Iframe'
|
||||||
import BlockchainViewer from './components/ProcessesViewer';
|
import BlockchainViewer from './components/ProcessesViewer';
|
||||||
import FolderModal from './components/FolderModal';
|
import FolderModal from './components/FolderModal';
|
||||||
@ -27,55 +27,47 @@ function App() {
|
|||||||
const [userPairingId, setUserPairingId] = useState<string | null>(null)
|
const [userPairingId, setUserPairingId] = useState<string | null>(null)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Met à jour la connexion au montage
|
|
||||||
setIsConnected(UserStore.getInstance().isConnected());
|
setIsConnected(UserStore.getInstance().isConnected());
|
||||||
}, []);
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Charge le pairingId s’il existe déjà
|
|
||||||
setUserPairingId(UserStore.getInstance().getUserPairingId());
|
setUserPairingId(UserStore.getInstance().getUserPairingId());
|
||||||
}, []);
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleConnectionFlow = async () => {
|
if (isConnected) {
|
||||||
if (!isConnected) return;
|
|
||||||
|
|
||||||
const userStore = UserStore.getInstance();
|
|
||||||
const messageBus = MessageBus.getInstance(iframeUrl);
|
const messageBus = MessageBus.getInstance(iframeUrl);
|
||||||
|
messageBus.isReady().then(() => {
|
||||||
try {
|
messageBus.getProcesses().then((processes: any) => {
|
||||||
await messageBus.isReady();
|
|
||||||
|
|
||||||
let pairingId = userStore.getUserPairingId();
|
|
||||||
|
|
||||||
// 1️⃣ Créer le pairing si non existant
|
|
||||||
if (!pairingId) {
|
|
||||||
console.log("🚀 No pairing found — creating new pairing...");
|
|
||||||
pairingId = await messageBus.createUserPairing();
|
|
||||||
console.log("✅ Pairing created:", pairingId);
|
|
||||||
|
|
||||||
userStore.pair(pairingId);
|
|
||||||
setUserPairingId(pairingId);
|
|
||||||
} else {
|
|
||||||
console.log("🔗 Already paired with ID:", pairingId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2️⃣ Charger les processes
|
|
||||||
const processes = await messageBus.getProcesses();
|
|
||||||
setProcesses(processes);
|
setProcesses(processes);
|
||||||
|
});
|
||||||
// 3️⃣ Charger les myProcesses
|
});
|
||||||
const myProcesses = await messageBus.getMyProcesses();
|
|
||||||
setMyProcesses(myProcesses);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
console.error("❌ Error during pairing or process loading:", err);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
handleConnectionFlow();
|
|
||||||
}, [isConnected, iframeUrl]);
|
}, [isConnected, iframeUrl]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isConnected && processes !== null) {
|
||||||
|
const messageBus = MessageBus.getInstance(iframeUrl);
|
||||||
|
messageBus.isReady().then(() => {
|
||||||
|
messageBus.getMyProcesses().then((res: string[]) => {
|
||||||
|
setMyProcesses(res);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [isConnected, processes]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isConnected && userPairingId === null) {
|
||||||
|
const messageBus = MessageBus.getInstance(iframeUrl);
|
||||||
|
messageBus.isReady().then(() => {
|
||||||
|
messageBus.getUserPairingId().then((userPairingId: string) => {
|
||||||
|
UserStore.getInstance().pair(userPairingId);
|
||||||
|
setUserPairingId(UserStore.getInstance().getUserPairingId());
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [isConnected, userPairingId, processes]);
|
||||||
|
|
||||||
// Gestionnaire pour afficher la modale de connexion
|
// Gestionnaire pour afficher la modale de connexion
|
||||||
const handleLogin = useCallback(() => {
|
const handleLogin = useCallback(() => {
|
||||||
// Afficher la modale de connexion
|
// Afficher la modale de connexion
|
||||||
@ -197,7 +189,7 @@ function App() {
|
|||||||
{/* Espace pour contenu supplémentaire à droite */}
|
{/* Espace pour contenu supplémentaire à droite */}
|
||||||
<div className="content-area">
|
<div className="content-area">
|
||||||
{/* Affichage des blocs de la blockchain */}
|
{/* Affichage des blocs de la blockchain */}
|
||||||
<BlockchainViewer processes={processes} myProcesses={myProcesses} onProcessesUpdate={setProcesses} />
|
<BlockchainViewer processes={processes} myProcesses={myProcesses} onProcessesUpdate={setProcesses}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import IframeReference from './IframeReference';
|
import IframeReference from './IframeReference';
|
||||||
import EventBus from './EventBus';
|
import EventBus from './EventBus';
|
||||||
import UserStore from './UserStore';
|
import UserStore from './UserStrore';
|
||||||
import { isProfileData, type ProfileCreated, type ProfileData } from './models/ProfileData';
|
import { isProfileData, type ProfileCreated, type ProfileData } from './models/ProfileData';
|
||||||
import { isFolderData, type FolderCreated, type FolderData } from './models/FolderData';
|
import { isFolderData, type FolderCreated, type FolderData } from './models/FolderData';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
@ -80,48 +80,6 @@ export default class MessageBus {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public createUserPairing(): Promise<string> {
|
|
||||||
return new Promise<string>((resolve, reject) => {
|
|
||||||
this.checkToken().then(async () => {
|
|
||||||
const userStore = UserStore.getInstance();
|
|
||||||
const accessToken = userStore.getAccessToken();
|
|
||||||
if (!accessToken) {
|
|
||||||
return reject('No access token found');
|
|
||||||
}
|
|
||||||
|
|
||||||
const correlationId = uuidv4();
|
|
||||||
this.initMessageListener(correlationId);
|
|
||||||
|
|
||||||
// ✅ Success listener
|
|
||||||
const unsubscribeSuccess = EventBus.getInstance().on('PAIRING_CREATED', (responseId: string, pairingId: string) => {
|
|
||||||
if (responseId !== correlationId) return;
|
|
||||||
unsubscribeSuccess();
|
|
||||||
unsubscribeError();
|
|
||||||
this.destroyMessageListener();
|
|
||||||
resolve(pairingId);
|
|
||||||
});
|
|
||||||
|
|
||||||
// ❌ Error listener
|
|
||||||
const unsubscribeError = EventBus.getInstance().on('ERROR_CREATE_PAIRING', (responseId: string, error: string) => {
|
|
||||||
if (responseId !== correlationId) return;
|
|
||||||
unsubscribeError();
|
|
||||||
unsubscribeSuccess();
|
|
||||||
this.destroyMessageListener();
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 📨 Send CREATE_PAIRING message to iframe
|
|
||||||
this.sendMessage({
|
|
||||||
type: 'CREATE_PAIRING',
|
|
||||||
accessToken,
|
|
||||||
messageId: correlationId,
|
|
||||||
});
|
|
||||||
}).catch((err) => {
|
|
||||||
reject(`Failed to validate token before pairing: ${err}`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public getUserPairingId(): Promise<string> {
|
public getUserPairingId(): Promise<string> {
|
||||||
return new Promise<string>((resolve: (userPairingId: string) => void, reject: (error: string) => void) => {
|
return new Promise<string>((resolve: (userPairingId: string) => void, reject: (error: string) => void) => {
|
||||||
this.checkToken().then(() => {
|
this.checkToken().then(() => {
|
||||||
@ -782,17 +740,6 @@ export default class MessageBus {
|
|||||||
EventBus.getInstance().emit('PUBLIC_DATA_DECODED', correlationId, message.decodedData);
|
EventBus.getInstance().emit('PUBLIC_DATA_DECODED', correlationId, message.decodedData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PAIRING_CREATED':
|
|
||||||
if (this.errors[correlationId]) {
|
|
||||||
const error = this.errors[correlationId];
|
|
||||||
delete this.errors[correlationId];
|
|
||||||
EventBus.getInstance().emit('ERROR_PAIRING_CREATED', correlationId, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
EventBus.getInstance().emit('MESSAGE_RECEIVED', message);
|
|
||||||
EventBus.getInstance().emit('PAIRING_CREATED', correlationId, message.decodedData);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'ERROR':
|
case 'ERROR':
|
||||||
console.error('Error:', message);
|
console.error('Error:', message);
|
||||||
this.errors[correlationId] = message.error;
|
this.errors[correlationId] = message.error;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user