From b8734189cf41765c235d0d8a2695d7e4b00e9b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A2=D1=80=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Wed, 23 Sep 2026 08:20:10 +0300 Subject: [PATCH] feat: offline file list + SELECT picker for the SIM/USIM RFM builders (v3.4.0) The SELECT rows (compact RFM chains and the Expanded Script C-APDU picker, which shares the row editor) now have a file picker instead of typing FIDs, paths or chains by hand. Data: - `pysim_simple_server/uicc_files.py` builds the standard file list cardless from pySim's profiles and application classes (CardProfileUICC + CardProfileSIM for the MF tree, every concrete CardApplication subclass for the ADFs) and writes `frontend/uicc_files.json` (490 entries: canonical FID path, symbolic name, fid, kind, root, ADF AID). `tests/test_uicc_files.py` regenerates it and fails when pySim adds or renames files. The asset is precached by the service worker, so the builders keep working offline. Picker: - Sources merged per canonical path: the loaded file-manager tree (card names and probed presence; probed-absent files hidden), custom files, and the shipped standard list (specs-default until "Probe all files" has run). - Default list shows what the current method can express; "all files" reveals the rest, and picking one auto-switches the method - preferring path (one SELECT) over chain - with a note line explaining the switch. A "starts in" selector sets the implicit current DF (UICC shared-FS RFM app starts in MF, an ADF RFM app in its ADF, TS 102 226 7.2/7.3 - the TAR decides; default per builder, overridable per row). - Fill rules: by FID only for direct children of the current DF; path = FID sequence from MF without the MF identifier (ISO 7816-4) or the relative tail (USIM P1=09); chain stays relative and follows the TS 102 221 11.1.1.2 FID search order (children, parent, siblings), so no hop to the common ancestor. ADF roots are not pickable (selection is by AID; TS 102 226 7.1 forbids P1=04 for RFM) - the By AID method stays manual. Tests/docs: frontend/tests/uicc_files.test.js (asset shape, merge/priority/ exclusion, fill matrix, relative chains, session-context tracking, option grouping); help 2.1/2.2 EN+RU, READMEs, AGENTS. sw cache -> simple-v242. --- README.md | 9 + README_RUS.md | 9 + frontend/help-ru.html | 9 + frontend/help.html | 9 + frontend/index.html | 332 ++- frontend/sw.js | 3 +- frontend/tests/uicc_files.test.js | 225 ++ frontend/uicc_files.json | 3931 +++++++++++++++++++++++++++++ pyproject.toml | 2 +- pysim_simple_server/server.py | 2 +- pysim_simple_server/uicc_files.py | 159 ++ tests/test_uicc_files.py | 77 + 12 files changed, 4762 insertions(+), 5 deletions(-) create mode 100644 frontend/tests/uicc_files.test.js create mode 100644 frontend/uicc_files.json create mode 100644 pysim_simple_server/uicc_files.py create mode 100644 tests/test_uicc_files.py diff --git a/README.md b/README.md index 39503b4..46d60f1 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,15 @@ CLA = `A0` (GSM 11.11 / ISO 7816-4). | By DF name / AID | 04 | 00 | AID (application ID) | | ADF RFM chain | 00 | 00 | Comma-separated FIDs, each selected in turn | +#### SELECT file picker + +Every SELECT row offers a file picker: a filter box, an **all files** toggle, the session start root with the current DF, and the file list grouped by root (`MF`, `ADF.USIM`, ...). Picking a file fills the fields for the current method; when the method cannot express the selection the picker switches to one that can - preferring **path** (one SELECT), then **chain** - and says so, e.g. `7F106F40` (path from MF) or `7F20,6F46` (relative FID chain). + +- **List source**: with a card equipped the loaded file-manager tree wins (card names, probed presence; probed-absent files are hidden). Without a card, or for branches the tree has not loaded, the shipped standard list is used: `uicc_files.json`, generated from pySim's profiles/application classes by `pysim_simple_server/uicc_files.py` and drift-guarded by `tests/test_uicc_files.py`. It is specs-default until **Probe all files** runs in the file manager. Custom files are always merged. +- **Session start**: the implicit current DF follows the TAR the secured packet is sent to (UICC Shared File System RFM -> MF, TS 102 226 §7.2; ADF RFM -> its ADF, §7.3). Defaults: MF here, ADF.USIM for USIM RFM; changeable per row. +- **Path** is the FID sequence from MF without the MF identifier (ISO 7816-4); the USIM "from current DF" variant uses the relative tail. **Chain** stays relative to the current DF and follows the TS 102 221 §11.1.1.2 FID search order (children, parent, siblings). +- ADF roots are not pickable - an application is selected by AID, which the **By AID** method keeps manual (TS 102 226 §7.1 forbids P1=`04` for RFM). + #### Options - **Start with SELECT** — checkbox to prepend a SELECT command before the operation. When unchecked, the operation is sent standalone with CLA. diff --git a/README_RUS.md b/README_RUS.md index 3ab77d3..63aed67 100644 --- a/README_RUS.md +++ b/README_RUS.md @@ -77,6 +77,15 @@ CLA = `A0` (GSM 11.11 / ISO 7816-4). | By DF name / AID | 04 | 00 | AID | | ADF RFM chain | 00 | 00 | FID через запятую | +#### Выбор файла для SELECT + +У каждой строки SELECT есть выбор файла: поле фильтра, переключатель **all files**, корень начала сессии с текущим DF и список файлов по корням (`MF`, `ADF.USIM`, ...). Выбор файла заполняет поля текущего метода; если метод не может выразить выбор, помощник переключается на подходящий - предпочитая **path** (один SELECT), затем **chain** - и сообщает об этом, например `7F106F40` (путь от MF) или `7F20,6F46` (относительная цепочка FID). + +- **Источник списка**: при подключённой карте приоритет у загруженного дерева файлового менеджера (имена карты, проверенное наличие; отсутствующие скрываются). Без карты и для незагруженных ветвей используется поставляемый стандартный список: `uicc_files.json`, собранный из профилей/классов приложений pySim скриптом `pysim_simple_server/uicc_files.py` и проверяемый `tests/test_uicc_files.py`. До запуска **«Проверить все файлы»** список соответствует спецификациям. Пользовательские файлы добавляются всегда. +- **Начало сессии**: неявный текущий DF зависит от TAR, на который отправляется защищённый пакет (UICC Shared File System RFM -> MF, TS 102 226 §7.2; ADF RFM -> свой ADF, §7.3). По умолчанию: MF здесь и ADF.USIM для USIM RFM; меняется для каждой строки. +- **Path** - последовательность FID от MF без идентификатора MF (ISO 7816-4); вариант USIM «from current DF» использует относительный хвост. **Chain** остаётся относительным к текущему DF и следует порядку поиска FID из TS 102 221 §11.1.1.2 (дети, родитель, соседи). +- Корни ADF не выбираются - приложение выбирается по AID, и метод **By AID** остаётся ручным (TS 102 226 §7.1 запрещает P1=`04` для RFM). + #### Опции - **Start with SELECT** — добавить SELECT перед командой. diff --git a/frontend/help-ru.html b/frontend/help-ru.html index fb3215f..5dbe109 100644 --- a/frontend/help-ru.html +++ b/frontend/help-ru.html @@ -94,6 +94,15 @@

Для record-команд режим P2: Absolute (04), Next (02) или Previous (03). Если за Case 4 командой сразу следует строка GET RESPONSE, сборщик цепочки автоматически убирает её байт Le (ETSI TS 102 226 §5.1.1). В правой колонке — панель конвертации (IMSI, MSISDN, ICCID, SPN, PLMN, nibble swap). См. §2.5.

→ Расширенный скрипт отправляет собранную цепочку в конструктор Expanded Script строками C-APDU (строки GET RESPONSE отбрасываются — расширенный формат их не использует, TS 102 226 §5.2.1.1). Приложение UICC Shared File System RFM (TAR B00000) доступно и в компактном, и в расширенном формате — если TAR не настроен на автоопределение формата, используются разные значения TAR (TS 102 226 §7.0/§5.3).

+

Выбор файла для SELECT

+

У каждой строки SELECT под полями метода есть выбор файла: поле фильтра, переключатель all files, корень начала сессии с текущим DF и список файлов, сгруппированный по корню (MF, ADF.USIM, …). Выбор файла заполняет поля текущего метода; если метод не может выразить выбор, помощник переключается на подходящий — предпочитая path (один SELECT), затем chain — и пишет об этом в строке примечания, например файл из другого DF становится 7F106F40 (путь от MF) или 7F20,6F46 (относительная цепочка FID).

+ +

2.2 USIM RFM

CLA = 00 (ETSI TS 102 221). Тот же сборщик цепочки и набор команд, что и SIM, плюс административные команды UICC и формы SEARCH RECORD / INCREASE из TS 102 221: