@ceralive/modem-control 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +341 -0
- package/dist/backend/at-lease.d.ts +59 -0
- package/dist/backend/at-lease.js +118 -0
- package/dist/backend/cell-info.d.ts +46 -0
- package/dist/backend/cell-info.js +124 -0
- package/dist/backend/constants.d.ts +24 -0
- package/{src/backend/constants.ts → dist/backend/constants.js} +4 -9
- package/dist/backend/device-classifier.d.ts +46 -0
- package/dist/backend/device-classifier.js +258 -0
- package/dist/backend/enrichment.d.ts +28 -0
- package/dist/backend/enrichment.js +59 -0
- package/dist/backend/features.d.ts +61 -0
- package/dist/backend/features.js +109 -0
- package/dist/backend/identity-ladder.d.ts +57 -0
- package/dist/backend/identity-ladder.js +158 -0
- package/dist/backend/identity-registry.d.ts +51 -0
- package/dist/backend/identity-registry.js +101 -0
- package/dist/backend/index.d.ts +30 -0
- package/dist/backend/index.js +35 -0
- package/dist/backend/lifecycle-interlock.d.ts +25 -0
- package/dist/backend/lifecycle-interlock.js +18 -0
- package/dist/backend/managed-objects.d.ts +39 -0
- package/dist/backend/managed-objects.js +82 -0
- package/dist/backend/mapping.d.ts +11 -0
- package/dist/backend/mapping.js +148 -0
- package/dist/backend/mm-backend.d.ts +44 -0
- package/dist/backend/mm-backend.js +154 -0
- package/dist/backend/mm-location.d.ts +21 -0
- package/dist/backend/mm-location.js +237 -0
- package/dist/backend/mm-mutations.d.ts +42 -0
- package/dist/backend/mm-mutations.js +259 -0
- package/dist/backend/modem-actor.d.ts +41 -0
- package/dist/backend/modem-actor.js +78 -0
- package/dist/backend/nm-auto-apn.d.ts +54 -0
- package/dist/backend/nm-auto-apn.js +124 -0
- package/dist/backend/nm-gsm-fields.d.ts +23 -0
- package/dist/backend/nm-gsm-fields.js +107 -0
- package/dist/backend/nmcli-nm-port.d.ts +28 -0
- package/dist/backend/nmcli-nm-port.js +173 -0
- package/dist/backend/nmcli-runner.d.ts +24 -0
- package/dist/backend/nmcli-runner.js +35 -0
- package/dist/backend/observer.d.ts +37 -0
- package/dist/backend/observer.js +219 -0
- package/dist/backend/power-contract.d.ts +49 -0
- package/dist/backend/power-contract.js +34 -0
- package/dist/backend/recovery-attribution.d.ts +32 -0
- package/dist/backend/recovery-attribution.js +57 -0
- package/dist/backend/recovery-budget.d.ts +45 -0
- package/dist/backend/recovery-budget.js +44 -0
- package/dist/backend/recovery-ladder.d.ts +94 -0
- package/dist/backend/recovery-ladder.js +116 -0
- package/dist/backend/router-ethernet.d.ts +19 -0
- package/dist/backend/router-ethernet.js +66 -0
- package/dist/backend/row-store.d.ts +13 -0
- package/dist/backend/row-store.js +82 -0
- package/dist/backend/signal-setup.d.ts +30 -0
- package/dist/backend/signal-setup.js +92 -0
- package/dist/backend/sim-unlock.d.ts +13 -0
- package/dist/backend/sim-unlock.js +153 -0
- package/dist/backend/transition-preconditions.d.ts +101 -0
- package/dist/backend/transition-preconditions.js +132 -0
- package/dist/backend/usage/accounting.d.ts +39 -0
- package/dist/backend/usage/accounting.js +73 -0
- package/dist/backend/usage/billing-cycle.d.ts +11 -0
- package/dist/backend/usage/billing-cycle.js +39 -0
- package/dist/backend/usage/boot-id.d.ts +6 -0
- package/{src/backend/usage/boot-id.ts → dist/backend/usage/boot-id.js} +7 -7
- package/dist/backend/usage/index.d.ts +8 -0
- package/dist/backend/usage/index.js +11 -0
- package/dist/backend/usage/policy-store.d.ts +50 -0
- package/dist/backend/usage/policy-store.js +161 -0
- package/dist/backend/usage/policy-write.d.ts +65 -0
- package/dist/backend/usage/policy-write.js +112 -0
- package/dist/backend/usage/proc-net-dev.d.ts +18 -0
- package/{src/backend/usage/proc-net-dev.ts → dist/backend/usage/proc-net-dev.js} +39 -47
- package/dist/backend/usage/sampler.d.ts +75 -0
- package/dist/backend/usage/sampler.js +211 -0
- package/dist/backend/usage/store.d.ts +38 -0
- package/dist/backend/usage/store.js +126 -0
- package/dist/backend/usb-device-snapshot.d.ts +31 -0
- package/dist/backend/usb-device-snapshot.js +1 -0
- package/dist/backend/usb-enumerator.d.ts +21 -0
- package/dist/backend/usb-enumerator.js +153 -0
- package/dist/backend/usb-mode-transition.d.ts +29 -0
- package/dist/backend/usb-mode-transition.js +216 -0
- package/dist/band/band-names.d.ts +42 -0
- package/dist/band/band-names.js +150 -0
- package/dist/band/certification.d.ts +84 -0
- package/dist/band/certification.js +127 -0
- package/dist/band/certified-bands.json +4 -0
- package/dist/band/index.d.ts +2 -0
- package/dist/band/index.js +8 -0
- package/dist/capability/detect.d.ts +52 -0
- package/dist/capability/detect.js +86 -0
- package/dist/capability/five-g-preference.d.ts +104 -0
- package/dist/capability/five-g-preference.js +171 -0
- package/dist/capability/index.d.ts +3 -0
- package/dist/capability/index.js +10 -0
- package/dist/capability/support-claim.d.ts +39 -0
- package/dist/capability/support-claim.js +81 -0
- package/dist/domain/brand.d.ts +10 -0
- package/dist/domain/brand.js +21 -0
- package/dist/domain/errors.d.ts +32 -0
- package/dist/domain/errors.js +48 -0
- package/dist/domain/generation.d.ts +8 -0
- package/dist/domain/generation.js +12 -0
- package/dist/domain/guards.d.ts +6 -0
- package/dist/domain/guards.js +127 -0
- package/dist/domain/identity.d.ts +109 -0
- package/dist/domain/identity.js +86 -0
- package/dist/domain/index.d.ts +14 -0
- package/dist/domain/index.js +18 -0
- package/dist/domain/mm-enums.d.ts +12 -0
- package/dist/domain/mm-enums.js +139 -0
- package/dist/domain/modem-presentation.d.ts +10 -0
- package/dist/domain/modem-presentation.js +39 -0
- package/dist/domain/observation.d.ts +39 -0
- package/dist/domain/observation.js +4 -0
- package/dist/domain/operation.d.ts +118 -0
- package/dist/domain/operation.js +85 -0
- package/dist/domain/physical-identity.d.ts +43 -0
- package/dist/domain/physical-identity.js +113 -0
- package/{src/domain/policy.ts → dist/domain/policy.d.ts} +34 -69
- package/dist/domain/policy.js +38 -0
- package/dist/domain/shadow-divergence.d.ts +27 -0
- package/dist/domain/shadow-divergence.js +70 -0
- package/dist/domain/snapshot.d.ts +53 -0
- package/dist/domain/snapshot.js +75 -0
- package/{src/domain/state.ts → dist/domain/state.d.ts} +23 -122
- package/dist/domain/state.js +38 -0
- package/dist/fcc/coverage.d.ts +63 -0
- package/dist/fcc/coverage.js +102 -0
- package/dist/fcc/index.d.ts +3 -0
- package/dist/fcc/index.js +12 -0
- package/dist/fcc/policy-store.d.ts +40 -0
- package/dist/fcc/policy-store.js +146 -0
- package/dist/fcc/policy-write.d.ts +32 -0
- package/dist/fcc/policy-write.js +37 -0
- package/dist/hardware/hilink-protocol.d.ts +39 -0
- package/dist/hardware/hilink-protocol.js +58 -0
- package/dist/hardware/index.d.ts +3 -0
- package/dist/hardware/index.js +15 -0
- package/dist/hardware/router-parsers.d.ts +89 -0
- package/dist/hardware/router-parsers.js +234 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +27 -0
- package/dist/journal/codec.d.ts +44 -0
- package/dist/journal/codec.js +198 -0
- package/dist/journal/engine.d.ts +28 -0
- package/dist/journal/engine.js +68 -0
- package/dist/journal/entry.d.ts +74 -0
- package/dist/journal/entry.js +56 -0
- package/dist/journal/index.d.ts +6 -0
- package/dist/journal/index.js +6 -0
- package/dist/journal/legacy-ceraui.d.ts +73 -0
- package/dist/journal/legacy-ceraui.js +227 -0
- package/dist/journal/recovery.d.ts +58 -0
- package/dist/journal/recovery.js +117 -0
- package/dist/journal/store.d.ts +55 -0
- package/dist/journal/store.js +150 -0
- package/dist/location/fix-state.d.ts +53 -0
- package/dist/location/fix-state.js +75 -0
- package/dist/location/index.d.ts +2 -0
- package/dist/location/index.js +8 -0
- package/dist/location/nmea.d.ts +10 -0
- package/dist/location/nmea.js +89 -0
- package/dist/observations/envelope.d.ts +63 -0
- package/dist/observations/envelope.js +77 -0
- package/dist/observations/freshness.d.ts +28 -0
- package/dist/observations/freshness.js +76 -0
- package/dist/observations/index.d.ts +13 -0
- package/dist/observations/index.js +24 -0
- package/dist/observations/metric.d.ts +61 -0
- package/dist/observations/metric.js +73 -0
- package/dist/observations/model.d.ts +80 -0
- package/dist/observations/model.js +11 -0
- package/dist/observations/provenance.d.ts +94 -0
- package/dist/observations/provenance.js +67 -0
- package/dist/observations/raw.d.ts +42 -0
- package/dist/observations/raw.js +146 -0
- package/dist/observations/reading.d.ts +51 -0
- package/dist/observations/reading.js +65 -0
- package/dist/observations/sources/hilink.d.ts +10 -0
- package/dist/observations/sources/hilink.js +84 -0
- package/dist/observations/sources/modemmanager.d.ts +18 -0
- package/dist/observations/sources/modemmanager.js +239 -0
- package/dist/observations/sources/router-shared.d.ts +29 -0
- package/dist/observations/sources/router-shared.js +68 -0
- package/dist/observations/sources/ufi.d.ts +10 -0
- package/dist/observations/sources/ufi.js +111 -0
- package/dist/observations/sources/zte.d.ts +7 -0
- package/dist/observations/sources/zte.js +71 -0
- package/dist/observations/state-separation.d.ts +64 -0
- package/dist/observations/state-separation.js +52 -0
- package/dist/operation-ids.d.ts +2 -0
- package/dist/operation-ids.js +26 -0
- package/dist/operations/contracts.d.ts +72 -0
- package/dist/operations/contracts.js +1 -0
- package/dist/operations/index.d.ts +1 -0
- package/dist/operations/index.js +1 -0
- package/dist/operations/operation-engine.d.ts +16 -0
- package/dist/operations/operation-engine.js +194 -0
- package/dist/ports/index.d.ts +12 -0
- package/{src/ports/index.ts → dist/ports/index.js} +12 -8
- package/dist/ports/location.d.ts +87 -0
- package/dist/ports/location.js +36 -0
- package/dist/ports/modem-manager.d.ts +89 -0
- package/dist/ports/modem-manager.js +9 -0
- package/dist/ports/mutation-admission.d.ts +27 -0
- package/dist/ports/mutation-admission.js +9 -0
- package/dist/ports/network-manager.d.ts +68 -0
- package/dist/ports/network-manager.js +13 -0
- package/{src/ports/observation.ts → dist/ports/observation.d.ts} +16 -27
- package/dist/ports/observation.js +7 -0
- package/dist/ports/ops.d.ts +44 -0
- package/dist/ports/ops.js +16 -0
- package/{src/ports/receipts.ts → dist/ports/receipts.d.ts} +5 -27
- package/dist/ports/receipts.js +9 -0
- package/dist/ports/reconcile.d.ts +33 -0
- package/dist/ports/reconcile.js +200 -0
- package/dist/ports/resource-ownership.d.ts +29 -0
- package/dist/ports/resource-ownership.js +1 -0
- package/dist/ports/router.d.ts +19 -0
- package/dist/ports/router.js +7 -0
- package/dist/ports/sms.d.ts +64 -0
- package/dist/ports/sms.js +24 -0
- package/dist/ports/uhubctl.d.ts +6 -0
- package/dist/ports/uhubctl.js +1 -0
- package/dist/providers/contracts.d.ts +124 -0
- package/dist/providers/contracts.js +10 -0
- package/dist/providers/huawei-hilink/index.d.ts +2 -0
- package/dist/providers/huawei-hilink/index.js +2 -0
- package/dist/providers/huawei-hilink/operations.d.ts +20 -0
- package/dist/providers/huawei-hilink/operations.js +56 -0
- package/dist/providers/huawei-hilink/provider.d.ts +52 -0
- package/dist/providers/huawei-hilink/provider.js +76 -0
- package/dist/providers/huawei-hilink/runtime.d.ts +22 -0
- package/dist/providers/huawei-hilink/runtime.js +171 -0
- package/dist/providers/huawei-hilink/session.d.ts +28 -0
- package/dist/providers/huawei-hilink/session.js +120 -0
- package/dist/providers/huawei-hilink/transport.d.ts +19 -0
- package/dist/providers/huawei-hilink/transport.js +1 -0
- package/dist/providers/index.d.ts +8 -0
- package/dist/providers/index.js +8 -0
- package/dist/providers/matcher.d.ts +3 -0
- package/dist/providers/matcher.js +205 -0
- package/dist/providers/modem-manager/errors.d.ts +7 -0
- package/dist/providers/modem-manager/errors.js +37 -0
- package/dist/providers/modem-manager/generic-operations.d.ts +10 -0
- package/dist/providers/modem-manager/generic-operations.js +209 -0
- package/dist/providers/modem-manager/index.d.ts +4 -0
- package/dist/providers/modem-manager/index.js +4 -0
- package/dist/providers/modem-manager/module-operations.d.ts +21 -0
- package/dist/providers/modem-manager/module-operations.js +118 -0
- package/dist/providers/modem-manager/provider.d.ts +41 -0
- package/dist/providers/modem-manager/provider.js +155 -0
- package/dist/providers/modem-manager/runtime-composition-operation.d.ts +32 -0
- package/dist/providers/modem-manager/runtime-composition-operation.js +151 -0
- package/dist/providers/modem-manager/snapshot.d.ts +5 -0
- package/dist/providers/modem-manager/snapshot.js +204 -0
- package/dist/providers/modem-manager/types.d.ts +137 -0
- package/dist/providers/modem-manager/types.js +1 -0
- package/dist/providers/network-manager/adapter.d.ts +71 -0
- package/dist/providers/network-manager/adapter.js +348 -0
- package/dist/providers/network-manager/index.d.ts +2 -0
- package/dist/providers/network-manager/index.js +2 -0
- package/dist/providers/network-manager/types.d.ts +171 -0
- package/dist/providers/network-manager/types.js +77 -0
- package/dist/providers/registry.d.ts +13 -0
- package/dist/providers/registry.js +33 -0
- package/dist/providers/ufi-himi/index.d.ts +6 -0
- package/dist/providers/ufi-himi/index.js +6 -0
- package/dist/providers/ufi-himi/operations.d.ts +41 -0
- package/dist/providers/ufi-himi/operations.js +66 -0
- package/dist/providers/ufi-himi/prohibitions.d.ts +62 -0
- package/dist/providers/ufi-himi/prohibitions.js +88 -0
- package/dist/providers/ufi-himi/provider.d.ts +41 -0
- package/dist/providers/ufi-himi/provider.js +204 -0
- package/dist/providers/ufi-himi/qualcomm-evidence.d.ts +32 -0
- package/dist/providers/ufi-himi/qualcomm-evidence.js +51 -0
- package/dist/providers/ufi-himi/session.d.ts +46 -0
- package/dist/providers/ufi-himi/session.js +92 -0
- package/dist/providers/ufi-himi/transport.d.ts +29 -0
- package/dist/providers/ufi-himi/transport.js +25 -0
- package/dist/providers/zte-goform/index.d.ts +2 -0
- package/dist/providers/zte-goform/index.js +2 -0
- package/dist/providers/zte-goform/provider.d.ts +56 -0
- package/dist/providers/zte-goform/provider.js +101 -0
- package/dist/providers/zte-goform/session.d.ts +23 -0
- package/dist/providers/zte-goform/session.js +197 -0
- package/dist/providers/zte-goform/transport.d.ts +16 -0
- package/dist/providers/zte-goform/transport.js +1 -0
- package/dist/radio/band-truth.d.ts +50 -0
- package/dist/radio/band-truth.js +92 -0
- package/dist/radio/index.d.ts +3 -0
- package/dist/radio/index.js +10 -0
- package/dist/radio/mode-combinations.d.ts +88 -0
- package/dist/radio/mode-combinations.js +198 -0
- package/dist/radio/mode-truth.d.ts +67 -0
- package/dist/radio/mode-truth.js +112 -0
- package/dist/redact.d.ts +15 -0
- package/dist/redact.js +189 -0
- package/dist/safety/composition-root.d.ts +28 -0
- package/dist/safety/composition-root.js +65 -0
- package/dist/safety/flock-resource-ownership.d.ts +11 -0
- package/dist/safety/flock-resource-ownership.js +138 -0
- package/dist/safety/index.d.ts +2 -0
- package/dist/safety/index.js +2 -0
- package/dist/sms/dbus-messaging.d.ts +17 -0
- package/dist/sms/dbus-messaging.js +185 -0
- package/dist/sms/inbox-store.d.ts +10 -0
- package/dist/sms/inbox-store.js +82 -0
- package/dist/sms/index.d.ts +4 -0
- package/dist/sms/index.js +10 -0
- package/dist/sms/mmcli-parse.d.ts +54 -0
- package/dist/sms/mmcli-parse.js +224 -0
- package/dist/sms/normalize.d.ts +42 -0
- package/dist/sms/normalize.js +95 -0
- package/dist/testing/domain-fakes.d.ts +58 -0
- package/dist/testing/domain-fakes.js +98 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +17 -0
- package/dist/testing/provider-fakes.d.ts +45 -0
- package/dist/testing/provider-fakes.js +64 -0
- package/dist/transport/calls.d.ts +9 -0
- package/dist/transport/calls.js +88 -0
- package/dist/transport/codec.d.ts +3 -0
- package/dist/transport/codec.js +207 -0
- package/dist/transport/dbus-native.d.ts +57 -0
- package/dist/transport/dbus-native.js +17 -0
- package/dist/transport/errors.d.ts +21 -0
- package/{src/transport/errors.ts → dist/transport/errors.js} +34 -46
- package/dist/transport/index.d.ts +4 -0
- package/dist/transport/index.js +9 -0
- package/dist/transport/signals.d.ts +15 -0
- package/dist/transport/signals.js +123 -0
- package/dist/transport/signature.d.ts +7 -0
- package/dist/transport/signature.js +94 -0
- package/dist/transport/transport.d.ts +2 -0
- package/dist/transport/transport.js +202 -0
- package/dist/transport/types.d.ts +61 -0
- package/dist/transport/types.js +19 -0
- package/dist/usb-mode/catalog-schema.d.ts +139 -0
- package/dist/usb-mode/catalog-schema.js +97 -0
- package/dist/usb-mode/catalog.d.ts +21 -0
- package/{src/usb-mode/catalog.ts → dist/usb-mode/catalog.js} +10 -32
- package/dist/usb-mode/certified-catalog.json +67 -0
- package/dist/usb-mode/index.d.ts +6 -0
- package/dist/usb-mode/index.js +16 -0
- package/dist/usb-mode/ingestion.d.ts +111 -0
- package/dist/usb-mode/ingestion.js +187 -0
- package/dist/usb-mode/promotion-review.d.ts +21 -0
- package/dist/usb-mode/promotion-review.js +87 -0
- package/dist/usb-mode/runtime-capability.d.ts +59 -0
- package/dist/usb-mode/runtime-capability.js +157 -0
- package/dist/usb-mode/usb-devices-parse.d.ts +36 -0
- package/dist/usb-mode/usb-devices-parse.js +157 -0
- package/dist/ussd/calls.d.ts +32 -0
- package/dist/ussd/calls.js +96 -0
- package/dist/ussd/index.d.ts +5 -0
- package/dist/ussd/index.js +12 -0
- package/dist/ussd/mm-ussd.d.ts +37 -0
- package/dist/ussd/mm-ussd.js +205 -0
- package/dist/ussd/refusal.d.ts +53 -0
- package/dist/ussd/refusal.js +154 -0
- package/dist/ussd/registration.d.ts +20 -0
- package/dist/ussd/registration.js +101 -0
- package/dist/ussd/session.d.ts +106 -0
- package/dist/ussd/session.js +163 -0
- package/package.json +38 -4
- package/src/backend/at-lease.test.ts +0 -106
- package/src/backend/at-lease.ts +0 -158
- package/src/backend/cell-info.test.ts +0 -154
- package/src/backend/cell-info.ts +0 -160
- package/src/backend/device-classifier.test.ts +0 -168
- package/src/backend/device-classifier.ts +0 -248
- package/src/backend/enrichment.ts +0 -96
- package/src/backend/features.test.ts +0 -162
- package/src/backend/features.ts +0 -179
- package/src/backend/identity-ladder.test.ts +0 -117
- package/src/backend/identity-ladder.ts +0 -221
- package/src/backend/identity-registry.test.ts +0 -89
- package/src/backend/identity-registry.ts +0 -151
- package/src/backend/index.ts +0 -236
- package/src/backend/lifecycle-interlock.ts +0 -38
- package/src/backend/managed-objects.ts +0 -108
- package/src/backend/mapping.ts +0 -160
- package/src/backend/mm-backend.ts +0 -191
- package/src/backend/mm-mutations.ts +0 -228
- package/src/backend/modem-actor.test.ts +0 -95
- package/src/backend/modem-actor.ts +0 -112
- package/src/backend/nm-auto-apn.ts +0 -161
- package/src/backend/nm-gsm-fields.ts +0 -122
- package/src/backend/nmcli-nm-port.ts +0 -228
- package/src/backend/nmcli-runner.ts +0 -52
- package/src/backend/observer.ts +0 -297
- package/src/backend/power-contract.test.ts +0 -40
- package/src/backend/power-contract.ts +0 -83
- package/src/backend/recovery-attribution.test.ts +0 -102
- package/src/backend/recovery-attribution.ts +0 -86
- package/src/backend/recovery-budget.test.ts +0 -64
- package/src/backend/recovery-budget.ts +0 -84
- package/src/backend/recovery-ladder.test.ts +0 -257
- package/src/backend/recovery-ladder.ts +0 -249
- package/src/backend/router-ethernet.test.ts +0 -71
- package/src/backend/router-ethernet.ts +0 -90
- package/src/backend/row-store.ts +0 -105
- package/src/backend/signal-setup.ts +0 -112
- package/src/backend/sim-unlock.ts +0 -193
- package/src/backend/transition-preconditions.ts +0 -149
- package/src/backend/uhubctl-power-hook.test.ts +0 -274
- package/src/backend/uhubctl-power-hook.ts +0 -377
- package/src/backend/usage/accounting.test.ts +0 -147
- package/src/backend/usage/accounting.ts +0 -123
- package/src/backend/usage/billing-cycle.test.ts +0 -62
- package/src/backend/usage/billing-cycle.ts +0 -45
- package/src/backend/usage/index.ts +0 -60
- package/src/backend/usage/policy-store.test.ts +0 -164
- package/src/backend/usage/policy-store.ts +0 -216
- package/src/backend/usage/policy-write.test.ts +0 -198
- package/src/backend/usage/policy-write.ts +0 -207
- package/src/backend/usage/proc-net-dev.test.ts +0 -56
- package/src/backend/usage/sampler.test.ts +0 -327
- package/src/backend/usage/sampler.ts +0 -282
- package/src/backend/usage/store.test.ts +0 -148
- package/src/backend/usage/store.ts +0 -177
- package/src/backend/usb-enumerator.test.ts +0 -87
- package/src/backend/usb-enumerator.ts +0 -181
- package/src/backend/usb-mode-transition.test.ts +0 -323
- package/src/backend/usb-mode-transition.ts +0 -253
- package/src/domain/brand.ts +0 -29
- package/src/domain/errors.ts +0 -77
- package/src/domain/guards.test.ts +0 -218
- package/src/domain/guards.ts +0 -144
- package/src/domain/identity.test.ts +0 -83
- package/src/domain/identity.ts +0 -165
- package/src/domain/index.ts +0 -12
- package/src/domain/snapshot.test.ts +0 -266
- package/src/domain/snapshot.ts +0 -120
- package/src/index.test.ts +0 -6
- package/src/index.ts +0 -15
- package/src/ports/README.md +0 -61
- package/src/ports/forbidden-surface.test.ts +0 -241
- package/src/ports/modem-manager.ts +0 -72
- package/src/ports/network-manager.ts +0 -87
- package/src/ports/ops.ts +0 -60
- package/src/ports/ops.type-test.ts +0 -39
- package/src/ports/receipts.test.ts +0 -153
- package/src/ports/reconcile.test.ts +0 -152
- package/src/ports/reconcile.ts +0 -338
- package/src/ports/router.ts +0 -29
- package/src/redact.test.ts +0 -82
- package/src/redact.ts +0 -73
- package/src/transport/README.md +0 -65
- package/src/transport/calls.ts +0 -113
- package/src/transport/characterization.test.ts +0 -260
- package/src/transport/codec.test.ts +0 -118
- package/src/transport/codec.ts +0 -240
- package/src/transport/conformance-python.test.ts +0 -152
- package/src/transport/conformance-same-lib.test.ts +0 -115
- package/src/transport/dbus-native-lib.d.ts +0 -19
- package/src/transport/dbus-native.ts +0 -85
- package/src/transport/index.ts +0 -30
- package/src/transport/no-library-leak.test.ts +0 -61
- package/src/transport/reliability.test.ts +0 -173
- package/src/transport/signals.ts +0 -150
- package/src/transport/signature.ts +0 -110
- package/src/transport/test-support/fake-service.ts +0 -168
- package/src/transport/test-support/independent-producer.py +0 -110
- package/src/transport/test-support/private-bus.ts +0 -66
- package/src/transport/transport.ts +0 -250
- package/src/transport/types.ts +0 -118
- package/src/usb-mode/catalog-schema.test.ts +0 -181
- package/src/usb-mode/catalog-schema.ts +0 -113
- package/src/usb-mode/certified-catalog.json +0 -67
- package/src/usb-mode/index.ts +0 -58
- package/src/usb-mode/ingestion.test.ts +0 -268
- package/src/usb-mode/ingestion.ts +0 -297
- package/src/usb-mode/promotion-review.ts +0 -117
- package/src/usb-mode/usb-devices-parse.ts +0 -196
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Independent D-Bus producer for transport conformance half (b).
|
|
3
|
-
|
|
4
|
-
A different implementation on the wire than the JavaScript library under test: this uses
|
|
5
|
-
the `dbus-python` bindings (`python3-dbus`) plus a GLib main loop. If our TypeScript codec
|
|
6
|
-
agrees with THIS producer as well as with the same-library fake, the codec is correct, not
|
|
7
|
-
merely self-consistent.
|
|
8
|
-
|
|
9
|
-
It exercises the shapes the plan calls out: the real ModemManager `GetManagedObjects`
|
|
10
|
-
shape `a{oa{sa{sv}}}`, 64-bit `x`/`t` values above 2**53, variants, and a
|
|
11
|
-
`PropertiesChanged` signal that carries an invalidated-properties array (not just changed
|
|
12
|
-
values).
|
|
13
|
-
|
|
14
|
-
Connects to the bus named by `DBUS_SESSION_BUS_ADDRESS` (set by `dbus-run-session`),
|
|
15
|
-
claims a well-known name, prints `READY` on stdout once serving, then runs the main loop.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
import sys
|
|
19
|
-
|
|
20
|
-
import dbus
|
|
21
|
-
import dbus.mainloop.glib
|
|
22
|
-
import dbus.service
|
|
23
|
-
from gi.repository import GLib
|
|
24
|
-
|
|
25
|
-
BUS_NAME = "tv.ceralive.ModemStackPy"
|
|
26
|
-
OBJECT_PATH = "/tv/ceralive/pyfake"
|
|
27
|
-
IFACE = "tv.ceralive.ModemStackPy.Conformance"
|
|
28
|
-
PROPERTIES_IFACE = "org.freedesktop.DBus.Properties"
|
|
29
|
-
|
|
30
|
-
INT64_MAX = 2**63 - 1
|
|
31
|
-
UINT64_MAX = 2**64 - 1
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class ConformanceProducer(dbus.service.Object):
|
|
35
|
-
@dbus.service.method(IFACE, in_signature="", out_signature="a{oa{sa{sv}}}")
|
|
36
|
-
def GetManagedObjects(self):
|
|
37
|
-
return dbus.Dictionary(
|
|
38
|
-
{
|
|
39
|
-
dbus.ObjectPath("/org/freedesktop/ModemManager1/Modem/0"): dbus.Dictionary(
|
|
40
|
-
{
|
|
41
|
-
"org.freedesktop.ModemManager1.Modem": dbus.Dictionary(
|
|
42
|
-
{
|
|
43
|
-
"SupportedCapabilities": dbus.UInt64(UINT64_MAX, variant_level=1),
|
|
44
|
-
"MaxBearers": dbus.Int64(-INT64_MAX, variant_level=1),
|
|
45
|
-
"SignalQuality": dbus.UInt32(87, variant_level=1),
|
|
46
|
-
"DeviceIdentifier": dbus.String("py-device-0", variant_level=1),
|
|
47
|
-
},
|
|
48
|
-
signature="sv",
|
|
49
|
-
),
|
|
50
|
-
},
|
|
51
|
-
signature="sa{sv}",
|
|
52
|
-
),
|
|
53
|
-
},
|
|
54
|
-
signature="oa{sa{sv}}",
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
@dbus.service.method(IFACE, in_signature="", out_signature="x")
|
|
58
|
-
def GetInt64(self):
|
|
59
|
-
return dbus.Int64(INT64_MAX)
|
|
60
|
-
|
|
61
|
-
@dbus.service.method(IFACE, in_signature="", out_signature="t")
|
|
62
|
-
def GetUint64(self):
|
|
63
|
-
return dbus.UInt64(UINT64_MAX)
|
|
64
|
-
|
|
65
|
-
@dbus.service.method(IFACE, in_signature="", out_signature="v")
|
|
66
|
-
def GetVariant(self):
|
|
67
|
-
return dbus.UInt64(UINT64_MAX, variant_level=1)
|
|
68
|
-
|
|
69
|
-
@dbus.service.method(IFACE, in_signature="x", out_signature="x")
|
|
70
|
-
def EchoInt64(self, value):
|
|
71
|
-
return dbus.Int64(value)
|
|
72
|
-
|
|
73
|
-
@dbus.service.method(IFACE, in_signature="t", out_signature="t")
|
|
74
|
-
def EchoUint64(self, value):
|
|
75
|
-
return dbus.UInt64(value)
|
|
76
|
-
|
|
77
|
-
@dbus.service.method(IFACE, in_signature="t", out_signature="s")
|
|
78
|
-
def DescribeUint64(self, value):
|
|
79
|
-
return dbus.String(str(int(value)))
|
|
80
|
-
|
|
81
|
-
@dbus.service.method(IFACE, in_signature="", out_signature="")
|
|
82
|
-
def TriggerPropertiesChanged(self):
|
|
83
|
-
changed = dbus.Dictionary(
|
|
84
|
-
{
|
|
85
|
-
"AccessTechnologies": dbus.UInt64(UINT64_MAX, variant_level=1),
|
|
86
|
-
"SignalQuality": dbus.UInt32(42, variant_level=1),
|
|
87
|
-
},
|
|
88
|
-
signature="sv",
|
|
89
|
-
)
|
|
90
|
-
invalidated = dbus.Array(["OperatorName", "OperatorCode"], signature="s")
|
|
91
|
-
self.PropertiesChanged(IFACE, changed, invalidated)
|
|
92
|
-
|
|
93
|
-
@dbus.service.signal(PROPERTIES_IFACE, signature="sa{sv}as")
|
|
94
|
-
def PropertiesChanged(self, interface_name, changed_properties, invalidated_properties):
|
|
95
|
-
pass
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def main():
|
|
99
|
-
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
|
100
|
-
bus = dbus.SessionBus()
|
|
101
|
-
name = dbus.service.BusName(BUS_NAME, bus)
|
|
102
|
-
ConformanceProducer(bus, OBJECT_PATH)
|
|
103
|
-
# Signal readiness only after the name is owned and the object is exported.
|
|
104
|
-
sys.stdout.write("READY\n")
|
|
105
|
-
sys.stdout.flush()
|
|
106
|
-
GLib.MainLoop().run()
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if __name__ == "__main__":
|
|
110
|
-
main()
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// A dedicated private `dbus-daemon` at a FIXED socket path, for the reconnect test.
|
|
2
|
-
//
|
|
3
|
-
// The outer `dbus-run-session` bus is shared by the whole `bun test` run, so the
|
|
4
|
-
// destructive kill/restart cannot happen there. This helper owns a throwaway daemon we
|
|
5
|
-
// can kill and respawn at the same socket path, so the transport reconnects to "the same
|
|
6
|
-
// bus" exactly as it would after a real bus restart on a device.
|
|
7
|
-
|
|
8
|
-
import { existsSync, mkdtempSync, rmSync } from 'node:fs';
|
|
9
|
-
import { tmpdir } from 'node:os';
|
|
10
|
-
import { join } from 'node:path';
|
|
11
|
-
|
|
12
|
-
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
|
|
13
|
-
|
|
14
|
-
export class PrivateBus {
|
|
15
|
-
readonly socket: string;
|
|
16
|
-
readonly address: string;
|
|
17
|
-
readonly #dir: string;
|
|
18
|
-
#proc: ReturnType<typeof Bun.spawn> | null = null;
|
|
19
|
-
|
|
20
|
-
constructor() {
|
|
21
|
-
this.#dir = mkdtempSync(join(tmpdir(), 'ceralive-dbus-'));
|
|
22
|
-
this.socket = join(this.#dir, 'bus');
|
|
23
|
-
this.address = `unix:path=${this.socket}`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async start(): Promise<void> {
|
|
27
|
-
// A SIGKILL leaves the socket file behind; dbus-daemon refuses to bind over it.
|
|
28
|
-
if (existsSync(this.socket)) {
|
|
29
|
-
rmSync(this.socket, { force: true });
|
|
30
|
-
}
|
|
31
|
-
this.#proc = Bun.spawn(
|
|
32
|
-
['dbus-daemon', '--session', `--address=${this.address}`, '--nofork', '--nopidfile'],
|
|
33
|
-
{ stdout: 'ignore', stderr: 'ignore' },
|
|
34
|
-
);
|
|
35
|
-
await this.#waitForSocket();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
kill(): void {
|
|
39
|
-
this.#proc?.kill('SIGKILL');
|
|
40
|
-
this.#proc = null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async restart(): Promise<void> {
|
|
44
|
-
this.kill();
|
|
45
|
-
await sleep(50);
|
|
46
|
-
await this.start();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async stop(): Promise<void> {
|
|
50
|
-
this.kill();
|
|
51
|
-
await sleep(20);
|
|
52
|
-
rmSync(this.#dir, { recursive: true, force: true });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async #waitForSocket(): Promise<void> {
|
|
56
|
-
for (let attempt = 0; attempt < 300; attempt += 1) {
|
|
57
|
-
if (existsSync(this.socket)) {
|
|
58
|
-
// Socket exists → daemon is listening; a short grace covers the accept race.
|
|
59
|
-
await sleep(30);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
await sleep(10);
|
|
63
|
-
}
|
|
64
|
-
throw new Error(`private dbus-daemon socket ${this.socket} never appeared`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
// The D-Bus transport seam implementation.
|
|
2
|
-
//
|
|
3
|
-
// Wraps `@httptoolkit/dbus-native` behind the `DbusTransport` interface. This module owns the
|
|
4
|
-
// connection lifecycle — handshake, a reconnect loop that re-issues every match rule after a
|
|
5
|
-
// bus restart, and teardown — and delegates method-call dispatch to `./calls` and signal
|
|
6
|
-
// subscription/match-rule tracking to `./signals`. Its single `message` listener fans out to
|
|
7
|
-
// the signal registry, so subscribing never grows the listener count (the 100-cycle leak check).
|
|
8
|
-
|
|
9
|
-
import { EventEmitter } from 'node:events';
|
|
10
|
-
import { CallDispatcher, DEFAULT_CALL_TIMEOUT_MS } from './calls';
|
|
11
|
-
import {
|
|
12
|
-
type CreateClientOptions,
|
|
13
|
-
createClient,
|
|
14
|
-
type RawBus,
|
|
15
|
-
type RawMessage,
|
|
16
|
-
} from './dbus-native';
|
|
17
|
-
import { DisconnectedError, TransportError } from './errors';
|
|
18
|
-
import { SignalRegistry } from './signals';
|
|
19
|
-
import type {
|
|
20
|
-
DbusTransport,
|
|
21
|
-
DbusTransportOptions,
|
|
22
|
-
MethodCall,
|
|
23
|
-
MethodReply,
|
|
24
|
-
SignalListener,
|
|
25
|
-
SignalSpec,
|
|
26
|
-
Subscription,
|
|
27
|
-
TransportEvent,
|
|
28
|
-
} from './types';
|
|
29
|
-
|
|
30
|
-
type State = 'idle' | 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'closed';
|
|
31
|
-
|
|
32
|
-
interface ResolvedReconnect {
|
|
33
|
-
readonly enabled: boolean;
|
|
34
|
-
readonly initialDelayMs: number;
|
|
35
|
-
readonly maxDelayMs: number;
|
|
36
|
-
readonly maxAttempts: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Bound a single connect/auth attempt so a stalled handshake cannot freeze the reconnect
|
|
40
|
-
// loop. A local unix-socket D-Bus connect completes in milliseconds; 2s is ample headroom
|
|
41
|
-
// while keeping reconnect responsive after a bus restart.
|
|
42
|
-
const CONNECT_TIMEOUT_MS = 2_000;
|
|
43
|
-
const DEFAULT_RECONNECT: ResolvedReconnect = {
|
|
44
|
-
enabled: true,
|
|
45
|
-
initialDelayMs: 50,
|
|
46
|
-
maxDelayMs: 2_000,
|
|
47
|
-
maxAttempts: 0,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
|
|
51
|
-
|
|
52
|
-
class DbusTransportImpl implements DbusTransport {
|
|
53
|
-
readonly #options: DbusTransportOptions;
|
|
54
|
-
readonly #reconnect: ResolvedReconnect;
|
|
55
|
-
readonly #emitter = new EventEmitter();
|
|
56
|
-
readonly #calls: CallDispatcher;
|
|
57
|
-
readonly #signals: SignalRegistry;
|
|
58
|
-
|
|
59
|
-
#bus: RawBus | null = null;
|
|
60
|
-
#state: State = 'idle';
|
|
61
|
-
#closing = false;
|
|
62
|
-
|
|
63
|
-
// Bound once so the same references can be detached from a dead connection.
|
|
64
|
-
readonly #onMessage = (message: RawMessage): void => this.#signals.dispatch(message);
|
|
65
|
-
readonly #onConnectionError = (cause: unknown): void =>
|
|
66
|
-
this.#handleDrop(cause instanceof Error ? cause : new DisconnectedError(String(cause)));
|
|
67
|
-
readonly #onConnectionEnd = (): void =>
|
|
68
|
-
this.#handleDrop(new DisconnectedError('bus connection ended'));
|
|
69
|
-
|
|
70
|
-
constructor(options: DbusTransportOptions) {
|
|
71
|
-
this.#options = options;
|
|
72
|
-
this.#calls = new CallDispatcher(options.callTimeoutMs ?? DEFAULT_CALL_TIMEOUT_MS);
|
|
73
|
-
this.#signals = new SignalRegistry({
|
|
74
|
-
currentBus: () => this.#bus,
|
|
75
|
-
isConnected: () => this.#state === 'connected',
|
|
76
|
-
emitError: (error) => this.#emitter.emit('error', error),
|
|
77
|
-
});
|
|
78
|
-
this.#reconnect = {
|
|
79
|
-
enabled: options.reconnect?.enabled ?? DEFAULT_RECONNECT.enabled,
|
|
80
|
-
initialDelayMs: options.reconnect?.initialDelayMs ?? DEFAULT_RECONNECT.initialDelayMs,
|
|
81
|
-
maxDelayMs: options.reconnect?.maxDelayMs ?? DEFAULT_RECONNECT.maxDelayMs,
|
|
82
|
-
maxAttempts: options.reconnect?.maxAttempts ?? DEFAULT_RECONNECT.maxAttempts,
|
|
83
|
-
};
|
|
84
|
-
// Avoid MaxListeners warnings when many consumers observe transport events.
|
|
85
|
-
this.#emitter.setMaxListeners(0);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async connect(): Promise<void> {
|
|
89
|
-
if (this.#state === 'connected') {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (this.#closing) {
|
|
93
|
-
throw new TransportError('Transport is closed');
|
|
94
|
-
}
|
|
95
|
-
this.#state = 'connecting';
|
|
96
|
-
await this.#establish();
|
|
97
|
-
this.#emitter.emit('connected');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
isConnected(): boolean {
|
|
101
|
-
return this.#state === 'connected';
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async disconnect(): Promise<void> {
|
|
105
|
-
this.#closing = true;
|
|
106
|
-
this.#state = 'closed';
|
|
107
|
-
const bus = this.#bus;
|
|
108
|
-
this.#bus = null;
|
|
109
|
-
this.#calls.rejectAll(new DisconnectedError('transport closed'));
|
|
110
|
-
if (bus) {
|
|
111
|
-
this.#quiesce(bus);
|
|
112
|
-
await bus.disconnect().catch(() => undefined);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
callMethod(call: MethodCall): Promise<MethodReply> {
|
|
117
|
-
return this.#calls.call(this.#bus, this.#state === 'connected', call);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
subscribeSignal(spec: SignalSpec, listener: SignalListener): Promise<Subscription> {
|
|
121
|
-
return this.#signals.subscribe(spec, listener);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
subscriptionCount(): number {
|
|
125
|
-
return this.#signals.count();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
on(event: TransportEvent, handler: (payload?: unknown) => void): void {
|
|
129
|
-
this.#emitter.on(event, handler);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
off(event: TransportEvent, handler: (payload?: unknown) => void): void {
|
|
133
|
-
this.#emitter.off(event, handler);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// ── internals ──────────────────────────────────────────────────────────────────
|
|
137
|
-
|
|
138
|
-
async #establish(): Promise<void> {
|
|
139
|
-
const options: CreateClientOptions = { ReturnLongjs: true };
|
|
140
|
-
if (this.#options.socket !== undefined) {
|
|
141
|
-
options.socket = this.#options.socket;
|
|
142
|
-
} else if (this.#options.busAddress !== undefined) {
|
|
143
|
-
options.busAddress = this.#options.busAddress;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const bus = createClient(options);
|
|
147
|
-
try {
|
|
148
|
-
await new Promise<void>((resolve, reject) => {
|
|
149
|
-
const onConnect = (): void => {
|
|
150
|
-
cleanup();
|
|
151
|
-
resolve();
|
|
152
|
-
};
|
|
153
|
-
const onError = (error: unknown): void => {
|
|
154
|
-
cleanup();
|
|
155
|
-
reject(error instanceof Error ? error : new TransportError(String(error)));
|
|
156
|
-
};
|
|
157
|
-
const timer = setTimeout(() => {
|
|
158
|
-
cleanup();
|
|
159
|
-
reject(new TransportError(`bus connect timed out after ${CONNECT_TIMEOUT_MS}ms`));
|
|
160
|
-
}, CONNECT_TIMEOUT_MS);
|
|
161
|
-
const cleanup = (): void => {
|
|
162
|
-
clearTimeout(timer);
|
|
163
|
-
bus.connection.removeListener('connect', onConnect);
|
|
164
|
-
bus.connection.removeListener('error', onError);
|
|
165
|
-
};
|
|
166
|
-
bus.connection.once('connect', onConnect);
|
|
167
|
-
bus.connection.once('error', onError);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
bus.connection.on('message', this.#onMessage as (...args: unknown[]) => void);
|
|
171
|
-
bus.connection.on('error', this.#onConnectionError);
|
|
172
|
-
bus.connection.on('end', this.#onConnectionEnd);
|
|
173
|
-
|
|
174
|
-
// Re-issue every live match rule so a reconnect resubscribes transparently.
|
|
175
|
-
await this.#signals.reissueRules(bus);
|
|
176
|
-
|
|
177
|
-
this.#bus = bus;
|
|
178
|
-
this.#state = 'connected';
|
|
179
|
-
} catch (error) {
|
|
180
|
-
this.#detachHandlers(bus);
|
|
181
|
-
bus.connection.removeAllListeners();
|
|
182
|
-
bus.connection.on('error', () => undefined);
|
|
183
|
-
try {
|
|
184
|
-
bus.connection.end();
|
|
185
|
-
} catch {
|
|
186
|
-
// The half-open connection is already dead; nothing to close.
|
|
187
|
-
}
|
|
188
|
-
throw error;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
#detachHandlers(bus: RawBus): void {
|
|
193
|
-
bus.connection.removeListener('message', this.#onMessage as (...args: unknown[]) => void);
|
|
194
|
-
bus.connection.removeListener('error', this.#onConnectionError);
|
|
195
|
-
bus.connection.removeListener('end', this.#onConnectionEnd);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Detach our handlers from a dead connection, then swallow any late socket error it
|
|
199
|
-
// still emits — without a listener, Node re-throws an EventEmitter 'error' and crashes
|
|
200
|
-
// the process mid-reconnect.
|
|
201
|
-
#quiesce(bus: RawBus): void {
|
|
202
|
-
this.#detachHandlers(bus);
|
|
203
|
-
bus.connection.on('error', () => undefined);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
#handleDrop(cause: unknown): void {
|
|
207
|
-
if (this.#closing) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (this.#state === 'disconnected' || this.#state === 'reconnecting') {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
this.#state = 'disconnected';
|
|
214
|
-
if (this.#bus) {
|
|
215
|
-
this.#quiesce(this.#bus);
|
|
216
|
-
}
|
|
217
|
-
this.#bus = null;
|
|
218
|
-
this.#calls.rejectAll(cause);
|
|
219
|
-
this.#emitter.emit('disconnected', cause);
|
|
220
|
-
if (this.#reconnect.enabled) {
|
|
221
|
-
void this.#reconnectLoop();
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
async #reconnectLoop(): Promise<void> {
|
|
226
|
-
this.#state = 'reconnecting';
|
|
227
|
-
let delay = this.#reconnect.initialDelayMs;
|
|
228
|
-
let attempt = 0;
|
|
229
|
-
while (!this.#closing) {
|
|
230
|
-
attempt += 1;
|
|
231
|
-
try {
|
|
232
|
-
await this.#establish();
|
|
233
|
-
this.#emitter.emit('reconnected');
|
|
234
|
-
return;
|
|
235
|
-
} catch (error) {
|
|
236
|
-
if (this.#reconnect.maxAttempts > 0 && attempt >= this.#reconnect.maxAttempts) {
|
|
237
|
-
this.#state = 'disconnected';
|
|
238
|
-
this.#emitter.emit('error', error);
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
await sleep(delay);
|
|
242
|
-
delay = Math.min(delay * 2, this.#reconnect.maxDelayMs);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export function createDbusTransport(options: DbusTransportOptions = {}): DbusTransport {
|
|
249
|
-
return new DbusTransportImpl(options);
|
|
250
|
-
}
|
package/src/transport/types.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// Public value and message types for the D-Bus transport seam.
|
|
2
|
-
//
|
|
3
|
-
// These types are the transport's own vocabulary. None of the underlying
|
|
4
|
-
// `@httptoolkit/dbus-native` types appear here or in `./index.ts`, so the package's
|
|
5
|
-
// public surface never leaks the library — swapping the implementation (see README:
|
|
6
|
-
// documented fallback `@particle/dbus-next`) would not change a single caller type.
|
|
7
|
-
|
|
8
|
-
// A decoded / encodable D-Bus value.
|
|
9
|
-
//
|
|
10
|
-
// 64-bit integers (`x`, `t`) are ALWAYS `bigint`, never `number`. Byte arrays (`ay`)
|
|
11
|
-
// are `Uint8Array`. Arrays, structs, and dict entries are all plain arrays; a dict
|
|
12
|
-
// `a{KV}` decodes to an array of `[key, value]` entry pairs, preserving order and
|
|
13
|
-
// tolerating duplicate/non-string keys losslessly. Variants are wrapped in
|
|
14
|
-
// `DbusVariant` so their inner signature survives a round-trip.
|
|
15
|
-
export type DbusValue = string | number | boolean | bigint | Uint8Array | DbusVariant | DbusValue[];
|
|
16
|
-
|
|
17
|
-
// A D-Bus variant (`v`): a value tagged with the signature of its contained type.
|
|
18
|
-
export interface DbusVariant {
|
|
19
|
-
readonly signature: string;
|
|
20
|
-
readonly value: DbusValue;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Construct a variant for encoding, e.g. `variant('u', 42)` or `variant('t', 5n)`.
|
|
24
|
-
export function variant(signature: string, value: DbusValue): DbusVariant {
|
|
25
|
-
return { signature, value };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Narrowing guard for a decoded variant.
|
|
29
|
-
export function isVariant(value: DbusValue): value is DbusVariant {
|
|
30
|
-
return (
|
|
31
|
-
typeof value === 'object' &&
|
|
32
|
-
value !== null &&
|
|
33
|
-
!Array.isArray(value) &&
|
|
34
|
-
!(value instanceof Uint8Array) &&
|
|
35
|
-
typeof (value as DbusVariant).signature === 'string' &&
|
|
36
|
-
'value' in value
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// An outgoing method call.
|
|
41
|
-
export interface MethodCall {
|
|
42
|
-
readonly destination: string;
|
|
43
|
-
readonly path: string;
|
|
44
|
-
readonly interface: string;
|
|
45
|
-
readonly member: string;
|
|
46
|
-
// D-Bus signature of `args`. Omit (or empty) for a no-argument call.
|
|
47
|
-
readonly signature?: string;
|
|
48
|
-
readonly args?: readonly DbusValue[];
|
|
49
|
-
// Per-call reply timeout in ms. Defaults to the transport's configured timeout.
|
|
50
|
-
readonly timeoutMs?: number;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// A decoded method reply.
|
|
54
|
-
export interface MethodReply {
|
|
55
|
-
readonly signature: string;
|
|
56
|
-
readonly body: DbusValue[];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// A signal subscription filter. `interface` and `member` are required; `path` and
|
|
60
|
-
// `sender` narrow further when supplied (MM emits the same signal from many paths).
|
|
61
|
-
export interface SignalSpec {
|
|
62
|
-
readonly interface: string;
|
|
63
|
-
readonly member: string;
|
|
64
|
-
readonly path?: string;
|
|
65
|
-
readonly sender?: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// A decoded signal delivered to a subscriber.
|
|
69
|
-
export interface SignalEvent {
|
|
70
|
-
readonly path: string;
|
|
71
|
-
readonly interface: string;
|
|
72
|
-
readonly member: string;
|
|
73
|
-
readonly sender: string | undefined;
|
|
74
|
-
readonly signature: string;
|
|
75
|
-
readonly body: DbusValue[];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export type SignalListener = (event: SignalEvent) => void;
|
|
79
|
-
|
|
80
|
-
// Handle returned by `subscribeSignal`; call `unsubscribe` to detach the listener and
|
|
81
|
-
// (when it was the last subscriber for its match rule) drop the bus-side match.
|
|
82
|
-
export interface Subscription {
|
|
83
|
-
unsubscribe(): Promise<void>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export type TransportEvent = 'connected' | 'reconnected' | 'disconnected' | 'error';
|
|
87
|
-
|
|
88
|
-
export interface DbusTransportOptions {
|
|
89
|
-
// Encoded bus address. Defaults to `DBUS_SESSION_BUS_ADDRESS`.
|
|
90
|
-
readonly busAddress?: string;
|
|
91
|
-
// Unix socket path (an alternative to `busAddress` for a private test bus).
|
|
92
|
-
readonly socket?: string;
|
|
93
|
-
// Default per-call reply timeout in ms (default 30000).
|
|
94
|
-
readonly callTimeoutMs?: number;
|
|
95
|
-
// Automatic reconnect after an unexpected bus drop (default enabled).
|
|
96
|
-
readonly reconnect?: ReconnectOptions;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface ReconnectOptions {
|
|
100
|
-
readonly enabled?: boolean;
|
|
101
|
-
readonly initialDelayMs?: number;
|
|
102
|
-
readonly maxDelayMs?: number;
|
|
103
|
-
// 0 = retry forever (default).
|
|
104
|
-
readonly maxAttempts?: number;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// The transport seam. This is the entire surface the A3.x D-Bus backend builds on.
|
|
108
|
-
export interface DbusTransport {
|
|
109
|
-
connect(): Promise<void>;
|
|
110
|
-
disconnect(): Promise<void>;
|
|
111
|
-
isConnected(): boolean;
|
|
112
|
-
callMethod(call: MethodCall): Promise<MethodReply>;
|
|
113
|
-
subscribeSignal(spec: SignalSpec, listener: SignalListener): Promise<Subscription>;
|
|
114
|
-
on(event: TransportEvent, handler: (payload?: unknown) => void): void;
|
|
115
|
-
off(event: TransportEvent, handler: (payload?: unknown) => void): void;
|
|
116
|
-
// Number of live signal subscriptions — exposed for leak assertions in tests.
|
|
117
|
-
subscriptionCount(): number;
|
|
118
|
-
}
|