build: fix ihm_client build (config import Vite); bump 1.1.1; update CHANGELOG (docker-support-v2)
This commit is contained in:
parent
b9580c0113
commit
7e3d160d5c
@ -1,3 +1,4 @@
|
|||||||
|
## 1.1.1 - Correction build (config Vite) pour docker-support-v2
|
||||||
# Changelog - ihm_client
|
# Changelog - ihm_client
|
||||||
|
|
||||||
Tous les changements notables de ce projet seront documentés dans ce fichier.
|
Tous les changements notables de ce projet seront documentés dans ce fichier.
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "sdk_client",
|
"name": "sdk_client",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sdk_client",
|
"name": "sdk_client",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/elements": "^19.0.1",
|
"@angular/elements": "^19.0.1",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sdk_client",
|
"name": "sdk_client",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
7
src/config.ts
Normal file
7
src/config.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export const config = {
|
||||||
|
api: {
|
||||||
|
baseUrl: (import.meta as any).env?.VITE_BASE_URL || process.env.VITE_BASE_URL || 'http://localhost'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
@ -6,6 +6,7 @@ import ModalService from './modal.service';
|
|||||||
import Database from './database.service';
|
import Database from './database.service';
|
||||||
import { navigate } from '../router';
|
import { navigate } from '../router';
|
||||||
import { storeData, retrieveData, testData } from './storage.service';
|
import { storeData, retrieveData, testData } from './storage.service';
|
||||||
|
import config from '../config';
|
||||||
import { BackUp } from '~/models/backup.model';
|
import { BackUp } from '~/models/backup.model';
|
||||||
|
|
||||||
export const U32_MAX = 4294967295;
|
export const U32_MAX = 4294967295;
|
||||||
@ -87,7 +88,7 @@ export default class Services {
|
|||||||
*/
|
*/
|
||||||
public async connectAllRelays(): Promise<void> {
|
public async connectAllRelays(): Promise<void> {
|
||||||
const connectedUrls: string[] = [];
|
const connectedUrls: string[] = [];
|
||||||
|
|
||||||
// Connect to all relays
|
// Connect to all relays
|
||||||
for (const wsurl of Object.keys(this.relayAddresses)) {
|
for (const wsurl of Object.keys(this.relayAddresses)) {
|
||||||
try {
|
try {
|
||||||
@ -99,7 +100,7 @@ export default class Services {
|
|||||||
console.error(`Failed to connect to ${wsurl}:`, error);
|
console.error(`Failed to connect to ${wsurl}:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for at least one handshake message if we have connections
|
// Wait for at least one handshake message if we have connections
|
||||||
if (connectedUrls.length > 0) {
|
if (connectedUrls.length > 0) {
|
||||||
await this.waitForHandshakeMessage();
|
await this.waitForHandshakeMessage();
|
||||||
@ -343,18 +344,18 @@ export default class Services {
|
|||||||
roles: Record<string, RoleDefinition>,
|
roles: Record<string, RoleDefinition>,
|
||||||
): Promise<ApiReturn> {
|
): Promise<ApiReturn> {
|
||||||
let relayAddress = this.getAllRelays()[0]?.spAddress;
|
let relayAddress = this.getAllRelays()[0]?.spAddress;
|
||||||
|
|
||||||
if (!relayAddress || relayAddress === '') {
|
if (!relayAddress || relayAddress === '') {
|
||||||
console.log('No relay address found, connecting to relays...');
|
console.log('No relay address found, connecting to relays...');
|
||||||
await this.connectAllRelays();
|
await this.connectAllRelays();
|
||||||
|
|
||||||
// After connectAllRelays completes, relay addresses should be updated
|
// After connectAllRelays completes, relay addresses should be updated
|
||||||
relayAddress = this.getAllRelays()[0]?.spAddress;
|
relayAddress = this.getAllRelays()[0]?.spAddress;
|
||||||
if (!relayAddress || relayAddress === '') {
|
if (!relayAddress || relayAddress === '') {
|
||||||
throw new Error('No relay address available after connecting to relays');
|
throw new Error('No relay address available after connecting to relays');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const feeRate = 1;
|
const feeRate = 1;
|
||||||
|
|
||||||
// We can't encode files as the rest because Uint8Array is not valid json
|
// We can't encode files as the rest because Uint8Array is not valid json
|
||||||
@ -362,12 +363,12 @@ export default class Services {
|
|||||||
// TODO encoding of relatively large binaries (=> 1M) is a bit long now and blocking
|
// TODO encoding of relatively large binaries (=> 1M) is a bit long now and blocking
|
||||||
const privateSplitData = this.splitData(privateData);
|
const privateSplitData = this.splitData(privateData);
|
||||||
const publicSplitData = this.splitData(publicData);
|
const publicSplitData = this.splitData(publicData);
|
||||||
const encodedPrivateData = {
|
const encodedPrivateData = {
|
||||||
...this.sdkClient.encode_json(privateSplitData.jsonCompatibleData),
|
...this.sdkClient.encode_json(privateSplitData.jsonCompatibleData),
|
||||||
...this.sdkClient.encode_binary(privateSplitData.binaryData)
|
...this.sdkClient.encode_binary(privateSplitData.binaryData)
|
||||||
};
|
};
|
||||||
const encodedPublicData = {
|
const encodedPublicData = {
|
||||||
...this.sdkClient.encode_json(publicSplitData.jsonCompatibleData),
|
...this.sdkClient.encode_json(publicSplitData.jsonCompatibleData),
|
||||||
...this.sdkClient.encode_binary(publicSplitData.binaryData)
|
...this.sdkClient.encode_binary(publicSplitData.binaryData)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -388,10 +389,10 @@ export default class Services {
|
|||||||
await this.checkConnections([...members]);
|
await this.checkConnections([...members]);
|
||||||
|
|
||||||
const result = this.sdkClient.create_new_process (
|
const result = this.sdkClient.create_new_process (
|
||||||
encodedPrivateData,
|
encodedPrivateData,
|
||||||
roles,
|
roles,
|
||||||
encodedPublicData,
|
encodedPublicData,
|
||||||
relayAddress,
|
relayAddress,
|
||||||
feeRate,
|
feeRate,
|
||||||
this.getAllMembers()
|
this.getAllMembers()
|
||||||
);
|
);
|
||||||
@ -429,12 +430,12 @@ export default class Services {
|
|||||||
await this.checkConnections([...members]);
|
await this.checkConnections([...members]);
|
||||||
const privateSplitData = this.splitData(privateData);
|
const privateSplitData = this.splitData(privateData);
|
||||||
const publicSplitData = this.splitData(publicData);
|
const publicSplitData = this.splitData(publicData);
|
||||||
const encodedPrivateData = {
|
const encodedPrivateData = {
|
||||||
...this.sdkClient.encode_json(privateSplitData.jsonCompatibleData),
|
...this.sdkClient.encode_json(privateSplitData.jsonCompatibleData),
|
||||||
...this.sdkClient.encode_binary(privateSplitData.binaryData)
|
...this.sdkClient.encode_binary(privateSplitData.binaryData)
|
||||||
};
|
};
|
||||||
const encodedPublicData = {
|
const encodedPublicData = {
|
||||||
...this.sdkClient.encode_json(publicSplitData.jsonCompatibleData),
|
...this.sdkClient.encode_json(publicSplitData.jsonCompatibleData),
|
||||||
...this.sdkClient.encode_binary(publicSplitData.binaryData)
|
...this.sdkClient.encode_binary(publicSplitData.binaryData)
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
@ -544,7 +545,7 @@ export default class Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async parseNewTx(newTxMsg: string) {
|
async parseNewTx(newTxMsg: string) {
|
||||||
const parsedMsg: NewTxMessage = JSON.parse(newTxMsg);
|
const parsedMsg: NewTxMessage = JSON.parse(newTxMsg);
|
||||||
if (parsedMsg.error !== null) {
|
if (parsedMsg.error !== null) {
|
||||||
console.error('Received error in new tx message:', parsedMsg.error);
|
console.error('Received error in new tx message:', parsedMsg.error);
|
||||||
return;
|
return;
|
||||||
@ -881,7 +882,7 @@ export default class Services {
|
|||||||
try {
|
try {
|
||||||
const device = await this.getDeviceFromDatabase();
|
const device = await this.getDeviceFromDatabase();
|
||||||
if (device) {
|
if (device) {
|
||||||
const pairedMember = device['paired_member'];
|
const pairedMember = device['paired_member'];
|
||||||
return pairedMember.sp_addresses;
|
return pairedMember.sp_addresses;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@ -1055,7 +1056,7 @@ export default class Services {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Failed to save data to db: ${e}`);
|
console.error(`Failed to save data to db: ${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getBlobFromDb(hash: string): Promise<Blob | null> {
|
public async getBlobFromDb(hash: string): Promise<Blob | null> {
|
||||||
const db = await Database.getInstance();
|
const db = await Database.getInstance();
|
||||||
@ -1184,7 +1185,7 @@ export default class Services {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we can transfer them to memory
|
// Now we can transfer them to memory
|
||||||
await this.restoreSecretsFromDB();
|
await this.restoreSecretsFromDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1225,7 +1226,7 @@ export default class Services {
|
|||||||
if (!key) {
|
if (!key) {
|
||||||
const roles = state.roles;
|
const roles = state.roles;
|
||||||
let hasAccess = false;
|
let hasAccess = false;
|
||||||
// If we're not supposed to have access to this attribute, ignore
|
// If we're not supposed to have access to this attribute, ignore
|
||||||
for (const role of Object.values(roles)) {
|
for (const role of Object.values(roles)) {
|
||||||
for (const rule of Object.values(role.validation_rules)) {
|
for (const rule of Object.values(role.validation_rules)) {
|
||||||
if (rule.fields.includes(attribute)) {
|
if (rule.fields.includes(attribute)) {
|
||||||
@ -1246,7 +1247,7 @@ export default class Services {
|
|||||||
const maxRetries = 5;
|
const maxRetries = 5;
|
||||||
const retryDelay = 500; // delay in milliseconds
|
const retryDelay = 500; // delay in milliseconds
|
||||||
let retries = 0;
|
let retries = 0;
|
||||||
|
|
||||||
while ((!hash || !key) && retries < maxRetries) {
|
while ((!hash || !key) && retries < maxRetries) {
|
||||||
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
||||||
// Re-read hash and key after waiting
|
// Re-read hash and key after waiting
|
||||||
@ -1279,7 +1280,7 @@ export default class Services {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1321,7 +1322,7 @@ export default class Services {
|
|||||||
await this.resetDevice();
|
await this.resetDevice();
|
||||||
|
|
||||||
await this.saveDeviceInDatabase(device);
|
await this.saveDeviceInDatabase(device);
|
||||||
|
|
||||||
this.restoreDevice(device);
|
this.restoreDevice(device);
|
||||||
|
|
||||||
// TODO restore secrets and processes from file
|
// TODO restore secrets and processes from file
|
||||||
@ -1478,7 +1479,7 @@ export default class Services {
|
|||||||
private async waitForHandshakeMessage(timeoutMs: number = 10000): Promise<void> {
|
private async waitForHandshakeMessage(timeoutMs: number = 10000): Promise<void> {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
const pollInterval = 100; // Check every 100ms
|
const pollInterval = 100; // Check every 100ms
|
||||||
|
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
const checkForHandshake = () => {
|
const checkForHandshake = () => {
|
||||||
// Check if we have any members (indicating handshake was received)
|
// Check if we have any members (indicating handshake was received)
|
||||||
@ -1487,17 +1488,17 @@ export default class Services {
|
|||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check timeout
|
// Check timeout
|
||||||
if (Date.now() - startTime >= timeoutMs) {
|
if (Date.now() - startTime >= timeoutMs) {
|
||||||
reject(new Error(`No handshake message received after ${timeoutMs}ms timeout`));
|
reject(new Error(`No handshake message received after ${timeoutMs}ms timeout`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continue polling
|
// Continue polling
|
||||||
setTimeout(checkForHandshake, pollInterval);
|
setTimeout(checkForHandshake, pollInterval);
|
||||||
};
|
};
|
||||||
|
|
||||||
checkForHandshake();
|
checkForHandshake();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1548,7 +1549,7 @@ export default class Services {
|
|||||||
this.sendCommitMessage(JSON.stringify(content));
|
this.sendCommitMessage(JSON.stringify(content));
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
public getRoles(process: Process): Record<string, RoleDefinition> | null {
|
public getRoles(process: Process): Record<string, RoleDefinition> | null {
|
||||||
const lastCommitedState = this.getLastCommitedState(process);
|
const lastCommitedState = this.getLastCommitedState(process);
|
||||||
if (lastCommitedState && lastCommitedState.roles && Object.keys(lastCommitedState.roles).length != 0) {
|
if (lastCommitedState && lastCommitedState.roles && Object.keys(lastCommitedState.roles).length != 0) {
|
||||||
@ -1728,7 +1729,7 @@ export default class Services {
|
|||||||
return process.states[index + 1];
|
return process.states[index + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public isPairingProcess(roles: Record<string, RoleDefinition>): boolean {
|
public isPairingProcess(roles: Record<string, RoleDefinition>): boolean {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user