Export du dépôt interne d'Aleop, révision 0936ea1 (fichiers publiés identiques à e46bc12). Paquets construits depuis cette source : - Android : AAB 2026.10.0, code 4 - iPhone : archive 2026.10.0 (18) - Bureau : macOS universel build 13, Windows build 14, MSIX build 15 - Extensions Chrome, Edge et Firefox : 2026.10.0.3
977 lignes
61 KiB
Python
977 lignes
61 KiB
Python
#!/usr/bin/env python3
|
|
"""Adaptations Loksi, GPL-3.0-only. Sources amont épinglées, jamais de patch crypto."""
|
|
import base64
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import re
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tarfile
|
|
|
|
ROOT = Path(__file__).resolve().parent
|
|
CONFIG = json.loads((ROOT / "upstream.json").read_text())
|
|
SOURCE = ROOT / ".cache" / ("clients-" + CONFIG["tag"])
|
|
APP = SOURCE / "apps/browser"
|
|
# Premier tracé de LockIcon amont, présent dans le bundle tant que le dessin y est.
|
|
SIGNATURES = ROOT / ".cache" / "illustrations-amont.json"
|
|
LOKSI_ORIGINE = {
|
|
"fr": "Loksi, par Aleop. Extension de navigateur Bitwarden® modifiée par Aleop, sous licence "
|
|
"GPL v3. Aleop n'est pas affilié à Bitwarden Inc.",
|
|
"en": "Loksi, by Aleop. Bitwarden® browser extension modified by Aleop, under the GPL v3. "
|
|
"Aleop is not affiliated with Bitwarden Inc.",
|
|
}
|
|
LOKSI_AIDE = "https://www.aleop.eu/aide/loksi/"
|
|
LOKSI_PRODUIT = "https://www.aleop.eu/loksi/"
|
|
TEXTES_SERVEUR = {
|
|
"fr": {"loksiConnectingTo": "Connexion sur", "loksiAddressToEnter": "adresse à saisir",
|
|
"loksiVaultTitle": "Votre coffre Loksi",
|
|
"loksiNewClient": "Pas encore client ?", "loksiDiscover": "Découvrir Loksi",
|
|
"loksiVaultAddress": "Nom ou adresse de votre coffre",
|
|
"loksiVaultIntro": "Pour votre première connexion, indiquez votre coffre : remplacez « societe » "
|
|
"par le nom choisi à la commande, ou saisissez une autre adresse.",
|
|
"loksiReplaceCompany": "Remplacez « societe » par le nom de votre coffre.",
|
|
"loksiVaultAddressInvalid": "Saisissez le nom de votre coffre, choisi à la commande : 2 à 20 minuscules ou "
|
|
"chiffres, un tiret possible. Ou une adresse complète qui commence par https://.",
|
|
"loksiNotAVault": "Aucun coffre Loksi ne répond à cette adresse. Vérifiez le nom auprès de "
|
|
"votre administrateur.",
|
|
"selfHostedBaseUrlHint": "Vous pouvez aussi taper seulement le nom, par exemple mon-entreprise."},
|
|
"en": {"loksiConnectingTo": "Logging in to", "loksiAddressToEnter": "address to enter",
|
|
"loksiVaultTitle": "Your Loksi vault",
|
|
"loksiNewClient": "Not a customer yet?", "loksiDiscover": "Discover Loksi",
|
|
"loksiVaultAddress": "Name or address of your vault",
|
|
"loksiVaultIntro": "For your first login, enter your vault: replace \"societe\" with the "
|
|
"name chosen when ordering, or enter another address.",
|
|
"loksiReplaceCompany": "Replace \"societe\" with the name of your vault.",
|
|
"loksiVaultAddressInvalid": "Enter the name of your vault, chosen when ordering: 2 to 20 lowercase "
|
|
"letters or digits, a hyphen allowed. Or a full address starting with https://.",
|
|
"loksiNotAVault": "No Loksi vault answers at this address. Check the name with your "
|
|
"administrator.",
|
|
"selfHostedBaseUrlHint": "You can also type the name only, for example my-company."},
|
|
}
|
|
UNSET = CONFIG["unset_server"]
|
|
MODELE_COFFRE = "https://societe.loksi.fr"
|
|
LOKSI_CONFIDENTIALITE = "https://www.aleop.eu/loksi/confidentialite/"
|
|
LOKSI_SUPPORT = "support@aleop.eu"
|
|
# Source GPL publiée de Loksi, citée par chaque appli avant les envois aux magasins
|
|
# (Romain, 12/10/2026).
|
|
LOKSI_SOURCE = "https://sources.gitsi.dev/aleop/loksi"
|
|
ABOUT_WEB_VAULT = """ <bit-item>
|
|
<button type="button" bit-item-content (click)="openWebVault()">"""
|
|
ABOUT_LOKSI = """ <bit-item>
|
|
<button type="button" bit-item-content (click)="launchPrivacy()">
|
|
{{ "privacyPolicy" | i18n }}
|
|
<i slot="end" class="bwi bwi-external-link" aria-hidden="true"></i>
|
|
</button>
|
|
</bit-item>
|
|
<bit-item>
|
|
<button type="button" bit-item-content (click)="contactSupport()">
|
|
{{ "loksiContactUs" | i18n }}
|
|
<i slot="end" class="bwi bwi-envelope" aria-hidden="true"></i>
|
|
</button>
|
|
</bit-item>
|
|
<bit-item>
|
|
<button type="button" bit-item-content (click)="launchSource()">
|
|
{{ "loksiSourceCode" | i18n }}
|
|
<i slot="end" class="bwi bwi-external-link" aria-hidden="true"></i>
|
|
</button>
|
|
</bit-item>
|
|
"""
|
|
ABOUT_METHODES = """ async launchPrivacy() {
|
|
await BrowserApi.createNewTab("https://www.aleop.eu/loksi/confidentialite/");
|
|
}
|
|
|
|
async launchSource() {
|
|
const confirmed = await this.dialogService.openSimpleDialog({
|
|
title: { key: "loksiSourceTitle" },
|
|
content: { key: "loksiSourceDesc" },
|
|
type: "info",
|
|
acceptButtonText: { key: "continue" },
|
|
});
|
|
if (confirmed) {
|
|
await BrowserApi.createNewTab("https://sources.gitsi.dev/aleop/loksi");
|
|
}
|
|
}
|
|
|
|
async contactSupport() {
|
|
const confirmed = await this.dialogService.openSimpleDialog({
|
|
title: { key: "loksiEmailSupport" },
|
|
content: { key: "loksiEmailSupportDesc" },
|
|
type: "info",
|
|
acceptButtonText: { key: "continue" },
|
|
});
|
|
if (confirmed) {
|
|
this.platformUtilsService.launchUri("mailto:support@aleop.eu");
|
|
}
|
|
}
|
|
|
|
"""
|
|
# Textes où Bitwarden reste : mention d'origine, produit tiers cité comme tel, et textes
|
|
# des seules pages « Plus de Bitwarden », « Télécharger les applications Bitwarden »,
|
|
# aide et note du magasin, dont prepare retire l'accès.
|
|
BITWARDEN_GARDE = {
|
|
"loksiAboutOrigin", "loksiBasedOn", "authenticatorAppDescV2", "moreFromBitwarden", "continueToBitwardenDotCom",
|
|
"bitwardenForBusiness", "bitwardenForBusinessPageDesc", "bitwardenAuthenticator",
|
|
"continueToAuthenticatorPageDesc", "bitwardenSecretsManager", "continueToSecretsManagerPageDesc",
|
|
"continueToPasswordlessDotDevPageDesc", "freeBitwardenFamilies", "freeBitwardenFamiliesPageDesc",
|
|
"continueToBrowserExtensionStoreDesc", "downloadBitwarden",
|
|
"downloadBitwardenOnAllDevices", "getTheMobileAppDesc", "downloadFromBitwardenNow",
|
|
"downloadBitwardenApps", "premiumManageAlert",
|
|
}
|
|
CARROUSEL = {
|
|
"fr": {"introCarouselLabel": "Bienvenue sur Loksi",
|
|
"securityPrioritized": "Les accès de l'équipe, dans un coffre à vous",
|
|
"securityPrioritizedBody": "Identifiants, cartes et notes sont chiffrés sur votre appareil. "
|
|
"Le serveur ne voit jamais vos secrets en clair.",
|
|
"quickLogin": "Connexion en un geste",
|
|
"quickLoginBody": "Le déverrouillage biométrique et le remplissage automatique ouvrent vos "
|
|
"comptes sans rien taper.",
|
|
"secureUser": "Un mot de passe solide pour chaque compte",
|
|
"secureUserBody": "Le générateur les crée, Loksi les retient à votre place.",
|
|
"secureDevices": "Vos secrets, dans votre coffre, en France",
|
|
"secureDevicesBody": "Le même coffre sur votre téléphone, dans votre navigateur "
|
|
"et sur le coffre web de votre entreprise."},
|
|
"en": {"introCarouselLabel": "Welcome to Loksi",
|
|
"securityPrioritized": "Your team's access, in a vault of your own",
|
|
"securityPrioritizedBody": "Logins, cards and notes are encrypted on your device. "
|
|
"The server never sees your secrets in clear text.",
|
|
"quickLogin": "Log in with one gesture",
|
|
"quickLoginBody": "Biometric unlock and autofill open your accounts without typing anything.",
|
|
"secureUser": "A strong password for every account",
|
|
"secureUserBody": "The generator creates them and Loksi remembers them for you.",
|
|
"secureDevices": "Your secrets, in your vault, in France",
|
|
"secureDevicesBody": "The same vault on your phone, in your browser "
|
|
"and on your company's web vault."},
|
|
}
|
|
ONGLETS = ROOT.parent / "brand/illustrations-mobiles/onglets"
|
|
# Couleurs figées des pictogrammes d'onglets iOS (maîtres clairs), rendues aux variables
|
|
# du thème : l'actif suit le bouton (navy, cyan en sombre), le reste bascule par popup.scss.
|
|
ONGLET_COULEURS = {"#003087": "var(--color-fg-brand)", "#009CDE": "var(--loksi-onglet-accent)",
|
|
"#6B7A90": "var(--loksi-onglet-repos)"}
|
|
# Palette Bitwarden remplacée par celle de Loksi, par bloc de tw-theme.css : :root puis
|
|
# .theme_dark. Navy #003087 en clair, cyan #009CDE en sombre, comme les applis mobiles.
|
|
PALETTE = {
|
|
":root {": {
|
|
"--color-background-alt2": "0 48 135", "--color-background-alt3": "0 38 109",
|
|
"--color-background-alt4": "0 21 64",
|
|
"--color-primary-100": "217 240 251", "--color-primary-300": "127 208 241",
|
|
"--color-primary-600": "0 48 135", "--color-primary-700": "0 38 109",
|
|
"--color-hover-default": "rgb(0 48 135 / 0.1)",
|
|
"--color-marketing-logo": "0 48 135", "--color-bw-blue": "0 48 135",
|
|
"--color-illustration-outline": "0 48 135", "--color-illustration-bg-primary": "217 240 251",
|
|
"--color-illustration-bg-secondary": "127 208 241",
|
|
"--color-illustration-tertiary": "0 156 222", "--color-illustration-logo": "0 48 135",
|
|
"--color-brand-050": "#eef8fd", "--color-brand-100": "#d9f0fb", "--color-brand-200": "#b3e2f6",
|
|
"--color-brand-300": "#7fd0f1", "--color-brand-400": "#009cde", "--color-brand-500": "#0079bd",
|
|
"--color-brand-600": "#0a55a6", "--color-brand-700": "#003087",
|
|
"--color-brand-700-rgb": "0, 48, 135", "--color-brand-800": "#00266d",
|
|
"--color-brand-900": "#001d54", "--color-brand-950": "#001540",
|
|
"--color-brand-800-rgb": "0, 38, 109", "--color-brand-950-rgb": "0, 21, 64",
|
|
},
|
|
".theme_dark {": {
|
|
"--color-primary-100": "0 29 84", "--color-primary-300": "0 121 189",
|
|
"--color-primary-600": "0 156 222", "--color-primary-700": "127 208 241",
|
|
"--color-hover-default": "rgb(127 208 241 / 0.1)", "--color-bw-blue": "0 48 135",
|
|
"--color-illustration-outline": "0 156 222", "--color-illustration-bg-primary": "127 208 241",
|
|
"--color-illustration-bg-secondary": "0 121 189",
|
|
"--color-illustration-tertiary": "31 191 245",
|
|
},
|
|
}
|
|
# Fichier amont de libs/assets/src/svg/svgs : export remplacé, maître Loksi.
|
|
# Security et Party ne sont pas affichés dans la popup.
|
|
ILLUSTRATION_TABLE = {
|
|
"lock.icon.ts": ("LockIcon", "verrou"),
|
|
"user-lock.icon.ts": ("UserLockIcon", "verrou"),
|
|
"item-types.ts": ("ItemTypes", "coffre"),
|
|
"vault-open.ts": ("VaultOpen", "coffre"),
|
|
"login-cards.ts": ("LoginCards", "autofill"),
|
|
"no-credentials.icon.ts": ("NoCredentialsIcon", "generateur"),
|
|
"devices.icon.ts": ("DevicesIcon", "appareils"),
|
|
"user-verification-biometrics-fingerprint.icon.ts": ("UserVerificationBiometricsIcon", "biometrie"),
|
|
"no-folders.ts": ("NoFolders", "dossier-vide"),
|
|
"search-folder.ts": ("SearchFolder", "dossier-vide"),
|
|
"no-results.ts": ("NoResults", "recherche-vide"),
|
|
"empty-trash.ts": ("EmptyTrash", "corbeille"),
|
|
"no-send.icon.ts": ("NoSendsIcon", "send"),
|
|
"active-send.icon.ts": ("ActiveSendIcon", "send"),
|
|
"registration-check-email.icon.ts": ("RegistrationCheckEmailIcon", "email"),
|
|
"two-factor-auth-email.icon.ts": ("TwoFactorAuthEmailIcon", "email-code"),
|
|
"two-factor-timeout.icon.ts": ("TwoFactorTimeoutIcon", "delai-expire"),
|
|
"vault.icon.ts": ("VaultIcon", "securite"),
|
|
"deactivated-org.ts": ("DeactivatedOrg", "organisation"),
|
|
"account-warning.icon.ts": ("AccountWarning", "organisation"),
|
|
"domain.icon.ts": ("DomainIcon", "uri-bloquee"),
|
|
}
|
|
ILLUSTRATIONS = ROOT.parent / "brand/illustrations-mobiles/sources"
|
|
|
|
|
|
def write_json(path, value):
|
|
path.write_text(json.dumps(value, indent=2, ensure_ascii=False) + "\n")
|
|
|
|
|
|
def replace_once(path, old, new):
|
|
value = path.read_text()
|
|
if value.count(old) != 1:
|
|
raise RuntimeError(f"Point d'adaptation amont modifié : {path}")
|
|
path.write_text(value.replace(old, new))
|
|
|
|
|
|
def replace_count(path, old, new, expected):
|
|
value = path.read_text()
|
|
if value.count(old) != expected:
|
|
raise RuntimeError(f"Point d'adaptation amont modifié : {path}")
|
|
path.write_text(value.replace(old, new))
|
|
|
|
|
|
def theme_pair(clair, sombre, key):
|
|
"""Dessins clair et sombre de la charte réunis en un seul SVG pour le gabarit svg`...`.
|
|
|
|
L'amont colore ses dessins par classes que .theme_dark redéfinit ; ceux de Loksi
|
|
ont des couleurs en dur, d'où deux dessins dont popup.scss n'affiche qu'un. Les id
|
|
(g1, facestandalone...) se répètent d'un fichier à l'autre : préfixés, sinon un
|
|
dessin affiché irait chercher ses dégradés dans son jumeau masqué.
|
|
"""
|
|
parts = []
|
|
for variant, path in (("clair", clair), ("sombre", sombre)):
|
|
drawing = path.read_text().strip()
|
|
if not drawing.startswith("<svg ") or "`" in drawing or "${" in drawing:
|
|
raise RuntimeError("Dessin Loksi inattendu : " + path.name)
|
|
prefix = "loksi-" + key + "-" + variant + "-"
|
|
drawing = re.sub(r'id="([^"]+)"', lambda m: 'id="' + prefix + m.group(1) + '"', drawing)
|
|
drawing = re.sub(r"url\(#([^)]+)\)", lambda m: "url(#" + prefix + m.group(1) + ")", drawing)
|
|
opening = drawing[:drawing.index(">") + 1]
|
|
tag = re.sub(r' (width|height|role|aria-label)="[^"]*"', "", opening)
|
|
tag = tag.replace("<svg ", '<svg class="loksi-illustration-' + variant + '" data-loksi="' + key + '" ', 1)
|
|
parts.append(tag + drawing[len(opening):])
|
|
return "\n".join(parts)
|
|
|
|
|
|
def illustration(name):
|
|
return theme_pair(ILLUSTRATIONS / (name + "-clair.svg"), ILLUSTRATIONS / (name + "-sombre.svg"), name)
|
|
|
|
|
|
def prepare():
|
|
archive = ROOT / ".cache/upstream.tar.gz"
|
|
if hashlib.sha256(archive.read_bytes()).hexdigest() != CONFIG["archive_sha256"]:
|
|
raise RuntimeError("Archive amont incorrecte : SHA-256 différent")
|
|
# Réextraction des sources originales : adaptations idempotentes, node_modules conservé.
|
|
with tarfile.open(archive) as tar:
|
|
tar.extractall(ROOT / ".cache", filter="data")
|
|
for name in ("manifest.json", "manifest.v3.json"):
|
|
path = APP / "src" / name
|
|
data = json.loads(path.read_text())
|
|
data.update(short_name="Loksi", author="Aleop",
|
|
homepage_url=LOKSI_PRODUIT)
|
|
for key in ("action", "browser_action", "__firefox__sidebar_action", "__opera__sidebar_action"):
|
|
if key in data:
|
|
data[key]["default_title"] = "Loksi"
|
|
gecko = data["__firefox__browser_specific_settings"]["gecko"]
|
|
gecko["id"] = CONFIG["firefox_id"]
|
|
# Déclaration de collecte exigée par AMO pour toute nouvelle extension depuis le
|
|
# 03/11/2025, comprise à partir de Firefox 140. Le courriel et l'empreinte du mot de
|
|
# passe principal partent vers le coffre que l'utilisateur a saisi. Voir STORES.md.
|
|
gecko["strict_min_version"] = CONFIG["firefox_min"]
|
|
gecko["data_collection_permissions"] = CONFIG["firefox_data_collection"]
|
|
data["__firefox__browser_specific_settings"]["gecko_android"] = {"strict_min_version": "142.0"}
|
|
# Numérotation posée dans les sources, pas après webpack : un relecteur qui
|
|
# reconstruit depuis l'archive de sources obtient le même manifeste que le paquet.
|
|
version, build_no = numero()
|
|
data["version"] = version + "." + str(build_no)
|
|
for navigateur in ("chrome", "edge"):
|
|
data["__" + navigateur + "__version_name"] = version + " (" + str(build_no) + ")"
|
|
# Clé publique fixe : même identifiant sur tous les postes, que le bureau Loksi
|
|
# inscrit dans allowed_origins de son manifeste natif.
|
|
data["__" + navigateur + "__key"] = CONFIG["chromium_key"]
|
|
write_json(path, data)
|
|
for path in (APP / "src/_locales").glob("*/messages.json"):
|
|
data = json.loads(path.read_text())
|
|
# Ne pas renommer les produits tiers, mentions légales, liens d'aide ou offres Bitwarden.
|
|
for key in ("appName", "appLogoLabel", "extName", "extNameBeta", "newToBitwarden", "aboutBitwarden",
|
|
"continueToWebAppDesc", "changeMasterPasswordOnWebConfirmation", "bitWebVaultApp",
|
|
"notificationAddDesc", "notificationLoginSaveConfirmation", "notificationLoginUpdatedConfirmation",
|
|
"notificationChangeDesc", "notificationUnlockDesc", "autofillSpotlightDesc",
|
|
"setYourPinCode", "setPinCode", "autofillIframeWarningTip", "topLayerHijackWarning",
|
|
"excludedDomainsDesc", "updateInBitwarden", "couldNotDecryptVaultItemsBelow",
|
|
"bitwardenOverlayButton", "toggleBitwardenVaultOverlay", "bitwardenVault",
|
|
"bitwardenOverlayMenuAvailable", "bitwardenAccount", "uriMatchDefaultStrategyHint",
|
|
"overrideDefaultBrowserAutofillTitle", "overrideDefaultBrowserAutofillDescription",
|
|
"overrideDefaultBrowserAutoFillSettings", "defaultPasswordManagerCalloutDesc",
|
|
"privacyPermissionAdditionNotGrantedTitle", "privacyPermissionAdditionNotGrantedDescription",
|
|
"defaultPasswordManagerPromptTitle", "defaultPasswordManagerPromptTitleV2",
|
|
"defaultPasswordManagerPromptStep2AfterAllow", "defaultPasswordManagerSuccessToast",
|
|
"saveToBitwarden"):
|
|
if key in data:
|
|
data[key]["message"] = data[key]["message"].replace("Bitwarden", "Loksi")
|
|
# Tout le reste dit Loksi, application de bureau comprise (Romain la construit
|
|
# sous ce nom). Restent les textes des pages masquées plus bas et les vrais
|
|
# produits Bitwarden cités comme tels. Formes déclinées comprises (Bitwardenin).
|
|
for key, old_text, new_text in (("emailPlaceholder", "bitwarden.com", "aleop.eu"),
|
|
("emailPlaceholderMultiple", "bitwarden.com", "aleop.eu"),
|
|
("selfHostedBaseUrlHint", "bitwarden.company.com", "loksi.company.com")):
|
|
if key in data:
|
|
data[key]["message"] = data[key]["message"].replace(old_text, new_text)
|
|
for key, value in data.items():
|
|
if key not in BITWARDEN_GARDE and "bitwarden" in value.get("message", "").lower():
|
|
# « le coffre web de bitwarden.com » devient « le coffre web de Loksi ».
|
|
value["message"] = value["message"].replace("bitwarden.com", "Loksi").replace("Bitwarden", "Loksi")
|
|
data["extName"]["message"] = "Loksi"
|
|
# Les autres langues retombent sur « en » (default_locale, TranslationService amont).
|
|
if path.parent.name in ("en", "fr"):
|
|
fr = path.parent.name == "fr"
|
|
for key, text in TEXTES_SERVEUR["fr" if fr else "en"].items():
|
|
data[key] = {"message": text}
|
|
data["loksiContactUs"] = {"message": "Nous contacter" if fr else "Contact us"}
|
|
data["loksiSourceCode"] = {"message": "Code source" if fr else "Source code"}
|
|
# Mêmes textes que l'appli Android (mobile/android/loksi.py, 12/10/2026).
|
|
data["loksiSourceTitle"] = {"message": "Ouvrir le code source ?" if fr else "Open the source code?"}
|
|
data["loksiSourceDesc"] = {"message": (
|
|
"Loksi est un logiciel libre sous licence GPL v3. Son code source est publié sur "
|
|
"sources.gitsi.dev." if fr else
|
|
"Loksi is free software under the GPL v3 licence. Its source code is published on "
|
|
"sources.gitsi.dev.")}
|
|
data["loksiEmailSupport"] = {"message": "Écrire au support ?" if fr else "Email support?"}
|
|
data["loksiEmailSupportDesc"] = {"message": (
|
|
"Votre messagerie s'ouvre avec un courriel pour support@aleop.eu. "
|
|
"Pour la protection des données, écrivez à dpo@aleop.eu." if fr else
|
|
"Your mail app opens with an email to support@aleop.eu. "
|
|
"For data protection, write to dpo@aleop.eu.")}
|
|
# Mention d'origine validée par Romain le 30/09/2026, la même que le coffre web.
|
|
# Le « © Bitwarden Inc. » amont qui suit reste : avis de copyright GPL.
|
|
data["loksiAboutOrigin"] = {"message": LOKSI_ORIGINE["fr" if path.parent.name == "fr" else "en"]}
|
|
data["loksiBasedOn"] = {"message": ("Basé sur Bitwarden " if fr else "Based on Bitwarden ")
|
|
+ CONFIG["tag"].split("-v", 1)[1] + "."}
|
|
# Carrousel d'accueil : les textes du carrousel iOS (mobile/ios/loksi.py), le
|
|
# téléphone devenu l'appareil. Français pour fr, anglais pour toutes les autres.
|
|
for key, text in CARROUSEL["fr" if path.parent.name == "fr" else "en"].items():
|
|
data[key]["message"] = text
|
|
data["extDesc"]["message"] = (
|
|
"Votre coffre Loksi : mots de passe et remplissage automatique."
|
|
if path.parent.name == "fr" else "Your Loksi vault: passwords and autofill."
|
|
)
|
|
write_json(path, data)
|
|
# Page d'accueil ouverte à l'installation : l'aide Loksi, pas un coffre.
|
|
replace_once(APP / "src/platform/services/browser-initial-install.service.ts",
|
|
'https://bitwarden.com/browser-start/', LOKSI_AIDE)
|
|
# Aucun coffre par défaut : chaque client a le sien (décision de Romain du 04/10/2026),
|
|
# comme les applis mobiles et l'appli de bureau. Une politique administrateur (GPO, MDM,
|
|
# policies.json) reste prioritaire : browser-environment.service.ts n'est plus modifié,
|
|
# l'amont n'applique l'environnement géré que s'il existe. Sans rien de saisi,
|
|
# l'extension vise un marqueur en .invalid (RFC 6761) qui ne se résout jamais, au lieu
|
|
# de retomber sur bitwarden.com. Même patch que desktop/loksi.py, server_entry().
|
|
env = SOURCE / "libs/common/src/platform/services/default-environment.service.ts"
|
|
replace_count(env, " if (region == Region.SelfHosted && isEmpty(urls)) {\n region = DEFAULT_REGION;\n }\n",
|
|
" if (region == Region.SelfHosted && isEmpty(urls)) {\n"
|
|
" urls = { base: " + json.dumps(UNSET) + " };\n }\n", 2)
|
|
selector = SOURCE / "libs/angular/src/auth/environment-selector/environment-selector.component"
|
|
html = Path(str(selector) + ".html")
|
|
if html.read_text().count("toggle(ServerEnvironmentType.SelfHosted)") != 1:
|
|
raise RuntimeError("Sélecteur de région amont modifié")
|
|
# « Connexion sur : adresse à saisir », un clic ouvre la saisie. Tant que rien n'est
|
|
# saisi, une ligne pour qui n'est pas encore client renvoie vers la page Loksi.
|
|
html.write_text(
|
|
'<div class="tw-mb-1">\n <div bitTypography="body2">\n'
|
|
' {{ "loksiConnectingTo" | i18n }} :\n'
|
|
' <button type="button" bitLink (click)="toggle(ServerEnvironmentType.SelfHosted)"'
|
|
' data-loksi="serveur">\n'
|
|
' <b class="tw-text-primary-600 tw-font-medium">{{\n'
|
|
' (loksiHost$ | async) || ("loksiAddressToEnter" | i18n)\n }}</b>\n'
|
|
' <bit-icon name="bwi-pencil" class="bwi-fw bwi-sm"></bit-icon>\n'
|
|
' </button>\n </div>\n'
|
|
' @if (!(loksiHost$ | async)) {\n'
|
|
' <div bitTypography="helper" class="tw-mt-2" data-loksi="nouveau-client">\n'
|
|
' {{ "loksiNewClient" | i18n }}\n'
|
|
' <a bitLink href="' + LOKSI_PRODUIT + '" target="_blank" rel="noreferrer">{{\n'
|
|
' "loksiDiscover" | i18n\n }}</a>\n'
|
|
' </div>\n }\n</div>\n')
|
|
ts = Path(str(selector) + ".ts")
|
|
replace_once(ts, " private destroy$ = new Subject<void>();\n",
|
|
" // Loksi : l'adresse du coffre saisi, rien tant que c'est le marqueur.\n"
|
|
" protected loksiHost$: Observable<string | null> = this.environmentService.globalEnvironment$.pipe(\n"
|
|
" map((env) => (env.getUrls().base === " + json.dumps(UNSET) + " ? null : env.getHostname())),\n"
|
|
" );\n\n private destroy$ = new Subject<void>();\n")
|
|
dialog = SOURCE / "libs/angular/src/auth/self-hosted-env-config-dialog/self-hosted-env-config-dialog.component.ts"
|
|
replace_once(dialog, ' baseUrl: urls.base || "",',
|
|
' baseUrl: urls.base === ' + json.dumps(UNSET) + ' ? "" : urls.base || "",')
|
|
replace_once(SOURCE / "libs/angular/src/auth/self-hosted-env-config-dialog/self-hosted-env-config-dialog.component.html",
|
|
"<span bitDialogTitle> Self-hosted environment</span>",
|
|
'<span bitDialogTitle>{{ "loksiVaultTitle" | i18n }}</span>')
|
|
# Code client (étape 2, décision du 04/10/2026) : abc donne https://abc.loksi.fr, une
|
|
# adresse complète en https reste acceptée. Avant d'enregistrer, /api/config doit
|
|
# répondre comme un Vaultwarden. Logique dans extensions/loksi-coffre.ts, testée seule.
|
|
dialog_dir = SOURCE / "libs/angular/src/auth/self-hosted-env-config-dialog"
|
|
shutil.copy2(ROOT / "loksi-coffre.ts", dialog_dir / "loksi-coffre.ts")
|
|
dialog_ts = dialog_dir / "self-hosted-env-config-dialog.component.ts"
|
|
replace_once(dialog_ts, 'import { JslibModule } from "../../jslib.module";\n',
|
|
'import { JslibModule } from "../../jslib.module";\n\n'
|
|
'import { loksiAdresse, loksiEstUnCoffre } from "./loksi-coffre";\n')
|
|
replace_once(dialog_ts,
|
|
' if (url && !url.startsWith("https://") && !platformUtilsService.isDev()) {\n'
|
|
' return {\n onlyHttpsAllowed: {\n'
|
|
' message: i18nService.t("selfHostedEnvMustUseHttps"),\n',
|
|
' if (url && loksiAdresse(url) == null) {\n'
|
|
' return {\n loksiAdresseRefusee: {\n'
|
|
' message: i18nService.t("loksiVaultAddressInvalid"),\n')
|
|
replace_once(dialog_ts, " private destroy$ = new Subject<void>();\n",
|
|
" private destroy$ = new Subject<void>();\n private i18nService = inject(I18nService);\n")
|
|
replace_once(dialog_ts,
|
|
" await this.environmentService.setEnvironment(Region.SelfHosted, {\n"
|
|
" base: this.baseUrl.value,\n",
|
|
" const base = this.baseUrl.value ? loksiAdresse(this.baseUrl.value) : \"\";\n"
|
|
" if (base && !(await loksiEstUnCoffre(base))) {\n"
|
|
" this.baseUrl.setErrors({\n"
|
|
" loksiPasUnCoffre: { message: this.i18nService.t(\"loksiNotAVault\") },\n"
|
|
" });\n return;\n }\n\n"
|
|
" await this.environmentService.setEnvironment(Region.SelfHosted, {\n"
|
|
" base: base,\n")
|
|
replace_once(dialog_dir / "self-hosted-env-config-dialog.component.html",
|
|
' <bit-label>{{ "baseUrl" | i18n }}</bit-label>',
|
|
' <bit-label>{{ "loksiVaultAddress" | i18n }}</bit-label>')
|
|
# Premier lancement (Romain, 09/10/2026) : sur l'écran de connexion, tant qu'aucun
|
|
# coffre n'est saisi, la saisie s'ouvre d'elle-même. Le champ propose le modèle
|
|
# https://societe.loksi.fr, « societe » sélectionné : taper le nom le remplace.
|
|
replace_once(ts, 'import { Observable, Subject, map } from "rxjs";',
|
|
'import { Observable, Subject, map, take } from "rxjs";')
|
|
replace_once(ts, " private destroy$ = new Subject<void>();\n",
|
|
" private destroy$ = new Subject<void>();\n\n"
|
|
" // Loksi : au premier affichage de la connexion sans coffre saisi, ouvrir la saisie.\n"
|
|
" private loksiPremiereSaisie = this.loksiHost$.pipe(take(1)).subscribe((host) => {\n"
|
|
" if (host == null && window.location.hash.startsWith(\"#/login\")) {\n"
|
|
" setTimeout(() => void this.toggle(Region.SelfHosted), 0);\n }\n });\n")
|
|
replace_once(dialog_ts,
|
|
' baseUrl: urls.base === ' + json.dumps(UNSET) + ' ? "" : urls.base || "",',
|
|
' baseUrl: urls.base === ' + json.dumps(UNSET) + ' ? ' + json.dumps(MODELE_COFFRE)
|
|
+ ' : urls.base || "",')
|
|
replace_once(dialog_ts, " submit = async () => {\n",
|
|
" // Loksi : avec le modèle pré-rempli, « societe » est sélectionné, prêt à être remplacé.\n"
|
|
" ngAfterViewInit() {\n"
|
|
" setTimeout(() => {\n"
|
|
" const champ = document.getElementById(\"self_hosted_env_settings_form_input_base_url\");\n"
|
|
" if (champ instanceof HTMLInputElement && champ.value === " + json.dumps(MODELE_COFFRE) + ") {\n"
|
|
" champ.focus();\n"
|
|
" champ.setSelectionRange(8, 8 + \"societe\".length);\n"
|
|
" }\n }, 50);\n }\n\n"
|
|
" submit = async () => {\n")
|
|
replace_once(dialog_ts,
|
|
" const base = this.baseUrl.value ? loksiAdresse(this.baseUrl.value) : \"\";\n",
|
|
" if (this.baseUrl.value?.trim() === " + json.dumps(MODELE_COFFRE) + ") {\n"
|
|
" this.baseUrl.setErrors({\n"
|
|
" loksiModele: { message: this.i18nService.t(\"loksiReplaceCompany\") },\n"
|
|
" });\n return;\n }\n"
|
|
" const base = this.baseUrl.value ? loksiAdresse(this.baseUrl.value) : \"\";\n")
|
|
replace_once(dialog_dir / "self-hosted-env-config-dialog.component.html",
|
|
" <bit-form-field>\n <bit-label>{{ \"loksiVaultAddress\" | i18n }}</bit-label>",
|
|
" <p bitTypography=\"body2\" class=\"tw-mb-4\" data-loksi=\"intro-coffre\">\n"
|
|
" {{ \"loksiVaultIntro\" | i18n }}\n </p>\n"
|
|
" <bit-form-field>\n <bit-label>{{ \"loksiVaultAddress\" | i18n }}</bit-label>")
|
|
context_menu = APP / "src/autofill/browser/main-context-menu-handler.ts"
|
|
replace_once(context_menu,
|
|
' {\n id: ROOT_ID,\n title: "Bitwarden",\n },\n', '')
|
|
# Edge et Chromium affichent déjà le nom natif de l'extension au-dessus de
|
|
# ces actions : supprimer le parent évite un deuxième niveau redondant.
|
|
replace_count(context_menu, ' parentId: ROOT_ID,\n', '', 12)
|
|
# Le titre de page devient le titre de la fenêtre détachée (popout) et le nom
|
|
# lu par les lecteurs d'écran sur les iframes du menu en ligne.
|
|
for page, old, new in (
|
|
("src/popup/index.ejs", "Bitwarden", "Loksi"),
|
|
("src/sidepanel-disabled.html", "Bitwarden", "Loksi"),
|
|
("src/autofill/notification/bar.html", "Bitwarden", "Loksi"),
|
|
("src/platform/offscreen-document/index.html", "Bitwarden Offscreen Document",
|
|
"Loksi Offscreen Document"),
|
|
("src/autofill/overlay/inline-menu/pages/button/button.html", "Bitwarden inline menu button",
|
|
"Loksi inline menu button"),
|
|
("src/autofill/overlay/inline-menu/pages/list/list.html", "Bitwarden vault", "Loksi vault"),
|
|
("src/autofill/overlay/inline-menu/pages/menu-container/menu-container.html",
|
|
"Bitwarden inline menu", "Loksi inline menu")):
|
|
replace_once(APP / page, "<title>" + old + "</title>", "<title>" + new + "</title>")
|
|
# Pas de création de compte : un compte Loksi est créé par l'administrateur de
|
|
# l'entreprise, et personne ne commence la relation commerciale par l'extension
|
|
# (Romain, 30/09/2026). Comme les applis mobiles. Le lien bitwarden.com/terms/ de
|
|
# l'écran d'inscription n'est plus atteignable.
|
|
carousel = APP / "src/vault/popup/components/vault/intro-carousel/intro-carousel.component.html"
|
|
html = carousel.read_text()
|
|
html, count = re.subn(r'<button\n type="button"\n bitButton\n buttonType="primary"\n'
|
|
r' \(click\)="navigateToSignup\(\)"\n.*?</button>\n', "", html, flags=re.S)
|
|
if count != 1:
|
|
raise RuntimeError("Carrousel amont modifié : navigateToSignup()")
|
|
html = html.replace(' buttonType="secondary"\n (click)="navigateToLogin()"\n class="tw-w-full tw-mt-2"',
|
|
' buttonType="primary"\n (click)="navigateToLogin()"\n class="tw-w-full tw-mt-4"', 1)
|
|
if 'buttonType="primary"\n (click)="navigateToLogin()"' not in html:
|
|
raise RuntimeError("Carrousel amont modifié : navigateToLogin()")
|
|
carousel.write_text(html)
|
|
secondary = SOURCE / "libs/auth/src/angular/login/login-secondary-content.component.ts"
|
|
code = secondary.read_text()
|
|
code, count = re.subn(r' template: `\n <div class="tw-text-center" \*ngIf.*?</div>\n `,',
|
|
" template: ``,", code, flags=re.S)
|
|
if count != 1:
|
|
raise RuntimeError("Lien d'inscription amont modifié : login-secondary-content")
|
|
secondary.write_text(code)
|
|
# Sélecteur de serveur : plus de bitwarden.com ni bitwarden.eu, sans objet pour Loksi.
|
|
# Filtré dans la seule liste affichée (sélecteur, inscription) : la logique
|
|
# d'environnement garde ses régions, un état ancien sur US ne casse rien.
|
|
replace_once(SOURCE / "libs/common/src/platform/services/default-available-regions.service.ts",
|
|
".filter((r) => r.key !== Region.Gov || govEnabled),",
|
|
".filter((r) => r.key !== Region.Gov || govEnabled)\n"
|
|
" .filter((r) => r.key !== Region.US && r.key !== Region.EU),")
|
|
# Plus de Bitwarden sauf obligation (Romain, 09/10/2026). Inventaire et raisons dans
|
|
# README.md, « Ce qui garde bitwarden ». L'hôte de messagerie native est celui que le
|
|
# bureau Loksi écoute : sans lui, pas de déverrouillage biométrique par le bureau.
|
|
for path in ("src/background/nativeMessaging.background.ts",
|
|
"src/platform/ipc/transports/desktop-ipc.transport.ts"):
|
|
replace_once(APP / path, 'BrowserApi.connectNative("com.8bit.bitwarden")',
|
|
'BrowserApi.connectNative(' + json.dumps(CONFIG["native_host"]) + ')')
|
|
replace_once(SOURCE / "libs/tools/export-vault-core/src/services/export-helper.ts",
|
|
'return "bitwarden" + (prefix', 'return "loksi" + (prefix')
|
|
replace_count(SOURCE / "libs/logging/src/flight-recorder-export.ts",
|
|
"Bitwarden-diagnostic-report-", "Loksi-diagnostic-report-", 2)
|
|
# Classe posée sur les champs remplis, visible des sites dans leur propre page.
|
|
replace_count(APP / "src/autofill/content/autofill.css", "com-bitwarden-browser-animated-fill",
|
|
"com-loksi-browser-animated-fill", 3)
|
|
replace_count(APP / "src/autofill/services/insert-autofill-content.service.ts",
|
|
'"com-bitwarden-browser-animated-fill"', '"com-loksi-browser-animated-fill"', 2)
|
|
# Mots qui affaiblissent un mot de passe : le nom du produit en fait partie.
|
|
replace_once(SOURCE / "libs/common/src/tools/password-strength/password-strength.service.ts",
|
|
' "bitwarden",\n', ' "loksi",\n')
|
|
# Tailwind ne cherche plus de classes dans bitwarden_license (code sous licence non
|
|
# libre, jamais compilé ici) : sinon le CSS en tirait 5 classes que l'archive de
|
|
# sources, qui exclut ce dossier, ne reproduisait pas (relevé le 10/10/2026).
|
|
replace_once(APP / "tailwind.config.js",
|
|
' path.resolve(__dirname, "../../bitwarden_license/bit-browser/src/**/*.{html,ts,mdx}"),\n', "")
|
|
# Entrées qui n'ouvrent que des offres, magasins et aides Bitwarden : retirées.
|
|
settings = APP / "src/tools/popup/settings/settings-v2.component.html"
|
|
html = settings.read_text()
|
|
for route in ("/download-bitwarden", "/more-from-bitwarden"):
|
|
html, count = re.subn(r' <bit-item>\n <a bit-item-content routerLink="' + route
|
|
+ r'".*?</bit-item>\n', "", html, flags=re.S)
|
|
if count != 1:
|
|
raise RuntimeError("Entrée de paramètres amont modifiée : " + route)
|
|
settings.write_text(html)
|
|
about_page = APP / "src/tools/popup/settings/about-page/about-page-v2.component.html"
|
|
html = about_page.read_text()
|
|
for handler in ("rate()",):
|
|
html, count = re.subn(r' <bit-item>\n <button type="button" bit-item-content \(click\)="'
|
|
+ re.escape(handler) + r'">.*?</bit-item>\n', "", html, flags=re.S)
|
|
if count != 1:
|
|
raise RuntimeError("Entrée À propos amont modifiée : " + handler)
|
|
# Aide, confidentialité et « Nous contacter », comme Android (b04ec5e) et iOS. Adresses
|
|
# www définitives : Romain publie les pages avec les applis (décision du 30/09/2026).
|
|
html = html.replace(ABOUT_WEB_VAULT, ABOUT_LOKSI + ABOUT_WEB_VAULT, 1)
|
|
if "contactSupport()" not in html:
|
|
raise RuntimeError("Entrée À propos amont modifiée : openWebVault()")
|
|
about_page.write_text(html)
|
|
replace_once(about_page.with_suffix(".ts"), " async openWebVault() {",
|
|
ABOUT_METHODES + " async openWebVault() {")
|
|
# Plus aucun lien vers l'aide ou la confidentialité de Bitwarden : l'aide ciblée
|
|
# (import, raccourcis...) mène à l'aide Loksi, qui n'a pas encore de page par sujet.
|
|
liens = 0
|
|
for root in (APP / "src", SOURCE / "libs"):
|
|
for path in root.rglob("*"):
|
|
if path.suffix not in (".ts", ".html") or ".spec." in path.name or "_locales" in path.parts:
|
|
continue
|
|
text = path.read_text(errors="ignore")
|
|
text, count = re.subn(r"https://bitwarden\.com/help/[^\"'`\s)]*", LOKSI_AIDE, text)
|
|
text, count2 = re.subn(r"https://bitwarden\.com/privacy/?", LOKSI_CONFIDENTIALITE, text)
|
|
if count + count2:
|
|
path.write_text(text)
|
|
liens += count + count2
|
|
if liens < 30:
|
|
raise RuntimeError("Liens d'aide amont : " + str(liens) + ", 38 attendus au 30/09/2026")
|
|
# Le nom Bitwarden reste où il dit l'origine (copyright GPL), pas où il fait
|
|
# croire à leur produit. Le menu dit déjà « À propos de Loksi ».
|
|
# Numérotation (06/10/2026) : l'appli affiche « AAAA.M.n (build) », sous Firefox aussi,
|
|
# qui n'a pas version_name. Le serveur reçoit toujours la version amont dans
|
|
# Bitwarden-Client-Version : c'est la version réelle du code, celle que Vaultwarden
|
|
# doit voir pour activer ou non une fonction.
|
|
utils = APP / "src/platform/services/platform-utils/browser-platform-utils.service.ts"
|
|
replace_once(utils, " return Promise.resolve(manifest.version_name ?? manifest.version);\n",
|
|
" const [annee, mois, sortie, build] = manifest.version.split(\".\");\n"
|
|
" return Promise.resolve(\n"
|
|
" build ? `${annee}.${mois}.${sortie} (${build})` : manifest.version,\n );\n")
|
|
replace_once(utils, ' return Promise.resolve(manifest.version.split(RegExp("[+|-]"))[0].trim());\n',
|
|
" // Loksi : la version amont, pas la numérotation Loksi.\n"
|
|
" return Promise.resolve(" + json.dumps(VERSION_AMONT) + ");\n")
|
|
about = APP / "src/tools/popup/settings/about-dialog/about-dialog.component.html"
|
|
replace_once(about, "<div bitDialogTitle>Bitwarden</div>", "<div bitDialogTitle>Loksi</div>")
|
|
replace_once(about, " <p>© Bitwarden Inc.",
|
|
' <p>{{ "loksiAboutOrigin" | i18n }}</p>\n <p>{{ "loksiBasedOn" | i18n }}</p>\n'
|
|
' <p>© Bitwarden Inc.')
|
|
replace_once(APP / "src/platform/badge/badge-browser-api.ts",
|
|
'const title = `Bitwarden${Utils.isNullOrEmpty(text) ? "" : ` [${text}]`}`;',
|
|
'const title = `Loksi${Utils.isNullOrEmpty(text) ? "" : ` [${text}]`}`;')
|
|
# Remplace seulement les logos exposés par l'extension. Les noms d'exports restent compatibles.
|
|
# Logo d'en-tête : icône et mot-symbole de la charte, clair et sombre.
|
|
wordmark = theme_pair(ROOT.parent / "brand/sources/loksi-logo-clair.svg",
|
|
ROOT.parent / "brand/sources/loksi-logo-sombre.svg", "logo")
|
|
# Pastilles 16 px du menu de remplissage : l'icône plate, dessinée pour cette taille.
|
|
svg = (ROOT.parent / "brand/sources/loksi-icon-16.svg").read_text().strip()
|
|
for name, export in (("bitwarden-logo.icon.ts", "BitwardenLogo"),
|
|
("bitwarden-logo-beta.icon.ts", "BitwardenLogoBeta")):
|
|
(SOURCE / "libs/assets/src/svg/svgs" / name).write_text(
|
|
'import { svg } from "../svg";\nexport const ' + export + ' = svg`' + wordmark + '`;\n')
|
|
# Les illustrations de la popup sont des dessins Bitwarden (contour navy, jaune),
|
|
# dont le cadenas au champ « ***__ » de l'écran de déverrouillage. Chacune est
|
|
# remplacée par son maître Loksi, table de brand/illustrations-mobiles/README.md.
|
|
# La signature de chaque dessin amont sert à verify pour prouver qu'il a disparu.
|
|
signatures = {}
|
|
for filename, (export, name) in ILLUSTRATION_TABLE.items():
|
|
path = SOURCE / "libs/assets/src/svg/svgs" / filename
|
|
original = path.read_text()
|
|
if original.count("export const " + export + " = svg`") != 1 or original.count("svg`") != 1:
|
|
raise RuntimeError("Illustration amont modifiée : " + export)
|
|
signatures[export] = re.search(r' d="([^"]{40})', original).group(1)
|
|
path.write_text('import { svg } from "../svg";\n\nexport const ' + export + ' = svg`'
|
|
+ illustration(name) + '`;\n')
|
|
write_json(SIGNATURES, signatures)
|
|
# Barre d'onglets : les pictogrammes Loksi des applis iOS, maître clair, couleurs
|
|
# remplacées par des variables pour suivre le thème comme les classes de l'amont.
|
|
for filename, stem in (("vault.ts", "Vault"), ("generator.ts", "Generator"),
|
|
("send.ts", "Send"), ("settings.ts", "Settings")):
|
|
path = SOURCE / "libs/assets/src/svg/svgs" / filename
|
|
if re.findall(r"export const (\w+) = svg`", path.read_text()) != [stem + "Inactive", stem + "Active"]:
|
|
raise RuntimeError("Onglet amont modifié : " + filename)
|
|
parts = ['import { svg } from "../svg";\n']
|
|
for export, state in ((stem + "Inactive", "idle"), (stem + "Active", "active")):
|
|
picto = (ONGLETS / (stem.lower() + "-" + state + "-light.svg")).read_text().strip()
|
|
picto = re.sub(r'(fill|stroke)="(#[0-9A-F]{6})"',
|
|
lambda m: 'style="' + m.group(1) + ":" + ONGLET_COULEURS[m.group(2)] + '"', picto)
|
|
if "#" in picto or "`" in picto:
|
|
raise RuntimeError("Couleur d'onglet inattendue : " + filename)
|
|
picto = picto.replace("<svg ", '<svg data-loksi="onglet-' + stem.lower() + '" ', 1)
|
|
parts.append("export const " + export + " = svg`" + picto + "`;\n")
|
|
path.write_text("\n".join(parts))
|
|
# Pas de variante Tailwind arbitraire : [.theme_dark_&] y devient « .theme dark ».
|
|
with (APP / "src/popup/scss/popup.scss").open("a") as scss:
|
|
scss.write("\n.loksi-illustration-sombre,\n.theme_dark .loksi-illustration-clair {\n"
|
|
" display: none;\n}\n\n.theme_dark .loksi-illustration-sombre {\n"
|
|
" display: block;\n}\n\n:root {\n --loksi-onglet-accent: #009cde;\n"
|
|
" --loksi-onglet-repos: #6b7a90;\n}\n\n.theme_dark {\n"
|
|
" --loksi-onglet-accent: #1fbff5;\n --loksi-onglet-repos: #8d9aae;\n}\n")
|
|
# Police : Raleway renommée « Loksi » (nom réservé OFL), comme les applis mobiles.
|
|
subprocess.run([sys.executable, str(ROOT / "fonts.py")], check=True)
|
|
webfonts = SOURCE / "libs/components/src/webfonts"
|
|
faces = []
|
|
for filename, weight, style in (("loksi-400.woff2", 400, "normal"), ("loksi-600.woff2", 600, "normal"),
|
|
("loksi-700.woff2", 700, "normal"),
|
|
("loksi-400-italic.woff2", 400, "italic")):
|
|
shutil.copy2(ROOT / ".cache/fonts/woff2" / filename, webfonts / filename)
|
|
faces.append('@font-face {\n font-family: Loksi;\n src: url("~@bitwarden/components/src/webfonts/'
|
|
+ filename + '") format("woff2");\n font-display: swap;\n font-weight: '
|
|
+ str(weight) + ';\n font-style: ' + style + ';\n}\n')
|
|
fonts_css = SOURCE / "libs/components/src/theme.css"
|
|
replace_once(fonts_css, " --font-sans:\n Inter, ", " --font-sans:\n Loksi, Inter, ")
|
|
replace_once(fonts_css, "/**\n * CSS variables\n */", "".join(faces) + "\n/**\n * CSS variables\n */")
|
|
theme = SOURCE / "libs/components/src/tw-theme.css"
|
|
css = theme.read_text()
|
|
for block, values in PALETTE.items():
|
|
start = css.index("\n" + block + "\n")
|
|
end = css.index("\n}\n", start)
|
|
body = css[start:end]
|
|
for name, value in values.items():
|
|
body, count = re.subn(r"(\n " + re.escape(name) + r": )[^;]+;",
|
|
lambda m: m.group(1) + value + ";", body)
|
|
if count != 1:
|
|
raise RuntimeError("Couleur amont introuvable : " + block + " " + name)
|
|
css = css[:start] + body + css[end:]
|
|
theme.write_text(css)
|
|
overlay = APP / "src/autofill/utils/svg-icons.ts"
|
|
contents = overlay.read_text()
|
|
for export in ("logoIcon", "logoLockedIcon"):
|
|
icon = svg.replace('<svg ', '<svg width="16" height="16" ')
|
|
if export == "logoLockedIcon":
|
|
icon = icon.replace('</svg>', '<circle cx="50" cy="50" r="13" fill="#009CDE" '
|
|
'stroke="#FFFFFF" stroke-width="3"/>'
|
|
'<path d="M44 50h12" stroke="#FFFFFF" stroke-width="4"/></svg>')
|
|
contents, count = re.subn(r"export const " + export + r"\s*=\s*'[^']*';",
|
|
lambda m: "export const " + export + " = " + json.dumps(icon) + ";", contents)
|
|
if count != 1:
|
|
raise RuntimeError("Logo amont modifié : " + export)
|
|
overlay.write_text(contents)
|
|
subprocess.run(["node", str(ROOT / "icons.mjs")], check=True)
|
|
print(f"Sources Loksi préparées : {SOURCE}")
|
|
|
|
|
|
# ---------------------------------------------------------------- numérotation
|
|
|
|
# Règle de Romain du 06/10/2026, commune à Loksi et Klepsi : version affichée AAAA.M.n
|
|
# sans zéro devant (n = 0 pour la première sortie du mois), numéro de build entier qui
|
|
# monte à chaque paquet. Manifeste : version = AAAA.M.n.build, version_name =
|
|
# « AAAA.M.n (build) » pour Chrome et Edge. Le compteur vit dans version.json, seul endroit.
|
|
VERSION_FILE = ROOT / "version.json"
|
|
VERSION_AMONT = CONFIG["tag"].split("-v", 1)[1]
|
|
SORTIE = re.compile(r"(\d{4})\.([1-9]|1[0-2])\.(0|[1-9]\d*)")
|
|
|
|
|
|
def numero():
|
|
data = json.loads(VERSION_FILE.read_text())
|
|
if not SORTIE.fullmatch(data["version"]) or not isinstance(data["build"], int) or data["build"] < 1:
|
|
raise RuntimeError("version.json invalide")
|
|
return data["version"], data["build"]
|
|
|
|
|
|
def version_errors(manifest, browser, version, build):
|
|
"""Écarts du manifeste avec la règle. Liste vide si tout va bien."""
|
|
errors = []
|
|
attendu = version + "." + str(build)
|
|
if manifest.get("version") != attendu:
|
|
errors.append("version " + repr(manifest.get("version")) + ", attendu " + attendu)
|
|
if not re.fullmatch(SORTIE.pattern + r"\.[1-9]\d*", manifest.get("version", "")):
|
|
errors.append("format AAAA.M.n.build sans zéro devant")
|
|
if manifest.get("version", "").startswith(VERSION_AMONT):
|
|
errors.append("version amont " + VERSION_AMONT)
|
|
if browser == "firefox":
|
|
if "version_name" in manifest:
|
|
errors.append("version_name inconnu de Firefox")
|
|
elif manifest.get("version_name") != version + " (" + str(build) + ")":
|
|
errors.append("version_name " + repr(manifest.get("version_name")))
|
|
return errors
|
|
|
|
|
|
def bump(sortie=None):
|
|
"""Monte le build d'une unité, et change de sortie si on en donne une (AAAA.M.n)."""
|
|
version, build = numero()
|
|
if sortie is not None:
|
|
if not SORTIE.fullmatch(sortie):
|
|
raise ValueError("Sortie au format AAAA.M.n, sans zéro devant : " + sortie)
|
|
if tuple(map(int, sortie.split("."))) <= tuple(map(int, version.split("."))):
|
|
raise ValueError("La sortie doit monter : " + version + " puis " + sortie)
|
|
version = sortie
|
|
write_json(VERSION_FILE, {"version": version, "build": build + 1})
|
|
print(f"Version {version} ({build + 1})")
|
|
|
|
|
|
# ---------------------------------------------------------------- sources pour AMO
|
|
|
|
# Mozilla demande le code source quand le paquet est minifié ou assemblé par webpack.
|
|
# L'archive porte l'arbre amont tel que prepare l'a adapté, sans node_modules ni sortie de
|
|
# build, et un script qui reconstruit le paquet Firefox à l'identique. Le relecteur n'a pas
|
|
# besoin de prototype.py : les adaptations sont déjà appliquées dans les fichiers.
|
|
SOURCES_EXCLUS = {"node_modules", ".git", ".angular", ".nx", "bitwarden_license",
|
|
"coverage", ".cache"}
|
|
CONSTRUIRE_SH = """#!/bin/sh
|
|
# Reconstruit l'extension Loksi pour Firefox depuis ces sources (macOS ou Linux).
|
|
# Prérequis : Node.js 24 ou plus et npm 11. Environ 2 Go de dépendances npm.
|
|
set -eu
|
|
cd "$(dirname "$0")"
|
|
npm ci --ignore-scripts --no-audit --no-fund
|
|
cd apps/browser
|
|
NODE_ENV=production BROWSER=firefox NODE_OPTIONS=--max-old-space-size=8192 \\
|
|
node ../../node_modules/webpack-cli/bin/cli.js --config webpack.config.js
|
|
echo "Paquet construit dans apps/browser/build"
|
|
"""
|
|
|
|
|
|
def sources(browser="firefox"):
|
|
if browser != "firefox":
|
|
raise ValueError("Archive de sources : Firefox seulement")
|
|
version, build_no = numero()
|
|
numero_complet = version + "." + str(build_no)
|
|
manifeste = json.loads((APP / "src/manifest.json").read_text())
|
|
if manifeste.get("version") != numero_complet:
|
|
raise RuntimeError("Sources pas préparées pour " + numero_complet + " : lancer prepare")
|
|
archive = ROOT / "dist" / ("loksi-firefox-" + numero_complet + "-sources.zip")
|
|
archive.parent.mkdir(exist_ok=True)
|
|
racine = "loksi-firefox-" + numero_complet
|
|
notice = ("Loksi pour Firefox " + version + " (" + str(build_no) + "), sources\n\n"
|
|
"Extension Loksi d'Aleop, dérivée du client navigateur Bitwarden " + VERSION_AMONT
|
|
+ " (bitwarden/clients, tag " + CONFIG["tag"] + ", commit " + CONFIG["commit"]
|
|
+ "), sous licence GPL v3 (LICENSE_GPL.txt).\n"
|
|
"Les adaptations Loksi sont déjà appliquées dans ces fichiers.\n\n"
|
|
"Reconstruire : sh construire.sh\n"
|
|
"Prérequis : Node.js 24 ou plus, npm 11, environ 2 Go pour les dépendances.\n"
|
|
"Le paquet sort dans apps/browser/build, identique au fichier envoyé, à\n"
|
|
"l'exception des fichiers de licence ajoutés à côté (LICENSE.txt, LICENSE_GPL.txt,\n"
|
|
"NOTICE.txt, LOKSI-NOTICE.txt, OFL-police-Loksi.txt, THIRD-PARTY.json, third-party/).\n")
|
|
import zipfile
|
|
compte = 0
|
|
with zipfile.ZipFile(archive, "w", zipfile.ZIP_DEFLATED, compresslevel=9) as zf:
|
|
for path in sorted(SOURCE.rglob("*")):
|
|
relatif = path.relative_to(SOURCE)
|
|
if any(part in SOURCES_EXCLUS for part in relatif.parts) or not path.is_file():
|
|
continue
|
|
if relatif.parts[:2] == ("apps", "browser") and len(relatif.parts) > 2 and relatif.parts[2] == "build":
|
|
continue
|
|
zf.write(path, racine + "/" + relatif.as_posix())
|
|
compte += 1
|
|
zf.writestr(racine + "/CONSTRUIRE.txt", notice)
|
|
info = zipfile.ZipInfo(racine + "/construire.sh")
|
|
info.external_attr = 0o755 << 16
|
|
zf.writestr(info, CONSTRUIRE_SH)
|
|
taille = archive.stat().st_size
|
|
print(f"{archive} : {compte} fichiers, {taille / 1e6:.1f} Mo")
|
|
if taille > 200e6:
|
|
raise RuntimeError("Archive de sources trop lourde pour AMO")
|
|
return archive
|
|
|
|
|
|
def paquet(browser):
|
|
"""Zip à envoyer au magasin. Chrome et Edge sans la clé « key » ni cartes de sources :
|
|
chaque magasin attribue son propre identifiant, et Edge refuserait la clé au premier envoi."""
|
|
import zipfile
|
|
verify(browser)
|
|
target = ROOT / "dist" / browser
|
|
version, build_no = numero()
|
|
archive = ROOT / "dist" / ("loksi-" + browser + "-" + version + "." + str(build_no) + ".zip")
|
|
with zipfile.ZipFile(archive, "w", zipfile.ZIP_DEFLATED, compresslevel=9) as zf:
|
|
for path in sorted(target.rglob("*")):
|
|
# Cartes de sources gardées pour Firefox : le relecteur compare sa reconstruction
|
|
# au paquet, et sa reconstruction en contient.
|
|
if not path.is_file() or (path.suffix == ".map" and browser != "firefox"):
|
|
continue
|
|
relatif = path.relative_to(target).as_posix()
|
|
if relatif == "manifest.json" and browser != "firefox":
|
|
manifest = json.loads(path.read_text())
|
|
manifest.pop("key", None)
|
|
zf.writestr(relatif, json.dumps(manifest, indent=2, ensure_ascii=False) + "\n")
|
|
else:
|
|
zf.write(path, relatif)
|
|
with zipfile.ZipFile(archive) as zf:
|
|
manifest = json.loads(zf.read("manifest.json"))
|
|
assert "key" not in manifest or browser == "firefox", "clé dans le paquet magasin"
|
|
assert browser == "firefox" or not any(n.endswith(".map") for n in zf.namelist()), \
|
|
"cartes de sources dans le paquet"
|
|
print(f"{archive} : {archive.stat().st_size / 1e6:.1f} Mo")
|
|
return archive
|
|
|
|
|
|
def build(browser):
|
|
if browser not in ("chrome", "edge", "firefox"):
|
|
raise ValueError("Navigateur : chrome, edge ou firefox")
|
|
env = dict(os.environ, NODE_ENV="production", BROWSER=browser,
|
|
NODE_OPTIONS="--max-old-space-size=8192")
|
|
env.pop("MANIFEST_VERSION", None)
|
|
if browser != "firefox":
|
|
env["MANIFEST_VERSION"] = "3"
|
|
subprocess.run(["node", str(SOURCE / "node_modules/webpack-cli/bin/cli.js"),
|
|
"--config", str(ROOT / "webpack-oss.cjs")], cwd=APP, env=env, check=True)
|
|
target = ROOT / "dist" / browser
|
|
if target.exists():
|
|
shutil.rmtree(target)
|
|
shutil.copytree(APP / "build", target)
|
|
for filename in ("LICENSE.txt", "LICENSE_GPL.txt", "NOTICE.txt"):
|
|
if (SOURCE / filename).exists():
|
|
shutil.copy2(SOURCE / filename, target / filename)
|
|
shutil.copy2(ROOT.parent / "brand/propositions/harmonisation-klepsi/sources/OFL-Raleway.txt",
|
|
target / "OFL-police-Loksi.txt")
|
|
(target / "LOKSI-NOTICE.txt").write_text(
|
|
"Loksi, adaptation locale par Aleop, 27 septembre 2026.\n"
|
|
"Basé sur Bitwarden clients " + CONFIG["tag"] + ".\n"
|
|
"Code amont et adaptations : GPL v3 ; licences tierces conservées.\n"
|
|
"Modifications : identité visuelle, manifestes, serveur géré et accueil.\n"
|
|
"Police Loksi : instances de Raleway renommées, SIL Open Font License 1.1\n"
|
|
"(OFL-police-Loksi.txt).\n"
|
|
"Ni affilié ni approuvé par Bitwarden. Prototype non publié.\n")
|
|
verify(browser)
|
|
subprocess.run([sys.executable, str(ROOT / "dependencies.py"), browser], check=True)
|
|
|
|
|
|
def verify(browser):
|
|
target = ROOT / "dist" / browser
|
|
manifest = json.loads((target / "manifest.json").read_text())
|
|
version, build_no = numero()
|
|
erreurs = version_errors(manifest, browser, version, build_no)
|
|
assert not erreurs, "numérotation : " + " ; ".join(erreurs)
|
|
# Canari : ces manifestes fabriqués doivent être refusés, sinon le contrôle ne mesure rien.
|
|
for faux in ({"version": "2026.09.0.1", "version_name": "2026.09.0 (1)"},
|
|
{"version": VERSION_AMONT, "version_name": VERSION_AMONT},
|
|
{"version": "2026.10.0.01", "version_name": "2026.10.0 (01)"}):
|
|
assert version_errors(faux, "chrome", "2026.09.0" if faux["version"].startswith("2026.09") else version,
|
|
build_no), "canari de numérotation accepté : " + faux["version"]
|
|
assert version_errors({"version": "2026.10.0.7", "version_name": "x"}, "firefox", "2026.10.0", 7), \
|
|
"canari Firefox accepté"
|
|
assert manifest["short_name"] == "Loksi"
|
|
assert manifest["manifest_version"] == (2 if browser == "firefox" else 3)
|
|
if browser == "firefox":
|
|
gecko = manifest["browser_specific_settings"]["gecko"]
|
|
assert gecko["id"] == CONFIG["firefox_id"]
|
|
assert gecko.get("data_collection_permissions") == CONFIG["firefox_data_collection"], \
|
|
"déclaration de collecte Firefox"
|
|
assert float(gecko.get("strict_min_version", "0")) >= 140, "Firefox 140 minimum"
|
|
assert "update_url" not in manifest
|
|
if browser == "firefox":
|
|
assert "key" not in manifest
|
|
else:
|
|
assert manifest.get("key") == CONFIG["chromium_key"], "clé de manifeste"
|
|
empreinte = hashlib.sha256(base64.b64decode(manifest["key"])).hexdigest()[:32]
|
|
assert "".join(chr(ord("a") + int(c, 16)) for c in empreinte) == CONFIG["chromium_id"], \
|
|
"identifiant d'extension"
|
|
assert manifest["author"] == "Aleop"
|
|
# Plus de Bitwarden sauf obligation : ces traces doivent avoir disparu du build.
|
|
for path in target.rglob("*"):
|
|
if path.is_file() and path.suffix in (".js", ".css", ".html") and "third-party" not in path.parts:
|
|
texte = path.read_text(errors="ignore")
|
|
for trace in ("com.8bit.bitwarden", "com-bitwarden-browser-animated-fill",
|
|
"Bitwarden-diagnostic-report-"):
|
|
assert trace not in texte, trace + " dans " + str(path)
|
|
assert CONFIG["native_host"] in (target / "background.js").read_text(), "hôte natif Loksi"
|
|
for icon in manifest["icons"].values():
|
|
assert (target / icon).is_file(), icon
|
|
for script in manifest["content_scripts"]:
|
|
for filename in script.get("js", []) + script.get("css", []):
|
|
assert (target / filename).is_file(), filename
|
|
# Aucun coffre par défaut : plus une seule trace de loksi.aleop.eu dans le build, le
|
|
# marqueur .invalid dans le fond et la popup, et la ligne pour les nouveaux clients.
|
|
for path in target.rglob("*"):
|
|
if path.is_file() and path.suffix in (".js", ".json", ".html", ".css", ".map"):
|
|
assert "loksi.aleop.eu" not in path.read_text(errors="ignore"), "coffre par défaut : " + str(path)
|
|
assert UNSET in (target / "background.js").read_text(), "marqueur adresse à saisir"
|
|
assert UNSET in (target / "popup/main.js").read_text(), "marqueur adresse à saisir"
|
|
assert manifest["homepage_url"] == LOKSI_PRODUIT
|
|
background = (target / "background.js").read_text()
|
|
assert 'id:"root",title:"Bitwarden"' not in background
|
|
assert 'id:"root",title:"Loksi"' not in background
|
|
popup = (target / "popup/main.js").read_text()
|
|
for export, signature in json.loads(SIGNATURES.read_text()).items():
|
|
assert signature not in popup, "Illustration Bitwarden : " + export
|
|
for _, name in list(ILLUSTRATION_TABLE.values()) + [(None, "logo")]:
|
|
assert 'data-loksi="' + name + '"' in popup, "Illustration Loksi absente : " + name
|
|
css = (target / "popup/main.css").read_text()
|
|
assert ".theme_dark .loksi-illustration-sombre{display:block}" in css, "bascule sombre absente"
|
|
for page in (popup, (target / "background.js").read_text()):
|
|
assert "bitwarden.com/help" not in page and "bitwarden.com/privacy" not in page, "lien Bitwarden"
|
|
for link in (LOKSI_AIDE, LOKSI_CONFIDENTIALITE, "mailto:" + LOKSI_SUPPORT, '"loksiContactUs"',
|
|
LOKSI_SOURCE, '"loksiSourceCode"', '"loksiSourceTitle"', LOKSI_PRODUIT, '"nouveau-client"', '"loksiAddressToEnter"', '"loksiNotAVault"',
|
|
".loksi.fr", '"loksiVaultIntro"', MODELE_COFFRE, '"loksiReplaceCompany"'):
|
|
assert link in popup, "lien Loksi absent : " + link
|
|
assert re.search(r"\.key!==\w+\.US&&\w+\.key!==\w+\.EU", popup), \
|
|
"sélecteur de serveur : bitwarden.com encore proposé"
|
|
# Appel depuis le gabarit du carrousel (la méthode reste dans la classe) et lien de la connexion.
|
|
assert not re.search(r"\.navigateToSignup\(\)", popup), "création de compte encore affichée"
|
|
assert "login-create-account-link" not in popup, "création de compte encore affichée"
|
|
for key in ("downloadBitwardenApps", "rateExtension"):
|
|
assert '"' + key + '"' not in popup, "Entrée Bitwarden encore affichée : " + key
|
|
for stem in ("vault", "generator", "send", "settings"):
|
|
assert 'data-loksi="onglet-' + stem + '"' in popup, "Onglet Loksi absent : " + stem
|
|
assert "--color-brand-700:#003087" in css.replace(" ", ""), "palette Bitwarden"
|
|
assert "--color-brand-700:#175ddc" not in css.replace(" ", ""), "palette Bitwarden"
|
|
assert "font-family:Loksi" in css.replace(" ", ""), "police Loksi absente"
|
|
assert list((target / "popup/fonts").glob("loksi-400*.woff2")), "police Loksi absente"
|
|
assert (target / "OFL-police-Loksi.txt").is_file()
|
|
assert (target / "popup/index.html").is_file()
|
|
for page in target.rglob("*.html"):
|
|
title = re.search(r"<title>([^<]*)</title>", page.read_text())
|
|
assert title is None or "Bitwarden" not in title.group(1), page
|
|
for locale in ("en", "fr"):
|
|
data = json.loads((target / "_locales" / locale / "messages.json").read_text())
|
|
assert data["extName"]["message"] == "Loksi"
|
|
assert data["loksiAboutOrigin"]["message"] == LOKSI_ORIGINE[locale], "mention d'origine"
|
|
assert data["loksiBasedOn"]["message"].endswith("Bitwarden " + VERSION_AMONT + "."), "version amont"
|
|
restes = [k for k, v in data.items()
|
|
if "bitwarden" in v.get("message", "").lower() and k not in BITWARDEN_GARDE]
|
|
assert not restes, locale + " : " + ", ".join(restes)
|
|
print(f"Vérifications statiques réussies : {target}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
command = sys.argv[1] if len(sys.argv) > 1 else "help"
|
|
if command == "prepare":
|
|
prepare()
|
|
elif command == "sources":
|
|
sources()
|
|
elif command == "bump" and len(sys.argv) in (2, 3):
|
|
bump(sys.argv[2] if len(sys.argv) == 3 else None)
|
|
elif command in ("build", "verify", "paquet") and len(sys.argv) == 3:
|
|
globals()[command](sys.argv[2])
|
|
else:
|
|
sys.exit("Usage : prototype.py prepare | bump [AAAA.M.n] | sources | build|verify|paquet chrome|edge|firefox")
|