feat(apk): URL du depot affichee en forme courte + sync password quand le coffre vient de la synchro

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-09-17 17:38:47 +01:00
parent a9618e9395
commit 826b0809aa
2 changed files with 29 additions and 10 deletions
+15 -5
View File
@@ -1622,7 +1622,7 @@ document.addEventListener('click', function (ev) {
// LES REGLAGES. Ils lisent et ecrivent les MEMES champs que l'accueil - la // LES REGLAGES. Ils lisent et ecrivent les MEMES champs que l'accueil - la
// page n'en garde qu'une copie, Delphi reste la seule source. // page n'en garde qu'une copie, Delphi reste la seule source.
function openSettings() { function openSettings() {
document.getElementById('sUrl').value = elUrl.value; document.getElementById('sUrl').value = shortRepoUrl(elUrl.value);
document.getElementById('sTok').value = elTok.value; document.getElementById('sTok').value = elTok.value;
document.getElementById('sPwd').value = elPwd.value; document.getElementById('sPwd').value = elPwd.value;
document.getElementById('sPinNew').value = ''; document.getElementById('sPinNew').value = '';
@@ -1639,6 +1639,13 @@ function openSettings() {
// https://git.example.com/OWNER/REPO (ou .../src/branch/main/FICHIER) devient // https://git.example.com/OWNER/REPO (ou .../src/branch/main/FICHIER) devient
// l'URL de l'API des contenus. Une URL d'API ou d'endpoint PHP passe telle quelle, // l'URL de l'API des contenus. Une URL d'API ou d'endpoint PHP passe telle quelle,
// et une forme non reconnue aussi - Sync dira alors ce qui ne va pas. // et une forme non reconnue aussi - Sync dira alors ce qui ne va pas.
// L'inverse, pour l'affichage : l'URL d'API se relit comme l'adresse du depot.
function shortRepoUrl(u) {
var m = /^(https?:\/\/[^\/]+)\/api\/v1\/repos\/([^\/]+)\/([^\/]+)\/contents\/(.+)$/i.exec(u || '');
if (!m) return u;
return m[1] + '/' + m[2] + '/' + m[3] +
(m[4] === 'vault-sync.json' ? '' : '/src/branch/main/' + m[4]);
}
function normalizeRepoUrl(u) { function normalizeRepoUrl(u) {
u = u.replace(/\s+/g, ''); u = u.replace(/\s+/g, '');
if (!u || /\/api\/v1\/repos\//i.test(u) || /\.php(\?|$)/i.test(u)) return u; if (!u || /\/api\/v1\/repos\//i.test(u) || /\.php(\?|$)/i.test(u)) return u;
@@ -1648,8 +1655,8 @@ function normalizeRepoUrl(u) {
} }
document.getElementById('sSave').addEventListener('click', function () { document.getElementById('sSave').addEventListener('click', function () {
var sUrl = document.getElementById('sUrl'); var sUrl = document.getElementById('sUrl');
sUrl.value = normalizeRepoUrl(sUrl.value); elUrl.value = normalizeRepoUrl(sUrl.value);
elUrl.value = sUrl.value; sUrl.value = shortRepoUrl(elUrl.value);
elTok.value = document.getElementById('sTok').value.trim(); elTok.value = document.getElementById('sTok').value.trim();
elPwd.value = document.getElementById('sPwd').value; elPwd.value = document.getElementById('sPwd').value;
pushConfig(); pushConfig();
@@ -1687,6 +1694,9 @@ document.getElementById('sLog').addEventListener('click', function () {
// verrouillage d'ecran, c'est retirer le code : il faut donc le code courant. // verrouillage d'ecran, c'est retirer le code : il faut donc le code courant.
var unlockMode = 'none', canDeviceLock = false, hasContainer = false; var unlockMode = 'none', canDeviceLock = false, hasContainer = false;
function syncUnlockUi() { function syncUnlockUi() {
var pw = hasContainer ? 'vault password' : 'sync password';
document.getElementById('sModePwd').dataset.label =
pw.charAt(0).toUpperCase() + pw.slice(1) + ' (type it above)';
['device', 'code', 'password'].forEach(function (m) { ['device', 'code', 'password'].forEach(function (m) {
var id = { device: 'sModeDevice', code: 'sModeCode', password: 'sModePwd' }[m]; var id = { device: 'sModeDevice', code: 'sModeCode', password: 'sModePwd' }[m];
var b = document.getElementById(id), on = unlockMode === m; var b = document.getElementById(id), on = unlockMode === m;
@@ -1698,7 +1708,7 @@ function syncUnlockUi() {
document.getElementById('sModeNote').textContent = document.getElementById('sModeNote').textContent =
{ device: 'Now: screen lock. Changing the screen lock or adding a fingerprint never deletes the vault.', { device: 'Now: screen lock. Changing the screen lock or adding a fingerprint never deletes the vault.',
code: 'Now: app code. To go back to the screen lock, type the current code above.', code: 'Now: app code. To go back to the screen lock, type the current code above.',
password: 'Now: vault password. To go back to the screen lock, type it above.', password: 'Now: ' + pw + '. To go back to the screen lock, type it above.',
none: 'Now: no protection - anyone holding the phone unlocked can open the vault.' }[unlockMode] none: 'Now: no protection - anyone holding the phone unlocked can open the vault.' }[unlockMode]
+ (canDeviceLock ? '' : ' This phone has no screen lock.'); + (canDeviceLock ? '' : ' This phone has no screen lock.');
document.getElementById('btnUsePwd').hidden = document.getElementById('btnUsePwd').hidden =
@@ -1716,7 +1726,7 @@ document.getElementById('sModeCode').addEventListener('click', function () {
}); });
document.getElementById('sModePwd').addEventListener('click', function () { document.getElementById('sModePwd').addEventListener('click', function () {
var v = modeField(); var v = modeField();
if (!v) { toast('Type the vault password above first'); return; } if (!v) { toast('Type the ' + (hasContainer ? 'vault' : 'sync') + ' password above first'); return; }
send('pinset?pw=1&c=' + encodeURIComponent(v)); send('pinset?pw=1&c=' + encodeURIComponent(v));
}); });
document.getElementById('sModeDevice').addEventListener('click', function () { document.getElementById('sModeDevice').addEventListener('click', function () {
+14 -5
View File
@@ -341,6 +341,7 @@ type
/// que le proprietaire ne connaitrait pas. /// que le proprietaire ne connaitrait pas.
procedure SetUnlockCode(const ANew: string); procedure SetUnlockCode(const ANew: string);
procedure PushUnlockMode; procedure PushUnlockMode;
function PwdName: string;
/// Va chercher l'icone du site de l'entree ouverte, ou l'efface. /// Va chercher l'icone du site de l'entree ouverte, ou l'efface.
procedure SetEntryIcon(AFetch: Boolean); procedure SetEntryIcon(AFetch: Boolean);
/// Le depot a bouge, ou ne l'a plus : LE DRAPEAU ET SON TEMOIN ENSEMBLE. /// Le depot a bouge, ou ne l'a plus : LE DRAPEAU ET SON TEMOIN ENSEMBLE.
@@ -545,7 +546,7 @@ begin
if LCanOpen then if LCanOpen then
begin begin
if FRecover then if FRecover then
Status('Screen lock changed - type your vault password') Status('Screen lock changed - type your ' + PwdName)
else if VaultNeedsPin then else if VaultNeedsPin then
Status('Vault on this device - unlock code required') Status('Vault on this device - unlock code required')
else if VaultNeedsAuth then else if VaultNeedsAuth then
@@ -1807,7 +1808,7 @@ begin
// que l'utilisateur ne retapera jamais a l'identique. // que l'utilisateur ne retapera jamais a l'identique.
if (Param('pw') = '1') and if (Param('pw') = '1') and
((FPlain = '') or (TNetEncoding.URL.Decode(Param('c')) <> CachePwd)) then ((FPlain = '') or (TNetEncoding.URL.Decode(Param('c')) <> CachePwd)) then
WebCall('PM.toast("Wrong vault password")') WebCall('PM.toast("Wrong ' + PwdName + '")')
else else
SetUnlockCode(TNetEncoding.URL.Decode(Param('c'))); SetUnlockCode(TNetEncoding.URL.Decode(Param('c')));
end end
@@ -2304,7 +2305,7 @@ begin
begin begin
Log('Recovery copy did not open under this password'); Log('Recovery copy did not open under this password');
ShowUnlock; ShowUnlock;
StatusErr('Wrong vault password'); StatusErr('Wrong ' + PwdName);
WebCall('PM.focusPin()'); WebCall('PM.focusPin()');
Exit; Exit;
end; end;
@@ -2315,7 +2316,7 @@ begin
FRecover := True; FRecover := True;
Log('Screen lock key destroyed - recovery copy available'); Log('Screen lock key destroyed - recovery copy available');
ShowUnlock; ShowUnlock;
StatusErr('Screen lock changed - type your vault password'); StatusErr('Screen lock changed - type your ' + PwdName);
WebCall('PM.focusPin()'); WebCall('PM.focusPin()');
Exit; Exit;
end; end;
@@ -2380,7 +2381,7 @@ begin
begin begin
if FPin = '' then if FPin = '' then
begin begin
StatusErr('Screen lock changed - type your vault password'); StatusErr('Screen lock changed - type your ' + PwdName);
WebCall('PM.focusPin()'); WebCall('PM.focusPin()');
Exit; Exit;
end; end;
@@ -3188,6 +3189,14 @@ begin
LowerCase(BoolToStr(HasLocalContainer, True))])); LowerCase(BoolToStr(HasLocalContainer, True))]));
end; end;
/// LE BON NOM POUR LE MOT DE PASSE QUI OUVRE CE COFFRE. Un coffre venu de la
/// synchro s'ouvre au mot de passe de synchro ; l'appeler "vault password"
/// envoyait chercher un mot de passe qui n'existe pas.
function TForm8.PwdName: string;
begin
if HasLocalContainer then Result := 'vault password' else Result := 'sync password';
end;
function TForm8.CachePwd: string; function TForm8.CachePwd: string;
begin begin
if HasLocalContainer then Result := FVaultPwd else Result := FSyncPwd; if HasLocalContainer then Result := FVaultPwd else Result := FSyncPwd;