Repository: LedgerHQ/speculos Branch: master Commit: c8324ac5b952 Files: 426 Total size: 21.0 MB Directory structure: gitextract_zpn2g_yk/ ├── .clang-format ├── .codespell-ignore ├── .dockerignore ├── .github/ │ ├── actionlint.yaml │ └── workflows/ │ ├── continuous-integration-workflow.yml │ ├── documentation.yml │ ├── fast-checks.yml │ ├── force-rebase.yml │ └── reusable_ragger_tests_latest_speculos.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .vscode/ │ └── settings.json ├── CHANGELOG.md ├── CMakeLists.txt ├── COPYING ├── COPYING.LESSER ├── Dockerfiles/ │ ├── Dockerfile │ └── build.Dockerfile ├── MANIFEST.in ├── Pipfile ├── README.md ├── apps/ │ ├── README.md │ └── nanox#boil#25#6e728d99.elf ├── clang-armv7m.cmake ├── docker-compose.yml ├── docs/ │ ├── CNAME │ ├── Makefile │ ├── conf.py │ ├── dev/ │ │ ├── ci.md │ │ ├── getting_started.md │ │ ├── index.rst │ │ ├── internals.md │ │ └── tests.md │ ├── index.rst │ ├── installation/ │ │ ├── build.md │ │ ├── index.rst │ │ └── wsl.md │ ├── requirements.txt │ └── user/ │ ├── api.md │ ├── automation.md │ ├── clients.md │ ├── debug.md │ ├── docker.md │ ├── index.rst │ ├── macm1.md │ ├── semihosting.md │ └── usage.md ├── gcc-arm.cmake ├── lgtm.yml ├── pyproject.toml ├── sdk/ │ └── bolos_syscalls.h ├── setup.py ├── speculos/ │ ├── __init__.py │ ├── __main__.py │ ├── api/ │ │ ├── README.md │ │ ├── __init__.py │ │ ├── apdu.py │ │ ├── api.py │ │ ├── automation.py │ │ ├── button.py │ │ ├── events.py │ │ ├── finger.py │ │ ├── resources/ │ │ │ ├── apdu.schema │ │ │ ├── button.schema │ │ │ ├── finger.schema │ │ │ └── ticker.schema │ │ ├── restful.py │ │ ├── screenshot.py │ │ ├── static/ │ │ │ ├── index.html │ │ │ └── swagger/ │ │ │ ├── README.md │ │ │ ├── index.html │ │ │ ├── swagger-ui-bundle.js │ │ │ ├── swagger-ui-standalone-preset.js │ │ │ ├── swagger-ui.css │ │ │ └── swagger.json │ │ ├── swagger.py │ │ ├── swagger.yaml │ │ ├── ticker.py │ │ └── web_interface.py │ ├── client.py │ ├── cxlib/ │ │ ├── flex-api-level-cx-22.elf │ │ ├── nanosp-api-level-cx-22.elf │ │ ├── nanox-api-level-cx-22.elf │ │ └── stax-api-level-cx-22.elf │ ├── main.py │ ├── mcu/ │ │ ├── __init__.py │ │ ├── apdu.py │ │ ├── automation.py │ │ ├── automation_server.py │ │ ├── bagl.py │ │ ├── bagl_font.py │ │ ├── bagl_glyph.py │ │ ├── button_tcp.py │ │ ├── display.py │ │ ├── finger_tcp.py │ │ ├── headless.py │ │ ├── nbgl.py │ │ ├── nbgl_serialize.py │ │ ├── ocr.py │ │ ├── readerror.py │ │ ├── resources/ │ │ │ └── automation.schema │ │ ├── rle_custom.py │ │ ├── screen.py │ │ ├── screen_text.py │ │ ├── seproxyhal.py │ │ ├── struct.py │ │ ├── transport/ │ │ │ ├── __init__.py │ │ │ ├── interface.py │ │ │ ├── nfc.py │ │ │ └── usb.py │ │ └── vnc.py │ ├── observer.py │ ├── resources_importer.py │ └── sharedlib/ │ ├── apex_p-api-level-shared-25.elf │ ├── apex_p-api-level-shared-26.elf │ ├── flex-api-level-shared-24.elf │ ├── flex-api-level-shared-25.elf │ ├── flex-api-level-shared-26.elf │ ├── nanosp-api-level-shared-24.elf │ ├── nanosp-api-level-shared-25.elf │ ├── nanosp-api-level-shared-26.elf │ ├── nanox-api-level-shared-24.elf │ ├── nanox-api-level-shared-25.elf │ ├── nanox-api-level-shared-26.elf │ ├── stax-api-level-shared-24.elf │ ├── stax-api-level-shared-25.elf │ └── stax-api-level-shared-26.elf ├── speculos.py ├── src/ │ ├── CMakeLists.txt │ ├── bolos/ │ │ ├── bagl.c │ │ ├── bagl.h │ │ ├── cx.c │ │ ├── cx.h │ │ ├── cx_aes.c │ │ ├── cx_aes.h │ │ ├── cx_aes_sdk2.c │ │ ├── cx_blake2.h │ │ ├── cx_blake2b.c │ │ ├── cx_bls.c │ │ ├── cx_bls.h │ │ ├── cx_bls_fp2.c │ │ ├── cx_bls_g2.c │ │ ├── cx_bn.c │ │ ├── cx_common.h │ │ ├── cx_crc.c │ │ ├── cx_crc.h │ │ ├── cx_curve25519.c │ │ ├── cx_curve25519.h │ │ ├── cx_ec.c │ │ ├── cx_ec.h │ │ ├── cx_ec_domain.c │ │ ├── cx_ecpoint.c │ │ ├── cx_ed25519.c │ │ ├── cx_ed25519.h │ │ ├── cx_hash.c │ │ ├── cx_hash.h │ │ ├── cx_hkdf.c │ │ ├── cx_hkdf.h │ │ ├── cx_hmac.c │ │ ├── cx_hmac.h │ │ ├── cx_math.c │ │ ├── cx_math.h │ │ ├── cx_montgomery.c │ │ ├── cx_mpi.c │ │ ├── cx_ripemd160.c │ │ ├── cx_rng_rfc6979.c │ │ ├── cx_rng_rfc6979.h │ │ ├── cx_scc.c │ │ ├── cx_sha256.c │ │ ├── cx_sha3.c │ │ ├── cx_sha512.c │ │ ├── cx_twisted_edwards.c │ │ ├── cx_utils.c │ │ ├── cx_utils.h │ │ ├── cx_weierstrass.c │ │ ├── cxlib.c │ │ ├── cxlib.h │ │ ├── default.c │ │ ├── endorsement.c │ │ ├── endorsement.h │ │ ├── exception.c │ │ ├── exception.h │ │ ├── fonts_info.c │ │ ├── hdkey/ │ │ │ ├── include/ │ │ │ │ ├── hdkey.h │ │ │ │ ├── hdkey_bip32.h │ │ │ │ ├── hdkey_bls12377.h │ │ │ │ ├── hdkey_validate.h │ │ │ │ └── hdkey_zip32.h │ │ │ └── src/ │ │ │ ├── hdkey.c │ │ │ ├── hdkey_bip32.c │ │ │ ├── hdkey_bls12377.c │ │ │ ├── hdkey_validate.c │ │ │ └── hdkey_zip32.c │ │ ├── io/ │ │ │ ├── io.c │ │ │ ├── io.h │ │ │ ├── mock/ │ │ │ │ ├── include/ │ │ │ │ │ ├── checks.h │ │ │ │ │ ├── cx_rng_internal.h │ │ │ │ │ ├── decorators.h │ │ │ │ │ ├── exceptions.h │ │ │ │ │ ├── lcx_hash.h │ │ │ │ │ ├── lcx_sha512.h │ │ │ │ │ ├── os.h │ │ │ │ │ ├── os_debug.h │ │ │ │ │ ├── os_helpers.h │ │ │ │ │ ├── os_id.h │ │ │ │ │ ├── os_math.h │ │ │ │ │ ├── os_pic.h │ │ │ │ │ ├── os_pin.h │ │ │ │ │ ├── os_pki.h │ │ │ │ │ ├── os_registry.h │ │ │ │ │ ├── os_seed.h │ │ │ │ │ ├── os_utils.h │ │ │ │ │ └── ux.h │ │ │ │ └── src/ │ │ │ │ └── mock.c │ │ │ └── sdk/ │ │ │ ├── include/ │ │ │ │ ├── appflags.h │ │ │ │ ├── errors.h │ │ │ │ ├── os_apdu.h │ │ │ │ ├── os_app.h │ │ │ │ ├── os_errors.h │ │ │ │ └── seproxyhal_protocol.h │ │ │ ├── io/ │ │ │ │ ├── include/ │ │ │ │ │ ├── os_io.h │ │ │ │ │ ├── os_io_seph_cmd.h │ │ │ │ │ └── os_io_seph_ux.h │ │ │ │ └── src/ │ │ │ │ ├── os_io.c │ │ │ │ ├── os_io_seph_cmd.c │ │ │ │ └── os_io_seph_ux.c │ │ │ ├── lib_nfc/ │ │ │ │ ├── doc/ │ │ │ │ │ └── mainpage.dox │ │ │ │ ├── include/ │ │ │ │ │ ├── nfc_ledger.h │ │ │ │ │ └── nfc_ndef.h │ │ │ │ └── src/ │ │ │ │ ├── nfc_ledger.c │ │ │ │ └── nfc_ndef.c │ │ │ ├── lib_stusb/ │ │ │ │ ├── include/ │ │ │ │ │ ├── usbd_conf.h │ │ │ │ │ ├── usbd_core.h │ │ │ │ │ ├── usbd_ctlreq.h │ │ │ │ │ ├── usbd_def.h │ │ │ │ │ ├── usbd_desc.h │ │ │ │ │ ├── usbd_ioreq.h │ │ │ │ │ ├── usbd_ledger.h │ │ │ │ │ ├── usbd_ledger_ccid.h │ │ │ │ │ ├── usbd_ledger_cdc.h │ │ │ │ │ ├── usbd_ledger_hid.h │ │ │ │ │ ├── usbd_ledger_hid_kbd.h │ │ │ │ │ ├── usbd_ledger_hid_u2f.h │ │ │ │ │ ├── usbd_ledger_types.h │ │ │ │ │ └── usbd_ledger_webusb.h │ │ │ │ └── src/ │ │ │ │ ├── usbd_conf.c │ │ │ │ ├── usbd_core.c │ │ │ │ ├── usbd_ctlreq.c │ │ │ │ ├── usbd_desc.c │ │ │ │ ├── usbd_ioreq.c │ │ │ │ ├── usbd_ledger.c │ │ │ │ ├── usbd_ledger_hid.c │ │ │ │ ├── usbd_ledger_hid_u2f.c │ │ │ │ └── usbd_ledger_webusb.c │ │ │ └── protocol/ │ │ │ ├── include/ │ │ │ │ └── ledger_protocol.h │ │ │ └── src/ │ │ │ └── ledger_protocol.c │ │ ├── nbgl.c │ │ ├── nbgl.h │ │ ├── nbgl_rle.c │ │ ├── nbgl_rle.h │ │ ├── os.c │ │ ├── os_bip32.c │ │ ├── os_bip32.h │ │ ├── os_eip2333.c │ │ ├── os_hdkey.c │ │ ├── os_hdkey.h │ │ ├── os_pki.c │ │ ├── os_pki.h │ │ ├── os_result.h │ │ ├── os_signature.c │ │ ├── os_signature.h │ │ ├── os_types.h │ │ ├── seproxyhal.c │ │ ├── touch.c │ │ └── touch.h │ ├── emulate.c │ ├── emulate.h │ ├── environment.c │ ├── environment.h │ ├── fonts.h │ ├── launcher.c │ ├── launcher.h │ ├── output/ │ │ └── parse_elf │ ├── parse_elf │ ├── sdk.h │ ├── svc.c │ ├── svc.h │ └── vnc/ │ ├── CMakeLists.txt │ ├── cursor.c │ ├── cursor.h │ ├── cursors/ │ │ ├── approved.h │ │ ├── bitcoin.h │ │ ├── blue.h │ │ ├── fabrice.h │ │ ├── frame_00.h │ │ ├── frame_01.h │ │ ├── frame_02.h │ │ ├── frame_03.h │ │ ├── frame_04.h │ │ ├── frame_05.h │ │ ├── frame_06.h │ │ ├── frame_07.h │ │ ├── frame_08.h │ │ ├── frame_09.h │ │ ├── frame_10.h │ │ ├── frame_11.h │ │ ├── frame_12.h │ │ ├── frame_13.h │ │ ├── frame_14.h │ │ ├── frame_15.h │ │ ├── frame_16.h │ │ ├── frame_17.h │ │ ├── frame_18.h │ │ ├── frame_19.h │ │ ├── frame_20.h │ │ ├── frame_21.h │ │ ├── pizza.h │ │ ├── star.h │ │ ├── sword.h │ │ └── verynice.h │ ├── seccomp-bpf.h │ └── vnc_server.c ├── tests/ │ ├── c/ │ │ ├── CMakeLists.txt │ │ ├── mocks.c │ │ ├── syscalls/ │ │ │ ├── CMakeLists.txt │ │ │ ├── cavp/ │ │ │ │ ├── blake2b_kat.data │ │ │ │ ├── groestl_224_long_msg.data │ │ │ │ ├── groestl_224_short_msg.data │ │ │ │ ├── groestl_256_long_msg.data │ │ │ │ ├── groestl_256_short_msg.data │ │ │ │ ├── groestl_384_long_msg.data │ │ │ │ ├── groestl_384_short_msg.data │ │ │ │ ├── groestl_512_long_msg.data │ │ │ │ ├── groestl_512_short_msg.data │ │ │ │ ├── hmac.data │ │ │ │ ├── keccak_224_long_msg.data │ │ │ │ ├── keccak_224_short_msg.data │ │ │ │ ├── keccak_256_long_msg.data │ │ │ │ ├── keccak_256_short_msg.data │ │ │ │ ├── keccak_384_long_msg.data │ │ │ │ ├── keccak_384_short_msg.data │ │ │ │ ├── keccak_512_long_msg.data │ │ │ │ ├── keccak_512_short_msg.data │ │ │ │ ├── sha224_long_msg.data │ │ │ │ ├── sha224_short_msg.data │ │ │ │ ├── sha256_long_msg.data │ │ │ │ ├── sha256_short_msg.data │ │ │ │ ├── sha384_long_msg.data │ │ │ │ ├── sha384_short_msg.data │ │ │ │ ├── sha3_224_long_msg.data │ │ │ │ ├── sha3_224_short_msg.data │ │ │ │ ├── sha3_256_long_msg.data │ │ │ │ ├── sha3_256_short_msg.data │ │ │ │ ├── sha3_384_long_msg.data │ │ │ │ ├── sha3_384_short_msg.data │ │ │ │ ├── sha3_512_long_msg.data │ │ │ │ ├── sha3_512_short_msg.data │ │ │ │ ├── sha512_long_msg.data │ │ │ │ ├── sha512_short_msg.data │ │ │ │ ├── shake128_long_msg.data │ │ │ │ ├── shake128_short_msg.data │ │ │ │ ├── shake128_variable_output.data │ │ │ │ ├── shake256_long_msg.data │ │ │ │ ├── shake256_short_msg.data │ │ │ │ └── shake256_variable_output.data │ │ │ ├── hello.c │ │ │ ├── nist_cavp.c │ │ │ ├── nist_cavp.h │ │ │ ├── test_aes.c │ │ │ ├── test_bip32.c │ │ │ ├── test_blake2.c │ │ │ ├── test_bls.c │ │ │ ├── test_bn.c │ │ │ ├── test_crc16.c │ │ │ ├── test_ec.c │ │ │ ├── test_ecdh.c │ │ │ ├── test_ecdsa.c │ │ │ ├── test_ecpoint.c │ │ │ ├── test_eddsa.c │ │ │ ├── test_eip2333.c │ │ │ ├── test_endorsement.c │ │ │ ├── test_hdkey.c │ │ │ ├── test_hmac.c │ │ │ ├── test_math.c │ │ │ ├── test_mpi_rng.c │ │ │ ├── test_os_global_pin_is_validated.c │ │ │ ├── test_rfc6979.c │ │ │ ├── test_ripemd.c │ │ │ ├── test_sha2.c │ │ │ ├── test_sha3.c │ │ │ ├── test_slip21.c │ │ │ └── wycheproof/ │ │ │ ├── X25519.data │ │ │ ├── X448.data │ │ │ ├── ecdh_secp256k1.data │ │ │ └── eddsa.data │ │ ├── test_environment.c │ │ ├── utils.c │ │ └── utils.h │ └── python/ │ ├── __init__.py │ ├── api/ │ │ ├── __init__.py │ │ ├── resources/ │ │ │ └── automation.json │ │ └── test_api.py │ ├── apps/ │ │ ├── __init__.py │ │ ├── resources/ │ │ │ ├── __init__.py │ │ │ └── boil_getpubkey_nanox.json │ │ ├── test_boil.py │ │ └── test_vnc.py │ ├── conftest.py │ ├── mcu/ │ │ ├── __init__.py │ │ ├── resources/ │ │ │ ├── automation_invalid_action_args.json │ │ │ ├── automation_invalid_action_name.json │ │ │ ├── automation_invalid_rule_key.json │ │ │ └── automation_valid.json │ │ └── test_automation.py │ ├── pytest.ini │ ├── test_resources_importer.py │ └── unit/ │ ├── __init__.py │ ├── test_client_Api.py │ └── test_client_SpeculosClient.py └── tools/ ├── clang-format.sh ├── cursor.py ├── debug.sh ├── gdbinit ├── gif-recorder.py ├── ledger-live-http-proxy.py └── winamp.py ================================================ FILE CONTENTS ================================================ ================================================ FILE: .clang-format ================================================ # https://stackoverflow.com/questions/29477654/how-to-make-clang-format-add-new-line-before-opening-brace-of-a-function --- Language: Cpp # BasedOnStyle: LLVM AccessModifierOffset: -2 AlignAfterOpenBracket: Align AlignConsecutiveMacros: true AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Right AlignOperands: true AlignTrailingComments: true AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: false AllowShortLambdasOnASingleLine: All AllowShortIfStatementsOnASingleLine: Never AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: MultiLine BinPackArguments: true BinPackParameters: true BraceWrapping: AfterCaseLabel: false AfterClass: false AfterControlStatement: false AfterEnum: false AfterFunction: true AfterNamespace: false AfterObjCDeclaration: false AfterStruct: false AfterUnion: false AfterExternBlock: false BeforeCatch: false BeforeElse: false IndentBraces: false SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true BreakBeforeBinaryOperators: None BreakBeforeBraces: Custom BreakBeforeInheritanceComma: false BreakInheritanceList: BeforeColon BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeColon BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true ColumnLimit: 80 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: false DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH IncludeBlocks: Preserve IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 - Regex: '^(<|"(gtest|gmock|isl|json)/)' Priority: 3 - Regex: '.*' Priority: 1 IncludeIsMainRegex: '(Test)?$' IndentCaseLabels: false IndentPPDirectives: None IndentWidth: 2 IndentWrappedFunctionNames: false JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: true MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: None ObjCBinPackProtocolList: Auto ObjCBlockIndentWidth: 2 ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Right ReflowComments: true SortIncludes: true SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true SpaceBeforeCpp11BracedList: false SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true SpaceBeforeParens: ControlStatements SpaceBeforeRangeBasedForLoopColon: true SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Cpp11 StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION TabWidth: 8 UseTab: Never ... ================================================ FILE: .codespell-ignore ================================================ globaly keypair ontop tolen unstall TE ================================================ FILE: .dockerignore ================================================ apps node_server Dockerfile docker-compose.yml .dockerignore .git* doc README.md ================================================ FILE: .github/actionlint.yaml ================================================ version: 1 self-hosted-runner: labels: - public-ledgerhq-shared-small - speculos-builder-2c-arm64-ubuntu_2404 ================================================ FILE: .github/workflows/continuous-integration-workflow.yml ================================================ name: Continuous Integration & Deployment on: workflow_dispatch: push: tags: - '*' branches: - master pull_request: branches: - master # Cancel previous runs on this reference concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: PYGAME_HIDE_SUPPORT_PROMPT: 1 jobs: build_builder_image: name: Build speculos-builder image runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build speculos-builder locally uses: docker/build-push-action@v6 with: context: . file: Dockerfiles/build.Dockerfile push: false load: true tags: speculos-builder:local cache-from: type=gha cache-to: type=gha,mode=max - name: Export image as artifact run: docker save speculos-builder:local > /tmp/speculos-builder-image.tar - name: Upload image artifact uses: actions/upload-artifact@v4 with: name: speculos-builder-image path: /tmp/speculos-builder-image.tar retention-days: 1 build_speculos_image: name: Build speculos image needs: build_builder_image runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v4 - name: Download builder image artifact uses: actions/download-artifact@v4 with: name: speculos-builder-image path: /tmp - name: Load builder image run: docker load -i /tmp/speculos-builder-image.tar - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver: docker - name: Build speculos image uses: docker/build-push-action@v6 with: context: . file: Dockerfiles/Dockerfile push: false build-args: BUILDER_IMAGE=speculos-builder:local coverage: name: Code coverage needs: build_builder_image runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v4 with: fetch-depth: 0 - name: Download builder image artifact uses: actions/download-artifact@v4 with: name: speculos-builder-image path: /tmp - name: Load builder image run: docker load -i /tmp/speculos-builder-image.tar - name: Build with code coverage instrumentation env: CTEST_OUTPUT_ON_FAILURE: 1 RNG_SEED: 0 run: | docker run --rm \ -v "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" \ -w "$GITHUB_WORKSPACE" \ -e CTEST_OUTPUT_ON_FAILURE \ -e RNG_SEED=0 \ speculos-builder:local \ sh -c " git config --global --add safe.directory $GITHUB_WORKSPACE && cmake -Bbuild -H. -DPRECOMPILED_DEPENDENCIES_DIR=/install -DWITH_VNC=1 -DCODE_COVERAGE=ON && make -C build clean && make -C build && make -C build test && pip install pytest-cov && pip install . && PYTHONPATH=. pytest --cov=speculos --cov-report=xml " - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: name: codecov-speculos build: name: Clone, build, test needs: build_builder_image runs-on: ubuntu-latest strategy: fail-fast: false matrix: python_version: ['3.10', '3.11', '3.12', '3.13'] steps: - name: Clone uses: actions/checkout@v4 with: fetch-depth: 0 - name: Download builder image artifact uses: actions/download-artifact@v4 with: name: speculos-builder-image path: /tmp - name: Load builder image run: docker load -i /tmp/speculos-builder-image.tar - name: Setup Python version uses: actions/setup-python@v5 with: python-version: ${{ matrix.python_version }} - name: Build and test run: | PYTHON_PATH=$(which python) PYTHON_DIR=$(dirname $(dirname $PYTHON_PATH)) docker run --rm \ -v "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" \ -v "$PYTHON_DIR:$PYTHON_DIR" \ -w "$GITHUB_WORKSPACE" \ -e CTEST_OUTPUT_ON_FAILURE=1 \ speculos-builder:local \ sh -c " git config --global --add safe.directory $GITHUB_WORKSPACE && cmake -Bbuild -H. -DPRECOMPILED_DEPENDENCIES_DIR=/install -DWITH_VNC=1 && make -C build && $PYTHON_PATH -m pip install pytest && $PYTHON_PATH -m pip install . && make -C build/ test && $PYTHON_PATH -m pytest " deploy: name: Build and deploy speculos package needs: build uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_pypi_deployment.yml@v1 with: package_name: speculos jfrog_deployment: true release: ${{ startsWith(github.ref, 'refs/tags/') }} publish: ${{ startsWith(github.ref, 'refs/tags/') }} docker_image_artifact: speculos-builder-image workspace_mark_safe: true secrets: pypi_token: ${{ secrets.PYPI_PUBLIC_API_TOKEN }} package_and_test_docker: name: Build and test the Speculos docker uses: ./.github/workflows/reusable_ragger_tests_latest_speculos.yml with: app_repository: LedgerHQ/app-boilerplate app_branch_name: master package_and_test_docker_rust: name: Build and test the Speculos docker with a Rust app uses: ./.github/workflows/reusable_ragger_tests_latest_speculos.yml with: app_repository: LedgerHQ/app-boilerplate-rust app_branch_name: main ================================================ FILE: .github/workflows/documentation.yml ================================================ name: Documentation generation & update on: push: tags: - '*' branches: - develop - master pull_request: branches: - develop - master # Cancel previous runs on this reference concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: generate: name: Generate the documentation runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install Python dependencies run: | pip install -r docs/requirements.txt - name: Generate the documentation run: (cd docs && make html) - name: Upload documentation bundle uses: actions/upload-artifact@v4 with: name: documentation path: docs/build/html/ deploy: name: Deploy the documentation on Github pages runs-on: ubuntu-latest needs: generate if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) steps: - name: Download documentation bundle uses: actions/download-artifact@v4 - name: Deploy documentation on pages uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: documentation/ ================================================ FILE: .github/workflows/fast-checks.yml ================================================ name: Fast checks on: workflow_dispatch: push: branches: - master - develop pull_request: # Cancel previous runs on this reference concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: linter-python: name: Linter on Python code runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v4 with: fetch-depth: 0 - name: Python dependency run: pip install flake8 flake8-pyproject - name: Lint Python code run: flake8 speculos* setup.py linter-c: name: Linter on C code runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v4 with: fetch-depth: 0 - name: Lint C code uses: DoozyX/clang-format-lint-action@v0.16.1 with: source: 'src tests' extensions: 'c,h' clangFormatVersion: 11 mypy: name: Type checking runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v4 - run: pip install mypy types-requests types-setuptools PyQt5-stubs - name: Mypy type checking run: mypy speculos bandit: name: Security checking runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v4 - run: pip install bandit - name: Bandit security checking run: bandit -r speculos -ll || echo 0 misspell: name: Check misspellings runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v4 with: fetch-depth: 0 - name: Check misspellings uses: codespell-project/actions-codespell@v1 with: builtin: clear,rare check_filenames: true ignore_words_file: .codespell-ignore skip: ./speculos/api/static/swagger/swagger-ui.css,./speculos/api/static/swagger/swagger-ui-bundle.js,./speculos/api/static/swagger/swagger-ui-standalone-preset.js,./speculos/fonts ================================================ FILE: .github/workflows/force-rebase.yml ================================================ name: Force rebased on: [pull_request] jobs: force-rebase: runs-on: ubuntu-latest steps: - name: 'PR commits + 1' id: pr_commits run: echo "pr_fetch_depth=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_OUTPUT}" - name: 'Checkout PR branch and all PR commits' uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: ${{ steps.pr_commits.outputs.pr_fetch_depth }} - name: Check if PR branch is rebased on target branch shell: bash run: | git merge-base --is-ancestor ${{ github.event.pull_request.base.sha }} HEAD - name: Check if PR branch contains merge commits shell: bash run: | merges=$(git log --oneline HEAD~${{ github.event.pull_request.commits }}...HEAD --merges ); \ echo "--- Merges ---"; \ echo ${merges}; \ [[ -z "${merges}" ]] ================================================ FILE: .github/workflows/reusable_ragger_tests_latest_speculos.yml ================================================ name: Functional tests using Ragger and latest speculos on: workflow_call: inputs: app_repository: required: false default: ${{ github.repository }} type: string app_branch_name: required: false default: ${{ github.ref }} type: string jobs: build_application: name: Build application using the reusable workflow uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1 with: app_repository: ${{ inputs.app_repository }} app_branch_name: ${{ inputs.app_branch_name }} upload_app_binaries_artifact: compiled_app_binaries-${{ inputs.app_branch_name }} builder: ledger-app-builder build_docker_image: name: Build Speculos Docker image runs-on: ubuntu-latest steps: - name: Clone uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build the Speculos docker uses: docker/build-push-action@v6 with: push: false tags: ledgerhq/speculos:test context: . file: ./Dockerfiles/Dockerfile outputs: type=docker,dest=/tmp/speculos_image.tar - name: Upload artifact uses: actions/upload-artifact@v4 with: name: speculos_image-${{ inputs.app_branch_name }} path: /tmp/speculos_image.tar call_get_app_metadata: name: Retrieve application metadata uses: LedgerHQ/ledger-app-workflows/.github/workflows/_get_app_metadata.yml@v1 with: app_repository: ${{ inputs.app_repository }} app_branch_name: ${{ inputs.app_branch_name }} ragger_tests: name: Functional tests with Ragger runs-on: ubuntu-latest needs: [build_docker_image, build_application, call_get_app_metadata] strategy: fail-fast: false matrix: device: ${{ fromJSON(needs.call_get_app_metadata.outputs.compatible_devices) }} steps: - name: Clone uses: actions/checkout@v4 with: repository: ${{ inputs.app_repository }} ref: ${{ inputs.app_branch_name }} path: app submodules: recursive fetch-depth: 0 - name: Prepare test conditions shell: bash run: | pip install ledgered # Get Test directory from manifest TEST_DIR=$(ledger-manifest -otp "./app/ledger_app.toml") if [ -z "${TEST_DIR}" ]; then echo "No test directory found" && exit 1 fi echo "TEST_DIR=${TEST_DIR}" >> $GITHUB_ENV # Get SDK from manifest SDK=$(ledger-manifest -os "./app/ledger_app.toml") if [ -z "${SDK}" ]; then echo "No sdk defined" && exit 1 fi echo "SDK=${SDK,,}" >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Download artifact uses: actions/download-artifact@v4 with: name: speculos_image-${{ inputs.app_branch_name }} path: /tmp - name: Load image run: | docker load --input /tmp/speculos_image.tar docker image ls -a - name: Download app binaries uses: actions/download-artifact@v4 with: name: compiled_app_binaries-${{ inputs.app_branch_name }} path: ${{ github.workspace }}/app/${{ env.SDK == 'c' && 'build' || 'target' }} - name: Run and test Speculos docker for C apps if: ${{ env.SDK == 'c' }} run: | docker run --rm \ --entrypoint /bin/bash \ -v "${{ github.workspace }}/app:/app" \ ledgerhq/speculos:test \ -c "apt-get update && apt-get install -y gcc && \ pip install -r /app/${{ env.TEST_DIR }}/requirements.txt && \ pytest /app/${{ env.TEST_DIR }}/ --tb=short -v --device ${{ matrix.device }}" - name: Run and test Speculos docker for Rust apps if: ${{ env.SDK == 'rust' }} run: | docker run --rm \ --entrypoint /bin/bash \ -v "${{ github.workspace }}/app:/app" \ ledgerhq/speculos:test \ -c " apt-get update && \ apt-get install -y gcc cargo && \ pip install -r /app/${{ env.TEST_DIR }}/requirements.txt && \ pytest /app/${{ env.TEST_DIR }}/ --tb=short -v --device ${{ matrix.device }} -k 'not test_version' " ================================================ FILE: .gitignore ================================================ *.a *.o .cache/ .idea/ .eggs/ __pycache__/ apps/*vault* build/ core TAGS /speculos/resources/launcher /speculos/resources/vnc_server __version__.py # python *.pyc dist/ *egg-info .coverage ================================================ FILE: .pre-commit-config.yaml ================================================ # To install hooks, run: # pre-commit install --hook-type pre-commit # pre-commit install --hook-type commit-msg --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - repo: https://github.com/psf/black rev: 22.10.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 rev: 5.0.4 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.13.0 hooks: - id: mypy additional_dependencies: - types-protobuf>=5.28,<6 - types-requests - types-tabulate - types-toml - repo: https://github.com/PyCQA/bandit rev: 1.8.6 hooks: - id: bandit args: - -c - pyproject.toml additional_dependencies: - bandit[toml] - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: - id: isort - repo: https://github.com/rhysd/actionlint rev: v1.6.27 hooks: - id: actionlint types_or: [yaml] args: ["-config-file", ".github/actionlint.yaml", "-shellcheck","''", "-pyflakes", "''"] ================================================ FILE: .vscode/settings.json ================================================ { "files.associations": { "bolos_syscalls_blue_2.2.5.h": "c", "verynice.h": "c", "utils.h": "c", "bolos_syscalls.h": "c", "exception.h": "c", "numbers": "c", "sdk.h": "c", "stdbool.h": "c", "emulate.h": "c", "os.h": "c", "os_types.h": "c", "errors.h": "c", "launcher.h": "c" } } ================================================ FILE: CHANGELOG.md ================================================ # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.26.8] 2026-05-11 ### Changed - Include coordinates when reporting a TextEvent ## [0.26.7] 2026-05-06 ### Changed - Introduce NBGL text line SEPH messages, to fix OCR issues with API_LEVEL_26 ## [0.26.6] 2026-04-23 ### Changed - Add Montgomery curves support to sys_cx_ecpoint_is_on_curve ## [0.26.5] 2026-04-22 ### Changed - Introduce NBGL serialized events, to fix OCR issues with API_LEVEL_26 ## [0.26.4] 2026-04-16 ### Changed - Restore `os_registry_get_current_app_tag` syscall ## [0.26.3] 2026-04-09 ### Added - Add the support of ZIP32 Sapling, Orchard and Register derivations - Add the support of BIP32-like derivation with BLS12-377 curve ## [0.26.2] 2026-03-26 ### Changed - Rework and fix CI ## [0.26.1] 2026-03-25 ### Fix - Fix packaging issue: remove usage of distutils ## [0.26.0] 2026-03-25 ### Added - Add the support of the curves `Pallas`, `Vesta` and `Jubjub` - Support API_LEVEL_26 - Support new ENDORSEMENT syscalls - Support `os_stack_operations` syscall, to be able to get Syscall Stack usage - Log finger touch events to file for external consumers (when `SPECULOS_FINGER_LOG` is set) ### Changed - Remove support of python 3.9 ## [0.25.13] 2025-12-09 ### Fix - Fix not working '-p' option (Use production public key for PKI) ## [0.25.12] 2025-12-08 ### Fix - Fix VNC issue ## [0.25.11] 2025-12-05 ### Fix - Fix wrong derivation path when using libs (only use main app one) ## [0.25.10] 2025-12-04 ### Added - Support throwing exceptions from OS (mainly Cx syscalls) like on real devices - Support retrieving appflags from elf and use it for derivation - Support retrieving derivation_path from elf and use it for derivation ## [0.25.9] 2025-11-19 ### Added - support for os_perso_get_master_key_identifier syscall - support for BLS12-377 and Edwards BLS12-377 curves ## [0.25.8] 2025-10-13 ### Changed - Updated shared libraries for API level 25 ## [0.25.7] 2025-10-01 ### Changed - Remove support of old devices: Nano S & Blue - Remove support of old SDK versions (lower than API Level 22) - Last tag supporting Nano S & Blue is `NanoS_Blue_baseline` ## [0.25.6] 2025-09-25 ### Added - Add support of API level 25 on all products ### Fix - Fix crash in Apps on API levels 24 & 25 on Nano X & S+ when using \b in strings ## [0.25.5] 2025-09-12 ### Fix - Limit useless logs - Remove timestamp from debug logs - Missing Apex_p keyboard navigation coordinates ## [0.25.4] 2025-09-04 ### Fix - Update shared.elf library for Apex to fix issue with "More" button in long tag/value case - Force full screen refresh on Nano - "Fix" a race condition between ragger and speculos ## [0.25.3] 2025-08-11 ### Fix - Add missing definitions for LedgerPKI (including Apex devices) ## [0.25.2] 2025-07-28 ### Changed - Update of fonts for Apex API_LEVEL_25 ### Fix - Avoid defining strlcpy starting from glibc 2.38 ## [0.25.1] 2025-07-21 ### Fix - Fix missing check of API level 25 when loading fonts ## [0.25.0] 2025-07-16 ### Added - Add support of API level 25 (Apex) ## [0.24.0] 2025-07-10 ### Added - Automatically try to find an available apdu port - Stax/Flex navigation with keyboard: - Arrow Left / Right keys: Previous / Next actions in bottom right corner - Return: Approve button in center - Escape: Cancel button (review) in bottom left corner - Backspace: Back button in top left corner - M: Menu (Setting/Info) in top right corner ### Fix - Deploy workflow: regex to correctly set the `PUSH_FLAG` ## [0.23.0] 2025-07-02 ### Added - Add support of API level 24 (IO Revamp) - Add Curve `cv25519` support ### Fix - Support Rust apps on Nano devices with BAGL ### Changed - Update Shared lib ELF files for API_LEVEL 23 ## [0.22.0] 2025-06-02 ### Fix - Fix nb_fonts check and make OCR working again - Fix issue with LNX/LNSP Apps using BAGL with API_LEVEL 23 - Fix crash in nano shared lib files ### Changed - Modular exponentiation with exponent 0 is allowed in BOLOS - Only load pygame with --sound & suppress pygame message ## [0.21.2] 2025-04-28 ### Fix - Incorrect syscall address for API level < 23 ## [0.21.1] 2025-04-25 ### Fix - Incorrect font size/address computed when starting Speculos with libraries ## [0.21.0] 2025-04-23 ### Added - Add `key1_sign_without_code_hash` endorsement syscall. ## [0.20.0] 2025-04-23 ### Added - Add support of API level 23 (Cx -> Shared) - Implement new endorsement syscalls" - Implement NBGL adaptations to avoid drawing outside of area/screen - Add option `-S/--sound` allowing to play the Tunes (including the wav files) ## [0.19.0] 2025-03-31 ### Changed - Ported the code to PyQt6 ## [0.18.0] 2025-03-14 ### Added - Do not rely on C_bagl_fonts to check whether an app is BAGL or NBGL ## [0.17.0] 2025-03-14 ### Added - `--save-nvram` and `--load-nvram` parameters that allow NVRAM testing - destination boundaries verification for `nvm_write()` - Make BAGL-based applications able to call NBGL-based libraries, or NBGL-based applications able to call BAGL-based libraries ## [0.16.0] 2025-03-05 ### Changed - Allow CORS in order to be used directly from external website (ie: [DMK Playground](https://app.devicesdk.ledger.com/)) ### Fixed - Fixed `prod-pki` option in helper usage in the good group - Fixed `logger.warn` deprecated API ### Added - Add `-v/--verbose` to increase verbosity. Default behavior now is to limit _werkzeug_ logs and remove timestamp from logs ## [0.15.0] 2025-02-24 ### Added - Added support for Python versions 3.12 and 3.13 ### Fixed - Fixed prod-pki option ## [0.14.0] 2025-02-06 ### Changed - Increase number of sideloaded applications to 64 ## [0.13.1] 2025-01-28 ### Fixed - Re-enable the support for Python 3.9 ## [0.13.0] 2025-01-27 ### Added - Add arm64 host builder - Enable the use of test key or prod key for PKI ### Changed - Remove support for Python versions 3.8 and 3.9 - LedgerPKI: Allow any `key ID` and `key usage` values ## [0.12.0] 2024-11-25 ### Added - NFC communication available - Starting Speculos with the `--transport` argument allows to choose U2F, HID or NFC transport - Flex and Stax OSes emulation always consider NFC to be up (it can't be deactivated for now) ### Changed - Update Python dependencies (certifi, urllib3, werkzeug, zipp, requests) ## [0.11.0] 2024-11-12 ### Added - Ledger PKI support (S+/X+Stax/Flex) - API_LEVEL_22 support (S+/X+Stax/Flex) ## [0.10.0] 2024-10-03 ### Added - Enable support for secp521r1 ## [0.9.7] 2024-07-31 ### Fixed - CRC computation for API levels >= 18 ## [0.9.6] 2024-07-12 ### Fixed - Fix wrong display of some image files when BPP is not properly set in area ## [0.9.5] 2024-07-03 ### Added - cxlib and fonts for Flex on API_LEVEL_21 ## [0.9.4] 2024-06-27 ### Added - Add support of API_LEVEL_21 for Stax and Flex ### Fixed - Fix size of allocated buffer when redrawing VNC framebuffer ## [0.9.3] 2024-06-20 ### Fixed - Remove the vertical alignment assertion on multiples of 4 on Stax - Fixed the actions versions for `upload-artifact` and `download-artifact` in v4 ## [0.9.2] 2024-06-19 ### Added - Add support of API_LEVEL_20 for Stax and Flex ## [0.9.1] 2024-05-14 ### Fixed - `importlib.resources` does not exists on Python 3.8 ## [0.9.0] - 2024-05-06 ### Added - Finger swipe capabilities (this feature is currently only available on Flex, using the capability will have no effect on other devices) - Add support of API_LEVEL_19 for Flex ### Fixed - Replacing deprecated `pkg_resources` usages with `importlib.resources` equivalents ## [0.8.6] - 2024-04-11 ### Fixed - Fix race condition on screenshot generation - Fix ticker pause not waiting for end of tick processing ## [0.8.5] - 2024-04-11 ### Fixed - Fix race condition on screenshot generation ## [0.8.4] - 2024-04-10 ### Fixed - Removing PyQt5 from Speculos Docker images as it is unused and triggers error on MAC. - Fix OCR screen content reset mechanism. - Fix library mode fonts not unloaded at os_lib_end. ## [0.8.3] - 2024-04-08 ### Fixed - Fix library mode fonts not loaded. ## [0.8.2] - 2024-04-05 ### Fixed - Fix NanoX and NanoSP handling when BAGL is used but fonts are not found in the elf. ## [0.8.1] - 2024-04-04 ### Fixed - Fixed logger initialization that lead to root log handler not being propagated to children ## [0.8.0] - 2024-04-03 ### Added - NBGL support for non-Stax devices - Add Flex support - Add support of API_LEVEL_18 for NanoX, NanoS+ and Flex ## [0.7.1] - 2024-02-26 ### Fixed - Specific `cache` mechanism for Python3.8 (`functools.cache` does not exists yet) ## [0.7.0] - 2024-02-26 ### Changed - Significative performance improvement on display/snapshot management - Simplified HTTP API thread management ## [0.6.0] - 2024-02-21 ### Added - Add support for API_LEVEL_15 for Stax ## [0.5.1] - 2024-02-15 ### Added - Add possibility to set up a timeout for APDU exchange with default value to 5min ## [0.5.0] - 2024-01-11 ### Added - Attestation key or user private keys can now be configured with the new `--attestation-key` and `--user-private-key` arguments (or `ATTESTATION_PRIVATE_KEY` and `USER_PRIVATE_KEY` through environment variables). User certificates are correctly calculated, signed from the user private keys and the attestation key. ### Changed - Seed, RNG, application name and version are now fetched from the environment when Speculos starts then stored internally for further use, rather than fetched when needed during runtime. This avoids several Speculos instances from messing up with each other's environment variables. ## [0.4.1] - 2023-12-19 ### Fixed - CX: Fix AES implementation on NanoS ## [0.4.0] - 2023-12-04 ### Fixed - bolos/os_bip32.c: Improve syscall emulation ### Added - API_LEVEL: Add support for API_LEVEL_14 for Ledger Stax ## [0.3.5] - 2023-11-10 ### Fixed - CX: Update AES implementation to be compatible with API levels >= 12 ## [0.3.4] - 2023-11-07 ### Features - Implement cx_bn_gf2_n_mul() ### Miscellaneous Tasks - Add missing `binutils-arm-none-eabi` package ### README - Update Limitations section ## [0.3.3] - 2023-10-26 ### Fixed - Launcher: Fix missing RAM relocation emulation on NanoX, NanoSP and Stax ## [0.3.2] - 2023-09-28 ### Fixed - API: the API thread is asked to stop when Speculos exits ## [0.3.1] - 2023-09-28 ### Fixed - OCR: Prevent null dereference when expected font is not in ELF file ## [0.3.0] - 2023-09-11 ### Added - API_LEVEL: Add support for API_LEVEL_13 for corresponding device ## [0.2.10] - 2023-09-01 ### Changed - OCR: Apps using unified SDK don't use OCR anymore. Font info is parsed from .elf file. ## [0.2.9] - 2023-08-31 ### Fixed - Seproxyhal: default status_sent value upon app launch is unset. ## [0.2.8] - 2023-07-31 ### Changed - OCR: Change Stax OCR method. Don't use Tesseract anymore. - CI: Remove CI job dependency to allow deployment if wanted ### Added - API_LEVEL: Add support for API_LEVEL_12 for corresponding device ## [0.2.7] - 2023-06-30 ### Fixed - Seproxyhal: Fix SeProxyHal emulation ## [0.2.6] - 2023-06-26 ### Fixed - Seproxyhal: Fix SeProxyHal issue when on LNSP / LNX and HAVE_PRINTF is enabled ## [0.2.5] - 2023-06-21 ### Added - API: Add a ticker/ endpoint to allow control of the ticks sent to the app ### Fixed - OCR: Fix OCR on NanoX and NanoSP based on API_LEVEL_5 and upper - Seproxyhal: Fix SeProxyHal emulation to match real devices behavior ## [0.2.4] - 2023-06-13 ### Changed - OCR: Lazy evaluation of screenshot content, performance improvement on Stax ### Fixed - OCR: screenshot publish is no longer desynchronized with event publish ## [0.2.3] - 2023-06-05 ### Fixed - svc: Fixed emulation of os_lib_call for latest SDK API levels ## [0.2.2] - 2023-06-01 ### Changed - docker: Add blst library to the docker image - launcher: If Speculos is able to determine the location of the SVC_Call and SVC_cx_call symbols in the application elf, it will only try to patch `svc 1` inside the functions. ## [0.2.1] - 2023-05-30 ### Fixed - deployment: re-ordering pypi.org package automatic push in order to avoid incomplete deployments ## [0.2.0] - 2023-05-30 ### Changed - package: Version is not longer customly incremented, but inferred from tag then bundled into the package thanks to `setuptools_scm` ## [0.1.265] - 2023-05-12 ## [0.1.0] - 2021-07-21 - First release of Speculos on PyPi ================================================ FILE: CMakeLists.txt ================================================ cmake_minimum_required(VERSION 3.10) project(Speculos C) include(CTest) include(ExternalProject) if (CMAKE_TOOLCHAIN_FILE) message(STATUS "Using toolchain ${CMAKE_TOOLCHAIN_FILE}") else () # By default, use gcc cross-compiler for ARM-Thumb set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) add_compile_options(-mthumb) message(STATUS "Using default compiler ${CMAKE_C_COMPILER}") endif () # add_link_options(-static) should be used but was introduced into CMake version 3.13 set(CMAKE_EXE_LINKER_FLAGS -static) enable_testing() option(WITH_VNC "Support for VNC" OFF) # Set GIT_REVISION to the last commit hash. # Please note that the variable is set at configuration time and might be # outdated. find_package(Git) execute_process( COMMAND ${GIT_EXECUTABLE} describe --always HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE) add_compile_options(-W -Wall -fPIC) add_definitions(-DOS_LITTLE_ENDIAN -DNATIVE_64BITS -DGIT_REVISION=\"${GIT_REVISION}\") option( CODE_COVERAGE "Builds targets with code coverage instrumentation. (Requires GCC or Clang)" OFF ) if (CODE_COVERAGE) # Always disable optimisations and build with debug symbols, when building for code coverage add_compile_options(-O0 -g) add_link_options(-g) if (CMAKE_C_COMPILER_ID MATCHES "(Apple)?[Cc]lang") # Options for clang message(STATUS "Building with clang code coverage...") add_compile_options(-fprofile-instr-generate -fcoverage-mapping) add_link_options(-fprofile-instr-generate -fcoverage-mapping) elseif(CMAKE_C_COMPILER_ID MATCHES "GNU") # Options for gcc message(STATUS "Building with gcc code coverage...") add_compile_options(--coverage -fprofile-arcs -ftest-coverage) add_link_options(--coverage -fprofile-arcs -ftest-coverage) else() message(FATAL_ERROR "Unable to identify the compiler! Aborting...") endif() endif() include_directories(sdk src) if (PRECOMPILED_DEPENDENCIES_DIR) message(STATUS "Using OpenSSL and cmocka from ${PRECOMPILED_DEPENDENCIES_DIR}") set(INSTALL_DIR ${PRECOMPILED_DEPENDENCIES_DIR}) add_library(openssl STATIC IMPORTED) else() message(STATUS "Building OpenSSL and cmocka...") set(INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install) set(OPENSSL_CFLAGS "${CMAKE_C_FLAGS}") get_directory_property(compile_options COMPILE_OPTIONS) foreach (opt ${compile_options}) string(APPEND OPENSSL_CFLAGS " ${opt}") endforeach () if (CMAKE_C_COMPILER_TARGET) string(APPEND OPENSSL_CFLAGS " --target=${CMAKE_C_COMPILER_TARGET}") endif () if (CMAKE_SYSROOT) string(APPEND OPENSSL_CFLAGS " -isystem${CMAKE_SYSROOT}/include") endif () string(APPEND OPENSSL_CFLAGS " -Wno-unused-parameter -Wno-missing-field-initializers") ExternalProject_Add( openssl URL https://www.openssl.org/source/openssl-1.1.1k.tar.gz URL_HASH SHA256=892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5 CONFIGURE_COMMAND ./Configure "CC=${CMAKE_C_COMPILER}" "CFLAGS=${OPENSSL_CFLAGS}" no-afalgeng no-aria no-asan no-asm no-async no-autoalginit no-autoerrinit no-autoload-config no-bf no-buildtest-c++ no-camellia no-capieng no-cast no-chacha no-cmac no-cms no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-ct no-deprecated no-des no-devcryptoeng no-dgram no-dh no-dsa no-dso no-dtls no-ecdh no-egd no-engine no-err no-external-tests no-filenames no-fuzz-afl no-fuzz-libfuzzer no-gost no-heartbeats no-hw no-idea no-makedepend no-md2 no-md4 no-mdc2 no-msan no-multiblock no-nextprotoneg no-ocb no-ocsp no-pinshared no-poly1305 no-posix-io no-psk no-rc2 no-rc4 no-rc5 no-rdrand no-rfc3779 no-scrypt no-sctp no-seed no-shared no-siphash no-sm2 no-sm3 no-sm4 no-sock no-srp no-srtp no-sse2 no-ssl no-ssl3-method no-ssl-trace no-stdio no-tests no-threads no-tls no-ts no-ubsan no-ui-console no-unit-test no-whirlpool no-zlib no-zlib-dynamic linux-armv4 --prefix=${INSTALL_DIR} BUILD_COMMAND make INSTALL_COMMAND make install_sw BUILD_IN_SOURCE 1 ) ExternalProject_Add( blst URL https://github.com/supranational/blst/archive/d0bc304a132df43856d8302e15dabee97d3d8a95.tar.gz URL_HASH SHA256=70127766f8031cde3df4224d88f7b33dec6c33fc7ac6b8e4308d4f7d0bdffd7b CONFIGURE_COMMAND "" BUILD_COMMAND sh build.sh CC=arm-linux-gnueabihf-gcc INSTALL_COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/blst-prefix/src/blst/libblst.a ${INSTALL_DIR}/lib/ COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/blst-prefix/src/blst/bindings/blst.h ${INSTALL_DIR}/include/ COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/blst-prefix/src/blst/bindings/blst_aux.h ${INSTALL_DIR}/include/ BUILD_IN_SOURCE 1 ) if (BUILD_TESTING) set(CMOCKA_CMAKE_ARGS -DWITH_STATIC_LIB=true "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}" ) if (CMAKE_TOOLCHAIN_FILE) get_filename_component(abs_cmake_toolchain_file "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE) list(APPEND CMOCKA_CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${abs_cmake_toolchain_file}") endif () ExternalProject_Add(cmocka PREFIX ${CMAKE_CURRENT_BINARY_DIR}/cmocka URL https://cmocka.org/files/1.1/cmocka-1.1.5.tar.xz URL_HASH SHA256=f0ccd8242d55e2fd74b16ba518359151f6f8383ff8aef4976e48393f77bba8b6 CMAKE_ARGS ${CMOCKA_CMAKE_ARGS} ) endif() endif() if (BUILD_TESTING) add_library(cmocka-static STATIC SHARED IMPORTED) add_dependencies(cmocka-static cmocka) endif() include_directories(${INSTALL_DIR}/include) link_directories(${INSTALL_DIR}/lib) link_libraries(ssl crypto dl blst) add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(tests/c/) endif() add_custom_target( copy-launcher ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/src/launcher ${CMAKE_CURRENT_SOURCE_DIR}/speculos/resources/launcher DEPENDS src/launcher COMMENT Copy the launcher in the Python part of Speculos VERBATIM) if (WITH_VNC) externalproject_add(vnc_server SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/vnc" BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/vnc" INSTALL_COMMAND "" ) add_custom_target( copy-vnc-server ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/vnc/vnc_server ${CMAKE_CURRENT_SOURCE_DIR}/speculos/resources/vnc_server DEPENDS vnc_server COMMENT Copy the launcher in the Python part of Speculos VERBATIM) endif() ================================================ FILE: COPYING ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: COPYING.LESSER ================================================ GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. ================================================ FILE: Dockerfiles/Dockerfile ================================================ # This Dockerfile assembles an image with all the dependencies required to run # speculos from the command-line (--display headless or --display console, no # GUI). # # Building the Speculos environment ARG BUILDER_IMAGE=ghcr.io/ledgerhq/speculos-builder:latest FROM ${BUILDER_IMAGE} AS builder ADD . /speculos WORKDIR /speculos/ RUN cmake -Bbuild -H. -DPRECOMPILED_DEPENDENCIES_DIR=/install -DWITH_VNC=1 RUN make -C build # Preparing final image FROM docker.io/library/python:3.10-slim ADD . /speculos WORKDIR /speculos # Copying artifacts from previous build COPY --from=builder /speculos/speculos/resources/ /speculos/speculos/resources/ RUN pip install --upgrade pip pipenv RUN pipenv install --deploy --system RUN apt-get update && apt-get install -qy \ qemu-user-static \ libvncserver-dev \ gdb-multiarch \ binutils-arm-none-eabi \ && apt-get clean RUN apt-get clean && rm -rf /var/lib/apt/lists/ # default port for dev env EXPOSE 1234 EXPOSE 1236 EXPOSE 9999 EXPOSE 40000 EXPOSE 41000 EXPOSE 42000 ENTRYPOINT [ "python", "./speculos.py" ] ================================================ FILE: Dockerfiles/build.Dockerfile ================================================ # Dockerfile to have a container with everything ready to build speculos, # assuming that neither OpenSSL nor cmocka were updated. # # Support Debian buster & Ubuntu Bionic FROM docker.io/library/python:3.10-slim ENV LANG=C.UTF-8 RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ apt-get install -qy \ cmake \ curl \ gcc-arm-linux-gnueabihf \ git \ libc6-dev-armhf-cross \ libvncserver-dev \ python3-pip \ qemu-user-static \ wget && \ apt-get clean && \ rm -rf /var/lib/apt/lists/ # There are issues with PYTHONHOME if using distro packages, use pip instead. RUN pip3 install construct flake8 flask flask_restful jsonschema mnemonic pycrypto pyelftools pbkdf2 pytest Pillow requests # Create SHA256SUMS, download dependencies and verify their integrity RUN \ echo 892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5 openssl-1.1.1k.tar.gz >> SHA256SUMS && \ echo f0ccd8242d55e2fd74b16ba518359151f6f8383ff8aef4976e48393f77bba8b6 cmocka-1.1.5.tar.xz >> SHA256SUMS && \ echo 70127766f8031cde3df4224d88f7b33dec6c33fc7ac6b8e4308d4f7d0bdffd7b d0bc304a132df43856d8302e15dabee97d3d8a95.tar.gz && \ wget --quiet https://www.openssl.org/source/openssl-1.1.1k.tar.gz && \ wget --quiet https://cmocka.org/files/1.1/cmocka-1.1.5.tar.xz && \ wget --quiet https://github.com/supranational/blst/archive/d0bc304a132df43856d8302e15dabee97d3d8a95.tar.gz && \ sha256sum --check SHA256SUMS && \ rm SHA256SUMS # Build dependencies and install them in /install RUN mkdir install && \ tar xf openssl-1.1.1k.tar.gz && \ cd openssl-1.1.1k && \ ./Configure --cross-compile-prefix=arm-linux-gnueabihf- no-asm no-threads no-shared no-sock linux-armv4 --prefix=/install && \ make -j CFLAGS=-mthumb && \ make install_sw && \ cd .. && \ rm -r openssl-1.1.1k/ openssl-1.1.1k.tar.gz RUN mkdir cmocka && \ tar xf cmocka-1.1.5.tar.xz && \ cd cmocka && \ cmake ../cmocka-1.1.5 -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_C_FLAGS=-mthumb -DWITH_STATIC_LIB=true -DCMAKE_INSTALL_PREFIX=/install && \ make install && \ cd .. && \ rm -r cmocka/ cmocka-1.1.5/ cmocka-1.1.5.tar.xz RUN tar xf d0bc304a132df43856d8302e15dabee97d3d8a95.tar.gz && \ cd blst-d0bc304a132df43856d8302e15dabee97d3d8a95 && \ sh build.sh CC=arm-linux-gnueabihf-gcc && \ cp libblst.a ../install/lib/ && \ cp bindings/blst.h ../install/include/ && \ cp bindings/blst_aux.h ../install/include/ && \ cd .. && \ rm -r blst-d0bc304a132df43856d8302e15dabee97d3d8a95/ d0bc304a132df43856d8302e15dabee97d3d8a95.tar.gz CMD ["/bin/bash"] ================================================ FILE: MANIFEST.in ================================================ include CMakeLists.txt recursive-include sdk *.h recursive-include src *.c *.h *.txt include speculos/api/resources/*.schema include speculos/api/static/index.html include speculos/api/static/swagger/*.css include speculos/api/static/swagger/*.html include speculos/api/static/swagger/*.js include speculos/api/static/swagger/*.json include speculos/api/static/swagger/*.md include speculos/cxlib/*.elf include speculos/fonts/*.bin include speculos/mcu/resources/*.schema include speculos/resources/launcher include speculos/resources/vnc_server graft build exclude speculos.py ================================================ FILE: Pipfile ================================================ [[source]] name = "pypi" url = "https://pypi.org/simple" verify_ssl = true [dev-packages] [packages] construct = ">=2.10.56,<3.0.0" flask = ">=2.0.0,<3.0.0" flask-restful = ">=0.3.9,<1.0" jsonschema = ">=3.2.0,<4.18.0" mnemonic = ">=0.19,<1.0" pillow = ">=8.0.0,<11.0.0" pyelftools = ">=0.27,<1.0" requests = ">=2.25.1,<3.0.0" ledgered = ">=0.14.0" flask-cors = "*" pygame = "*" [requires] python_version = "3.10" ================================================ FILE: README.md ================================================ # Speculos [![codecov](https://codecov.io/gh/LedgerHQ/speculos/branch/master/graph/badge.svg)](https://codecov.io/gh/LedgerHQ/speculos) ![screenshot btc nano s](https://raw.githubusercontent.com/LedgerHQ/speculos/master/docs/_static/screenshot-api-nanos-btc.png) The goal of this project is to emulate Ledger Nano S+, Nano X, Apex+, Flex and Stax apps on standard desktop computers, without any hardware device. More information can be found here in the [documentation website](https://ledgerhq.github.io/speculos) (or in the [docs/ folder](docs/) directly). Usage example: ```shell ./speculos.py apps/btc.elf --model nanosp # ... and open a browser on http://127.0.0.1:5000 ``` ## Installation ### From Python `pypi` packages The easiest, stable way to install Speculos is with `pip`: ``` pip install speculos ``` It is advised to use Python virtualenv, otherwise admin rights will probably be necessary. ### From sources Installing Speculos from sources is a bit heavier and, depending on the platform, complex, due to all the dependency needed for compiling the emulator. On Debian (10 or later) or Ubuntu (18.04 or later): ``` sudo apt install \ git cmake gcc-arm-linux-gnueabihf libc6-dev-armhf-cross gdb-multiarch \ python3-pyqt6 python3-construct python3-flask-restful python3-jsonschema \ python3-mnemonic python3-pil python3-pyelftools python3-requests \ qemu-user-static libvncserver-dev # from the root directory of the source repository pip install . ``` Dependency management will vary on other platforms; using Docker images and/or WSL should facilitate the installation. ## Bugs and contributions Feel free to open issues and create pull requests on this GitHub repository. The `master` branch is protected to disable force pushing. Contributions should be made through pull requests, which are reviewed by @LedgerHQ members before being merged to `master`: - @LedgerHQ members can create branches directly on the repository (if member of a team with write access to the repository) - External contributors should fork the repository ## Limitations There is absolutely no guarantee that apps will have the same behavior on hardware devices and Speculos, though the differences are limited. ### Syscalls The emulator handles only a few syscalls made by common apps. For instance, syscalls related to app install, firmware update or OS info can't be implemented. ### Memory alignment Attempts to perform unaligned accesses when not allowed (eg. dereferencing a misaligned pointer) will cause an alignment fault on a Ledger Nano S+ device but not on Speculos. Note that such unaligned accesses are supported by other Ledger devices. Following code crashes on LNS device, but not on Speculos nor on other devices. ``` uint8_t buffer[20]; for (int i = 0; i < 20; i++) { buffer[i] = i; } uint32_t display_value = *((uint32_t*) (buffer + 1)); PRINTF("display_value: %d\n", display_value); ``` ### Watchdog NanoX, Flex, Apex+ and Stax devices use an internal watchdog enforcing usage of regular calls to `io_seproxyhal_io_heartbeat();`. This watchdog is not emulated on Speculos. ## Security Apps can make arbitrary Linux system calls (and use QEMU [semihosting](docs/user/semihosting.md) features), thus don't run Speculos on untrusted apps. It's worth noting that the syscall implementation (`src/`) doesn't expect malicious input. By the way, in Speculos, there is no privilege separation between the app and the syscalls. This doesn't reflect the security of the firmware on hardware devices where app and OS isolation is enforced. Speculos is not part of Ledger bug bounty program. ## Are you developing a Nano App as an external developer? For a smooth and quick integration: - Follow the developers documentation on the [Developer Portal](https://developers.ledger.com/docs/nano-app/introduction/) and - [Go on Discord](https://developers.ledger.com/discord-pro/) to chat with developer support and the developer community. ================================================ FILE: apps/README.md ================================================ The files in these folder are consumed by the tests to ensure that speculos works correctly across various devices and apps. DO NOT use them to test apps or your integrations, as these binaries are old and unmantained. Rather, follow the instructions in the app's repository in order to build the most recent version. ### Naming Examples: - `nanosp#btc#1.5#5b6693b8.elf` If the examples aren't enough, here is the naming convention that should be used: ``` device model # app name # SDK version # git revision .elf ``` where: - `device model` is one of the following: `nanosp`, `stax` - `git revision` is the short hash (8 bytes) of the last commit ================================================ FILE: clang-armv7m.cmake ================================================ # cmake-toolchain configuration to build with clang on Debian and Ubuntu # # Usage: # # cmake -DCMAKE_TOOLCHAIN_FILE=clang-armv7m.cmake -Bbuild -H. && cmake --build build # # Documentation: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_C_COMPILER clang) set(CMAKE_C_COMPILER_TARGET armv7m-linux-gnueabihf) # Use files installed by libc6-dev-armhf-cross # (This adds /usr/arm-linux-gnueabihf/include to CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES) set(CMAKE_SYSROOT /usr/arm-linux-gnueabihf) # Use LLVM linker to link ARM code, as using the system "ld" fails on Ubuntu with x86-64 add_link_options(-fuse-ld=lld) ================================================ FILE: docker-compose.yml ================================================ version: "3.7" services: nanos: build: . image: ghcr.io/ledgerhq/speculos volumes: - ./apps:/speculos/apps ports: - "1234:1234" # gdb - "5000:5000" # api - "40000:40000" # apdu - "41000:41000" # vnc command: "--model nanos ./apps/btc.elf --sdk 2.0 --seed secret --display headless --apdu-port 40000 --vnc-port 41000" # Add `--vnc-password ""` for macos users to use built-in vnc client. ================================================ FILE: docs/CNAME ================================================ speculos.ledger.com ================================================ FILE: docs/Makefile ================================================ # Minimal makefile for Sphinx documentation # # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) ================================================ FILE: docs/conf.py ================================================ # Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information project = 'Speculos' copyright = '2024, Ledger' author = 'Ledger' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = ['myst_parser', 'sphinxcontrib.rawfiles'] templates_path = ['_templates'] exclude_patterns = [] source_suffix = { '.rst': 'restructuredtext', '.txt': 'markdown', '.md': 'markdown', } rawfiles = ['CNAME'] # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output html_theme = "sphinx_rtd_theme" html_static_path = ['_static'] ================================================ FILE: docs/dev/ci.md ================================================ --- sort: 3 --- # Continuous Integration ## Speculos builder The Dockerfile `build.Dockerfile` builds a container with all required dependencies to build speculos: ```shell docker build -f build.Dockerfile -t ghcr.io/ledgerhq/speculos-builder . ``` The resulting container is pushed on [GitHub Packages](https://ghcr.io/ledgerhq/speculos-builder) by the CI and can eventually be used by the CI itself. The image can also be pushed manually with appropriate credentials: ```shell docker push ghcr.io/ledgerhq/speculos-builder:latest docker image tag ghcr.io/ledgerhq/speculos-builder:latest ghcr.io/ledgerhq/speculos-builder:$(git rev-parse --short HEAD) docker push ghcr.io/ledgerhq/speculos-builder:$(git rev-parse --short HEAD) ``` ## Speculos The Dockerfile `Dockerfile` builds a container with all required dependencies to run speculos from the command-line: ```shell docker build -f Dockerfile -t ghcr.io/ledgerhq/speculos . ``` This should be done by the CI, which publish the resulting image on [GitHub Packages](https://ghcr.io/ledgerhq/speculos). ================================================ FILE: docs/dev/getting_started.md ================================================ --- sort: 1 --- # Getting Started ## clang-format clang-format is used by the CI to format C code according to a set of rules and heuristics. The CI checks will fail if some code isn't formatted as expected by the rules. To ensure that the CI checks pass, please use the script `tools/clang-format.sh` (the path to clang-format can be specified thanks to the `CLANG_FORMAT` environment variable): ```shell CLANG_FORMAT=clang-format-11 ./tools/clang-format.sh ``` ================================================ FILE: docs/dev/index.rst ================================================ Developer documentation ======================= .. toctree:: :maxdepth: 1 getting_started tests internals ci ================================================ FILE: docs/dev/internals.md ================================================ --- sort: 4 --- # Internals The emulator is actually a userland application cross-compiled for the ARM architecture. It opens the target app (`app.elf`) from the filesystem and maps it as is in memory. The emulator is launched with `qemu-arm-static` and eventually jumps to the app entrypoint. Apps can be debugged with `gdb-multiarch` thanks to `qemu-arm-static`. ## Syscall hooks The `svc` instruction is replaced with `udf` (undefined) to generate a `SIGILL` signal upon execution. It allows to catch syscalls and emulate them. It can unfortunately lead to unexpected bytes being patched if `\x01\xdf` is found in the binary (and isn't the `svc` instruction). A disassembler could give better results, but it doesn't look worth it. As a side note, the `SVC_Call()` function can't be hooked because some syscalls are inlined. Other alternatives were considered (for instance `seccomp` or `ptrace`) but they seem not practicable because QEMU don't support the [associated syscalls](https://github.com/qemu/qemu/blob/1c4c6fcd1a2ae56e98be3a441e19a0933c508a51/linux-user/syscall.c#L7402). ================================================ FILE: docs/dev/tests.md ================================================ --- sort: 2 --- # Tests ## How to run tests The application binaries launched by the tests should be placed in `apps/`. Every type of app tested should have a dedicated test file that can be launched like this: ```shell python3 -m pytest -s -v tests/apps/ ``` Crypto syscalls are tested using the following command: ```shell make -C build/ test ``` Arguments can be given to `ctest`. For instance, to make the output of a specific test verbose: ```shell make -C build/ test ARGS='-V -R test_bip32' ``` ## Code coverage In order to build with code coverage instrumentation, the CMake configuration supports `CODE_COVERAGE` macro: ```shell cmake -B build/ -DCODE_COVERAGE=ON -S . make -C build/ clean make -C build/ all ``` When using gcc to build the project (which is by default), this enables instrumentation with gcov: these commands created `.gcno` files in `build/`. [lcov](http://ltp.sourceforge.net/coverage/lcov.php) can be used to collect code coverage and generates a HTML report in `coverage/`: ```shell lcov -d . --zerocounters lcov -d . --capture --initial -o coverage.base RNG_SEED=0 make -C build/ test lcov -d . --rc lcov_branch_coverage=1 --capture -o coverage.capture lcov -d . --add-tracefile coverage.base --add-tracefile coverage.capture -o coverage.total genhtml coverage.total -o coverage ``` ================================================ FILE: docs/index.rst ================================================ Speculos documentation ====================== `Source code `_ .. toctree:: :maxdepth: 1 installation/index user/index dev/index Users ----- Installation and basic usage ++++++++++++++++++++++++++++ - Linux: :doc:`Requirements and build` - Mac OS (and Linux) users: :doc:`How to use the Docker image` with VNC - Mac M1 users: :doc:`How to build and use the Docker image` - Windows users: :doc:`Using speculos from WSL 2` - :doc:`Usage` Interaction with an app +++++++++++++++++++++++ - :doc:`How to send APDUs to an app (and more)` - :doc:`How to use gdb to debug an app` - :doc:`How to automate actions thanks to the REST API` For advanced users ++++++++++++++++++ - :doc:`Automation: press buttons automatically` - :doc:`Semihosting as an additional debug mechanism` Speculos developers ------------------- - :doc:`CI (Continuous Integration)` - :doc:`Internals` - :doc:`How to run tests` ================================================ FILE: docs/installation/build.md ================================================ --- sort: 1 --- # Linux ## Requirements For Debian (version 12 "Bookworm" or later) and Ubuntu (version 24.04 or later): ```shell sudo apt install \ git cmake gcc-arm-linux-gnueabihf libc6-dev-armhf-cross gdb-multiarch \ python3-pyqt6 python3-construct python3-flask-restful python3-jsonschema \ python3-mnemonic python3-pil python3-pyelftools python3-requests \ qemu-user-static libvncserver-dev ``` Please note that VNC support (the `libvncserver-dev` package), although necessary for a Python installation, is optional when building only the launcher (see below). ## Build & install Easiest way to build & install Speculos is with `pip`. It will not only compile the launcher, but will also install the Python package wrapped around it, which includes the high-level Speculos entrypoint, used (for instance) in the [Ragger](https://ledgerhq.github.io/ragger/) framework. Following command ought to be executed into a Python virtualenv, else admin rights will be necessary. ```shell pip install . ``` ## Building the Speculos launcher only ### speculos ```shell cmake -B build/ -S . make -C build/ ``` Please note that the first build can take some time because a tarball of OpenSSL is downloaded (the integrity of the downloaded tarball is checked) before being built. Further invocations of `make` skip this step. The following command line can be used for a debug build: ```shell cmake -B build/ -DCMAKE_BUILD_TYPE=Debug -S . ``` ### VNC support (optional) Pass the `WITH_VNC` option to CMake: ```shell cmake -B build/ -DWITH_VNC=1 -S . ``` ================================================ FILE: docs/installation/index.rst ================================================ Installation ============ .. toctree:: :maxdepth: 1 build wsl ================================================ FILE: docs/installation/wsl.md ================================================ --- sort: 2 --- # Windows (with WSL 2) Building in WSL 2 (Windows Subsystem for Linux 2) is identical to the procedure in [building](build.md). Using Speculos with display features requires correctly exporting the X display. Rough steps to do so below, detailed procedure available on [this blogpost](https://techcommunity.microsoft.com/t5/windows-dev-appconsult/running-wsl-gui-apps-on-windows-10/ba-p/1493242). - Add the following to your `.bashrc` within WSL2: ```bash export DISPLAY="`sed -n 's/nameserver //p' /etc/resolv.conf`:0" ``` - Install an X server on your Windows host, like [VcXSrv](https://sourceforge.net/projects/vcxsrv/), and disable access control when prompted to do so. - Simply launch the X server prior to launching an app through Speculos from WSL. ================================================ FILE: docs/requirements.txt ================================================ sphinx<7 # rtd-theme 2.0.0 needs sphinx<8, but is buggy with sphinx 7, so both are pinned # rtd-theme v3 is still beta but should work with newer sphinx versions sphinx-rtd-theme<=2 myst-parser sphinxcontrib-rawfiles ================================================ FILE: docs/user/api.md ================================================ --- sort: 5 --- # REST API A REST API is available at [http://127.0.0.1:5000](http://127.0.0.1:5000) (the port can be changed thanks to `--api-port`) when speculos is running. The specification of the API can be found at this URL, or from the swagger.io [demo website](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/LedgerHQ/speculos/master/speculos/api/static/swagger/swagger.json). This API is meant to be used in test environments to automate actions on the device such as: - Taking screenshot - Pressing buttons - Setting or updating [automation rules](automation.md) - etc. ## Usage For instance, pressing the left button is as simple as: ```shell curl -d '{"action":"press-and-release"}' http://127.0.0.1:5000/button/left ``` and taking a screenshot of the device: ```shell curl -o screenshot.png http://127.0.0.1:5000/screenshot ``` ## Web UI There is a web user interface running directly on [http://127.0.0.1:5000](http://127.0.0.1:5000), which communicates with the API: ![screenshot btc nano s](../_static/screenshot-api-nanos-btc.png) ================================================ FILE: docs/user/automation.md ================================================ --- sort: 6 --- # Automation: press buttons automatically The `--automation` argument allows to apply a set of actions (eg. button press) when a condition is met (usually some text is displayed on the screen). It is especially useful to automate app testing. A JSON file is expected (either a JSON document or a path prefixed by `file:`). ## Rules Rules are a list of rules. Each rule is a dictionary with the following valid keys: - `text`: expected text (string) - `regexp`: regular expression matching the expected text (string) - `x`: x-coordinate of the text (int) - `y`: y-coordinate of the text (int) - `conditions`: list of conditions, described below - `actions`: list of actions, described below Each key is optional. ### Actions 4 actions are available: - `[ "button", num, pressed ]`: press (`pressed=true`) or release (`pressed=false`) a button (`num=1` for left, `num=2` for right) - `[ "finger", x, y, touched ]`: touch (`touched=true`) or release (`touched=false`) the screen (`x` and `y` coordinates) - `[ "setbool", varname, value ]`: set a variable whose name is `varname` to a boolean value (either `true` or `false`) - `[ "exit" ]`: exit speculos The actions of a rule are executed if and only if each rule option matches. These actions are applied successively according to the ordering of the `actions` list. The actions of the first rule matched are applied. Further matching rules are discarded (it allows to implement a *default* rule). ### Conditions Conditions are a list of variables of tuple `(varname, value)` where `varname` is a variable name and `value` a boolean. These variables are set by the `setbool` action and by default an unset variable is equal to `false`. If a non-empty `conditions` list is specified in the rule, each condition should be met (as well as the other options) to allow the actions to be applied. ## Example As an example, one can consider the following automation JSON file: ```json { "version": 1, "rules": [ { "text": "Application", "x": 35, "y": 3, "conditions": [ [ "seen", false ] ], "actions": [ [ "button", 2, true ], [ "button", 2, false ], [ "setbool", "seen", true ] ] }, { "regexp": "\\d+", "actions": [ [ "exit" ] ] }, { "actions": [ [ "setbool", "default_match", true ] ] } ] } ``` The first rule matches only if: - the text displayed at `(35, 3)` is `Application` - this rule was never matched before (because the variable `seen` is set to `true` in the `actions` and expected to be `false` in the `conditions`) If the first rule is matched, the right button (`2`) is pressed then released (`true` then `false`) and the variable `seen` is set to `true`. The second rules matches if the text is a number (regular expression `\d+`) displayed at any coordinates (no `x` nor `y` specified). The action `exit` makes speculos exit without any confirmation. The last rule is a default rule (there are no options). If no previous rule is matched, the variable `default_match` is set to `true`. ================================================ FILE: docs/user/clients.md ================================================ --- sort: 3 --- # Clients: how to send APDUs Clients can communicate with the emulated device using APDUs, as usual. Speculos embbeds a TCP server (listening on `127.0.0.1:9999`) to forward APDUs to the target app. ## ledgerctl (ledgerwallet) [ledgerwallet](https://github.com/LedgerHQ/ledgerctl) is a library to control Ledger devices, also available through the command `ledgerctl` (it can be installed thanks to [pip](https://pypi.org/project/ledgerwallet/)): ```shell pip3 install ledgerwallet ``` If the environment variables `LEDGER_PROXY_ADDRESS` and `LEDGER_PROXY_PORT` are set, the library tries to use the device emulated by Speculos. For instance, the following command-line sends the APDU `e0 c4 00 00 00` (Bitcoin app APDU to get the version): ```shell $ echo 'e0c4000000' | LEDGER_PROXY_ADDRESS=127.0.0.1 LEDGER_PROXY_PORT=9999 ledgerctl send - 13:37:35.096:apdu: > e0c4000000 13:37:35.099:apdu: < 1b3001030e0100039000 1b3001030e0100039000 ``` ## blue-loader-python (ledgerblue) Most clients relies on the [blue-loader-python](https://github.com/LedgerHQ/blue-loader-python/) Python library which supports Speculos since release [0.1.24](https://pypi.org/project/ledgerblue/0.1.24/). This library can be installed through pip using the following command-line: ```shell pip3 install ledgerblue ``` The usage is similar to `ledgerctl`: ```shell $ ./speculos.py ./apps/btc.elf & $ echo 'e0c4000000' | LEDGER_PROXY_ADDRESS=127.0.0.1 LEDGER_PROXY_PORT=9999 python3 -m ledgerblue.runScript --apdu => b'e0c4000000' <= b'1b30010308010003'9000 <= Clear bytearray(b'\x1b0\x01\x03\x08\x01\x00\x03') ``` ## btchip-python Use [btchip-python](https://github.com/LedgerHQ/btchip-python) without a real device: ```shell PYTHONPATH=$(pwd) LEDGER_PROXY_ADDRESS=127.0.0.1 LEDGER_PROXY_PORT=9999 python tests/testMultisigArmory.py ``` Note: `btchip-python` relies on its own library to communicate with devices (physical or emulated) instead of `ledgerblue` to transmit APDUs. ## ledger-live-common ```shell ./tools/ledger-live-http-proxy.py & DEBUG_COMM_HTTP_PROXY=http://127.0.0.1:9998 ledger-live getAddress -c btc --path "m/49'/0'/0'/0/0" --derivationMode segwit ``` ================================================ FILE: docs/user/debug.md ================================================ --- sort: 4 --- # Debug: how to use GDB Debug an app thanks to GDB: ```shell ./speculos.py -d apps/btc.elf & ./tools/debug.sh apps/btc.elf ``` Some useful tricks: - Use the `-t` (`--trace`) argument to trace every syscalls. - [Semihosting](semihosting.md) features can be used as an additional debug mechanism. ================================================ FILE: docs/user/docker.md ================================================ # Docker ## How to use the Docker image A docker image is available on [GitHub Packages](https://ghcr.io/ledgerhq/speculos). Pull the latest image: ```shell docker pull ghcr.io/ledgerhq/speculos docker image tag ghcr.io/ledgerhq/speculos speculos ``` And run the image with a few arguments from the root of the speculos project: ```shell docker run --rm -it -v $(pwd)/apps:/speculos/apps --publish 41000:41000 speculos --display headless --vnc-port 41000 apps/btc.elf ``` - The app folder (here `$(pwd)/apps/`) is mounted thanks to `-v` - The VNC server is available from the host thanks to `--publish` The image can obviously run an interactive shell with `--entrypoint /bin/bash`. ### Arguments All the arguments which are supported by `speculos.py` can be passed on the Docker command-line. Don't forget to publish container's ports when required using `-p`: ```shell docker run --rm -it -v "$(pwd)"/apps:/speculos/apps \ -p 1234:1234 -p 5000:5000 -p 40000:40000 -p 41000:41000 speculos \ --model nanos ./apps/btc.elf --sdk 2.0 --seed "secret" --display headless --apdu-port 40000 --vnc-port 41000 ``` ### Debug ```shell docker run --rm -it -v "$(pwd)"/apps:/speculos/apps -p 1234:1234 -p 5000:5000 -p 40000:40000 -p 41000:41000 --entrypoint /bin/bash speculos ``` ### docker-compose setup ```shell docker-compose up [-d] ``` > Default configuration is nanos / 2.0 / btc.elf / seed "secret" Edit `docker-compose.yml` to configure port forwarding and environment variables that fit your needs. ## Build The following command-line can be used to create a docker image based on a local [build](../installation/build.md): ```shell docker build ./ -t speculos ``` ================================================ FILE: docs/user/index.rst ================================================ User ==== .. toctree:: :maxdepth: 1 api automation clients debug docker macm1 semihosting usage ================================================ FILE: docs/user/macm1.md ================================================ # Docker - for Mac M1 ## How to build the Docker image Edit the `Dockerfile` and perform the following modification Replace line #1 ``` FROM ghcr.io/ledgerhq/speculos-builder:latest AS builder ``` with ``` FROM ghcr.io/ledgerhq/speculos-builder-aarch64:latest AS builder ``` Then build the Docker container image with the following command: ```shell docker build ./ -t speculos ``` If the build is successful, you should have a docker image named speculos: ```shell docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE speculos latest 634c66a13457 15 minutes ago 593MB ``` ## How to use the Docker image Run the image with a few arguments from the root of the speculos project: ```shell docker run --rm -it -v $(pwd)/apps:/speculos/apps --publish 41000:41000 --publish 5001:5001 speculos --display headless --vnc-port 41000 --api-port 5001 apps/btc.elf ``` - The app folder (here `$(pwd)/apps/`) is mounted thanks to `-v` - The VNC server is available from the host thanks to `--publish` The image can obviously run an interactive shell with `--entrypoint /bin/bash`. ### Arguments All the arguments which are supported by `speculos.py` can be passed on the Docker command-line. Don't forget to publish container's ports when required using `-p`: ```shell docker run --rm -it -v "$(pwd)"/apps:/speculos/apps \ -p 1234:1234 -p 5000:5000 -p 40000:40000 -p 41000:41000 speculos \ --model nanos ./apps/btc.elf --sdk 2.0 --seed "secret" --display headless --apdu-port 40000 --vnc-port 41000 ``` ### Debug ```shell docker run --rm -it -v "$(pwd)"/apps:/speculos/apps -p 1234:1234 -p 5000:5000 -p 40000:40000 -p 41000:41000 --entrypoint /bin/bash speculos ``` ### docker-compose setup ```shell docker-compose up [-d] ``` > Default configuration is nanos / 2.0 / btc.elf / seed "secret" Edit `docker-compose.yml` to configure port forwarding and environment variables that fit your needs. ================================================ FILE: docs/user/semihosting.md ================================================ --- sort: 7 --- # Semihosting as an additional debug mechanism QEMU implements some semihosted operations which can be triggered from the app. For instance, messages can be printed to stderr with the following code: ## SYS_WRITE0 ```C void debug_write(char *buf) { asm volatile ( "movs r0, #0x04\n" "movs r1, %0\n" "svc 0xab\n" :: "r"(buf) : "r0", "r1" ); } ``` The operation number must be passed in `r0` (here `SYS_WRITE0` operation is defined to `0x04`) and arguments are in `r1`, `r2` and `r3`. Usage: ```C debug_write("magic!\n"); ``` ## References - [ARM semihosting](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471c/Bgbjjgij.html) - [Semihosting for AArch32 and AArch64 - Release 2.0](https://static.docs.arm.com/100863/0200/semihosting.pdf) - [qemu/target/arm/arm-semi.c](https://github.com/qemu/qemu/blob/8de702cb677c8381fb702cae252d6b69aa4c653b/target/arm/arm-semi.c) ================================================ FILE: docs/user/usage.md ================================================ --- sort: 1 --- # Usage After having [installed the requirements and built](../installation/build.md) speculos: ```shell ./speculos.py apps/btc.elf ``` The docker image can also be used directly, as detailed in the specific [docker documentation page](docker.md). With applications built by recent SDKs, Speculos can automatically detect the targeted device. The Nano X, Nano S+, Flex, Stax and Apex+ can be specified on the command line: ```shell ./speculos.py --model nanox apps/nanox#btc#2.0.2#1c8db8da.elf ./speculos.py --model nanosp apps/nanosp#btc#1.0.3#17bf7619.elf ./speculos.py --model stax apps/btc.elf.elf ./speculos.py --model flex apps/btc.elf.elf ``` The last SDK version is automatically selected. However, a specific version be specified if the target app is not build against the last version of the SDK, thanks to the `-k`/`--sdk` argument. For instance, to launch an app built against the SDK `1.5` on the Nano S: ```shell ./speculos.py --sdk 1.5 --model nanosp apps/btc.elf ``` Supported SDK values for each device are defined in [src/sdk.h](https://github.com/LedgerHQ/speculos/blob/master/src/sdk.h). You main choose the SDK using `-k`/`--sdk` argument: | | Nano S+ | Nano X | |-----|------------|-----------------| | SDK | 1.0, 1.0.3 | 1.2, 2.0, 2.0.2 | For more options, pass the `-h` or `--help` flag. ## Keyboard control - The keyboard left and right arrow keys are used instead of the Nano buttons. The down arrow can also be used as a more convenient shortcut. - The `Q` key exits the application. ## Display Several display options are available through the `--display` parameter: - `qt`: default, requires a X server - `headless`: nothing is displayed - `text`: the UI is displayed in the console (handy on Windows) These options can be used along `--vnc-port` which spawns a VNC server on the specified port. macOS users should also add `--vnc-password ` if using the built-in VNC client because unauthenticated sessions doesn't seem to be supported (issue #34). A recording of the screen can be saved as a GIF file thanks to the `tools/gif-recorder.py` script. ## App name and version On a real device, some parameters specific to the app to be installed (name and version, icon, allowed derivation paths, etc.) are given during the installation. This information isn't embedded in the .elf file itself and thus cannot be retrieved by speculos. The default app name and version are respectively `app` `1.33.7`, but these values can be set through the `SPECULOS_APPNAME` environment variable. For instance: ```shell $ SPECULOS_APPNAME=blah:1.2.3.4 ./speculos.py ./apps/btc.elf & $ echo 'b0 01 00 00 00' \ | LEDGER_PROXY_ADDRESS=127.0.0.1 LEDGER_PROXY_PORT=9999 ledgerctl send - \ | xxd -r -ps \ | hd 00000000 01 04 62 6c 61 68 07 31 2e 32 2e 33 2e 34 01 00 |..blah.1.2.3.4..| 00000010 90 00 |..| 00000012 ``` # Bitcoin Testnet app Launch the Bitcoin Testnet app, which requires the Bitcoin app: ```shell ./speculos.py ./apps/btc-test.elf -l Bitcoin:./apps/btc.elf ``` ## OCR OCR is available for NanoX, Nanos S+, Flex, Stax and Apex+ with built in character recognition. ================================================ FILE: gcc-arm.cmake ================================================ # cmake-toolchain configuration to build with gcc on Debian and Ubuntu # # Usage: # # cmake -DCMAKE_TOOLCHAIN_FILE=gcc-arm.cmake -Bbuild -H. && cmake --build build # # Documentation: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) set(CMAKE_C_FLAGS "-mthumb" CACHE STRING "" FORCE) ================================================ FILE: lgtm.yml ================================================ # Test with: # podman run --rm -v $(pwd):/code -ti ubuntu:19.10 bash # apt update && apt install -y build-essential cmake gcc-arm-linux-gnueabihf gcc-arm-none-eabi libvncserver-dev # cd /code # # Run commands from "configure" and "build_command" sections extraction: cpp: prepare: packages: - cmake - gcc-arm-linux-gnueabihf - gcc-arm-none-eabi - libvncserver-dev configure: command: - cmake -Bbuild -H. -DWITH_VNC=1 index: build_command: - make -C build ================================================ FILE: pyproject.toml ================================================ [build-system] requires = [ "setuptools", "wheel", "setuptools_scm", "cmake" ] build-backend = "setuptools.build_meta" [project] name = "speculos" authors = [{name = "Ledger"}] description = "Ledger Stax, Flex, Apex+ and Nano S+/X application emulator" classifiers = [ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: POSIX :: Linux", "Operating System :: MacOS :: MacOS X", ] requires-python = ">=3.10" dependencies = [ "construct>=2.10.56,<3.0.0", "flask>=2.0.0,<3.0.0", "flask-restful>=0.3.9,<1.0", "flask-cors>=5.0.0,<7.0.0", "jsonschema>=3.2.0,<4.18.0", "mnemonic>=0.19,<1.0", "pillow>=8.0.0,<11.0.0", "pyelftools>=0.27,<1.0", "pyqt6>=6.4.0,<7.0.0", "requests>=2.25.1,<3.0.0", "ledgered>=0.14.0", "pygame>=2.6.1", ] dynamic = ["version"] [project.readme] file = "README.md" content-type = "text/markdown" [project.urls] Homepage = "https://github.com/LedgerHQ/speculos" "Bug Tracker" = "https://github.com/LedgerHQ/speculos/issues" [project.optional-dependencies] dev = [ "pytest", "pytest-cov" ] [project.scripts] speculos = "speculos.main:main" [tool.setuptools] include-package-data = true [tool.setuptools.packages] find = {namespaces = false} [tool.setuptools_scm] write_to = "speculos/__version__.py" local_scheme = "no-local-version" [tool.mypy] ignore_missing_imports = true [tool.flake8] max-line-length = 120 ================================================ FILE: sdk/bolos_syscalls.h ================================================ #pragma once /********************* * INCLUDES *********************/ /********************* * DEFINES *********************/ // the number of parameters of a syscall is stored in the syscall id #define SYSCALL_NUMBER_OF_PARAMETERS(id) (((id) >> 24) & 0xf) // clang-format off #define SYSCALL_get_api_level_ID_IN 0x00000001 #define SYSCALL_halt_ID_IN 0x00000002 #define SYSCALL_nvm_write_ID_IN 0x03000003 #define SYSCALL_nvm_erase_ID_IN 0x02000121 #define SYSCALL_cx_aes_set_key_hw_ID_IN 0x020000b2 #define SYSCALL_cx_aes_reset_hw_ID_IN 0x000000b3 #define SYSCALL_cx_aes_block_hw_ID_IN 0x020000b4 #define SYSCALL_cx_bn_lock_ID_IN 0x02000112 #define SYSCALL_cx_bn_unlock_ID_IN 0x000000b6 #define SYSCALL_cx_bn_is_locked_ID_IN 0x000000b7 #define SYSCALL_cx_bn_alloc_ID_IN 0x02000113 #define SYSCALL_cx_bn_alloc_init_ID_IN 0x04000114 #define SYSCALL_cx_bn_destroy_ID_IN 0x010000bc #define SYSCALL_cx_bn_nbytes_ID_IN 0x0200010d #define SYSCALL_cx_bn_init_ID_IN 0x03000115 #define SYSCALL_cx_bn_rand_ID_IN 0x010000ea #define SYSCALL_cx_bn_copy_ID_IN 0x020000c0 #define SYSCALL_cx_bn_set_u32_ID_IN 0x020000c1 #define SYSCALL_cx_bn_get_u32_ID_IN 0x020000eb #define SYSCALL_cx_bn_export_ID_IN 0x030000c3 #define SYSCALL_cx_bn_cmp_ID_IN 0x030000c4 #define SYSCALL_cx_bn_cmp_u32_ID_IN 0x030000c5 #define SYSCALL_cx_bn_is_odd_ID_IN 0x02000118 #define SYSCALL_cx_bn_xor_ID_IN 0x030000c8 #define SYSCALL_cx_bn_or_ID_IN 0x030000c9 #define SYSCALL_cx_bn_and_ID_IN 0x030000ca #define SYSCALL_cx_bn_tst_bit_ID_IN 0x030000cb #define SYSCALL_cx_bn_set_bit_ID_IN 0x020000cc #define SYSCALL_cx_bn_clr_bit_ID_IN 0x020000cd #define SYSCALL_cx_bn_shr_ID_IN 0x020000ce #define SYSCALL_cx_bn_shl_ID_IN 0x0200011c #define SYSCALL_cx_bn_cnt_bits_ID_IN 0x020000ec #define SYSCALL_cx_bn_add_ID_IN 0x03000119 #define SYSCALL_cx_bn_sub_ID_IN 0x0300011a #define SYSCALL_cx_bn_mul_ID_IN 0x030000d2 #define SYSCALL_cx_bn_mod_add_ID_IN 0x040000d3 #define SYSCALL_cx_bn_mod_sub_ID_IN 0x040000d4 #define SYSCALL_cx_bn_mod_mul_ID_IN 0x040000d5 #define SYSCALL_cx_bn_reduce_ID_IN 0x030000d6 #define SYSCALL_cx_bn_mod_sqrt_ID_IN 0x0400011d #define SYSCALL_cx_bn_mod_pow_bn_ID_IN 0x040000d7 #define SYSCALL_cx_bn_mod_pow_ID_IN 0x050000ed #define SYSCALL_cx_bn_mod_pow2_ID_IN 0x050000ee #define SYSCALL_cx_bn_mod_invert_nprime_ID_IN 0x030000da #define SYSCALL_cx_bn_mod_u32_invert_ID_IN 0x03000116 #define SYSCALL_cx_bn_is_prime_ID_IN 0x020000ef #define SYSCALL_cx_bn_next_prime_ID_IN 0x010000f0 #define SYSCALL_cx_bn_rng_ID_IN 0x020001dd #define SYSCALL_cx_bn_gf2_n_mul_ID_IN 0x05000046 #define SYSCALL_cx_mont_alloc_ID_IN 0x020000dc #define SYSCALL_cx_mont_init_ID_IN 0x020000dd #define SYSCALL_cx_mont_init2_ID_IN 0x030000de #define SYSCALL_cx_mont_to_montgomery_ID_IN 0x030000df #define SYSCALL_cx_mont_from_montgomery_ID_IN 0x030000e0 #define SYSCALL_cx_mont_mul_ID_IN 0x040000e1 #define SYSCALL_cx_mont_pow_ID_IN 0x050000e2 #define SYSCALL_cx_mont_pow_bn_ID_IN 0x040000e3 #define SYSCALL_cx_mont_invert_nprime_ID_IN 0x030000e4 #define SYSCALL_cx_ecdomain_size_ID_IN 0x0200012e #define SYSCALL_cx_ecdomain_parameters_length_ID_IN 0x0200012f #define SYSCALL_cx_ecdomain_parameter_ID_IN 0x04000130 #define SYSCALL_cx_ecdomain_parameter_bn_ID_IN 0x03000131 #define SYSCALL_cx_ecdomain_generator_ID_IN 0x04000132 #define SYSCALL_cx_ecdomain_generator_bn_ID_IN 0x02000133 #define SYSCALL_cx_ecpoint_alloc_ID_IN 0x020000f1 #define SYSCALL_cx_ecpoint_destroy_ID_IN 0x010000f2 #define SYSCALL_cx_ecpoint_init_ID_IN 0x050000f3 #define SYSCALL_cx_ecpoint_init_bn_ID_IN 0x030000f4 #define SYSCALL_cx_ecpoint_export_ID_IN 0x050000f5 #define SYSCALL_cx_ecpoint_export_bn_ID_IN 0x030000f6 #define SYSCALL_cx_ecpoint_compress_ID_IN 0x0400012c #define SYSCALL_cx_ecpoint_decompress_ID_IN 0x0400012d #define SYSCALL_cx_ecpoint_add_ID_IN 0x0300010e #define SYSCALL_cx_ecpoint_neg_ID_IN 0x0100010f #define SYSCALL_cx_ecpoint_scalarmul_ID_IN 0x03000110 #define SYSCALL_cx_ecpoint_scalarmul_bn_ID_IN 0x02000111 #define SYSCALL_cx_ecpoint_rnd_scalarmul_ID_IN 0x03000127 #define SYSCALL_cx_ecpoint_rnd_scalarmul_bn_ID_IN 0x02000128 #define SYSCALL_cx_ecpoint_rnd_fixed_scalarmul_ID_IN 0x03000129 #define SYSCALL_cx_ecpoint_double_scalarmul_ID_IN 0x07000148 #define SYSCALL_cx_ecpoint_double_scalarmul_bn_ID_IN 0x0500014a #define SYSCALL_cx_ecpoint_cmp_ID_IN 0x030000fb #define SYSCALL_cx_ecpoint_is_on_curve_ID_IN 0x020000fc #define SYSCALL_cx_ecpoint_is_at_infinity_ID_IN 0x0200014b #define SYSCALL_cx_ecpoint_x25519_ID_IN 0x0300001b #define SYSCALL_cx_ecpoint_x448_ID_IN 0x03000060 #define SYSCALL_cx_vss_generate_shares_ID_IN 0x0a000001 #define SYSCALL_cx_vss_combine_shares_ID_IN 0x04000002 #define SYSCALL_cx_vss_verify_commits_ID_IN 0x05000003 #define SYSCALL_cx_crc_hw_ID_IN 0x04000102 #define SYSCALL_ox_bls12381_sign_ID_IN 0x05000103 #define SYSCALL_cx_hash_to_field_ID_IN 0x06000104 #define SYSCALL_cx_bls12381_aggregate_ID_IN 0x05000105 #define SYSCALL_cx_bls12381_key_gen_ID_IN 0x03000108 #define SYSCALL_cx_get_random_bytes_ID_IN 0x02000107 #define SYSCALL_cx_trng_get_random_data_ID_IN 0x02000106 #define SYSCALL_RESERVED_7_ID_IN 0x0000004b #define SYSCALL_RESERVED_8_ID_IN 0x0400004e #define SYSCALL_RESERVED_9_ID_IN 0x0700004f #define SYSCALL_RESERVED_10_ID_IN 0x02000050 #define SYSCALL_RESERVED_11_ID_IN 0x01000051 #define SYSCALL_os_perso_is_pin_set_ID_IN 0x0000009e #define SYSCALL_os_perso_isonboarded_ID_IN 0x0000009f #define SYSCALL_RESERVED_12_ID_IN 0x03000094 #define SYSCALL_os_perso_derive_node_bip32_ID_IN 0x05000053 #define SYSCALL_os_perso_derive_node_with_seed_key_ID_IN 0x080000a6 #define SYSCALL_os_perso_derive_eip2333_ID_IN 0x040000a7 #define SYSCALL_HDKEY_derive_ID_IN 0x0a000002 #define SYSCALL_RESERVED_13_ID_IN 0x02000052 #define SYSCALL_RESERVED_14_ID_IN 0x02000054 #define SYSCALL_os_perso_get_master_key_identifier_ID_IN 0x02000055 #define SYSCALL_ENDORSEMENT_GET_CODE_HASH_ID_IN 0x01000055 #define SYSCALL_ENDORSEMENT_GET_PUB_KEY_ID_IN 0x03000056 #define SYSCALL_ENDORSEMENT_GET_PUB_KEY_SIG_ID_IN 0x03000057 #define SYSCALL_ENDORSEMENT_KEY1_GET_APP_SECRET_ID_IN 0x01000058 #define SYSCALL_ENDORSEMENT_KEY1_SIGN_DATA_ID_IN 0x04000059 #define SYSCALL_ENDORSEMENT_KEY2_DERIVE_AND_SIGN_DATA_ID_IN 0x0400005a #define SYSCALL_ENDORSEMENT_KEY1_SIGN_WITHOUT_CODE_HASH_ID_IN 0x0400005b #define SYSCALL_RESERVED_15_ID_IN 0x0400004c #define SYSCALL_RESERVED_16_ID_IN 0x0200004d #define SYSCALL_os_global_pin_is_validated_ID_IN 0x000000a0 #define SYSCALL_os_global_pin_check_ID_IN 0x020000a1 #define SYSCALL_os_global_pin_invalidate_ID_IN 0x0000005d #define SYSCALL_os_global_pin_retries_ID_IN 0x0000005e #define SYSCALL_RESERVED_3_ID_IN 0x0000005f #define SYSCALL_RESERVED_4_ID_IN 0x02000122 #define SYSCALL_os_ux_ID_IN 0x01000064 #define SYSCALL_os_lib_call_ID_IN 0x01000067 #define SYSCALL_os_lib_end_ID_IN 0x00000068 #define SYSCALL_os_flags_ID_IN 0x0000006a #define SYSCALL_os_version_ID_IN 0x0200006b #define SYSCALL_os_serial_ID_IN 0x0200006c #define SYSCALL_os_seph_features_ID_IN 0x0000006e #define SYSCALL_os_seph_version_ID_IN 0x0200006f #define SYSCALL_os_bootloader_version_ID_IN 0x02000073 #define SYSCALL_os_factory_setting_get_ID_IN 0x0300014c #define SYSCALL_os_setting_get_ID_IN 0x03000070 #define SYSCALL_os_setting_set_ID_IN 0x03000071 #define SYSCALL_RESERVED_5_ID_IN 0x06000123 #define SYSCALL_RESERVED_6_ID_IN 0x00000125 #define SYSCALL_RESERVED_34_ID_IN 0x01000126 #define SYSCALL_os_sched_exit_ID_IN 0x0100009a #define SYSCALL_os_sched_is_running_ID_IN 0x0100009b #define SYSCALL_os_sched_create_ID_IN 0x0700011b #define SYSCALL_os_sched_kill_ID_IN 0x01000078 #define SYSCALL_os_io_seph_tx_ID_IN 0x03000082 #define SYSCALL_os_io_seph_se_rx_event_ID_IN 0x05000083 #define SYSCALL_os_io_init_ID_IN 0x01000084 #define SYSCALL_os_io_start_ID_IN 0x01000085 #define SYSCALL_os_io_stop_ID_IN 0x01000086 #define SYSCALL_os_io_tx_cmd_ID_IN 0x04000088 #define SYSCALL_os_io_rx_evt_ID_IN 0x03000089 #define SYSCALL_nvm_write_page_ID_IN 0x0100010a #define SYSCALL_nvm_erase_page_ID_IN 0x01000136 #define SYSCALL_try_context_get_ID_IN 0x00000087 #define SYSCALL_try_context_set_ID_IN 0x0100010b #define SYSCALL_os_sched_last_status_ID_IN 0x0100009c #define SYSCALL_os_sched_yield_ID_IN 0x0100009d #define SYSCALL_os_sched_switch_ID_IN 0x0200009e #define SYSCALL_os_sched_current_task_ID_IN 0x0000008b #define SYSCALL_os_allow_protected_flash_ID_IN 0x0000008e #define SYSCALL_os_deny_protected_flash_ID_IN 0x00000091 #define SYSCALL_os_allow_protected_ram_ID_IN 0x00000092 #define SYSCALL_os_deny_protected_ram_ID_IN 0x00000093 #define SYSCALL_os_set_ux_time_ms_ID_IN 0x010000a2 #define SYSCALL_os_pki_load_certificate_ID_IN 0x060000aa #define SYSCALL_os_pki_verify_ID_IN 0x040000ab #define SYSCALL_os_pki_get_info_ID_IN 0x040000ac #define SYSCALL_RESERVED_20_ID_IN 0x02000150 #define SYSCALL_RESERVED_21_ID_IN 0x03000151 #define SYSCALL_RESERVED_22_ID_IN 0x01000152 #define SYSCALL_RESERVED_23_ID_IN 0x01000155 #define SYSCALL_RESERVED_24_ID_IN 0x01000CA0 #define SYSCALL_RESERVED_25_ID_IN 0x00000CA1 #define SYSCALL_RESERVED_2_ID_IN 0x010001ED #define SYSCALL_RESERVED_1_ID_IN 0x010001EE #define SYSCALL_ENDORSEMENT_GET_METADATA_ID_IN 0x02000138 #define SYSCALL_RESERVED_17_ID_IN 0x02000137 #define SYSCALL_RESERVED_18_ID_IN 0x00000149 #define SYSCALL_RESERVED_19_ID_IN 0x00000152 #define SYSCALL_screen_clear_ID_IN 0x00000079 #define SYSCALL_screen_update_ID_IN 0x0000007a #define SYSCALL_screen_set_keepout_ID_IN 0x0400007b #define SYSCALL_screen_set_brightness_ID_IN 0x0100008c #define SYSCALL_bagl_hal_draw_bitmap_within_rect_ID_IN 0x0900007c #define SYSCALL_bagl_hal_draw_rect_ID_IN 0x0500007d #define SYSCALL_os_ux_set_status_ID_IN 0x02000134 #define SYSCALL_os_ux_get_status_ID_IN 0x01000135 #define SYSCALL_io_button_read_ID_IN 0x0000008f #define SYSCALL_os_standby_ID_IN 0x0000d0d0 #define SYSCALL_os_seph_serial_ID_IN 0x0200006d #define SYSCALL_RESERVED_26_ID_IN 0x01000153 #define SYSCALL_RESERVED_27_ID_IN 0x01000154 #define SYSCALL_os_stack_operations_ID_IN 0x01000199 #define SYSCALL_nbgl_front_draw_rect_ID_IN 0x01fa0000 #define SYSCALL_nbgl_front_draw_horizontal_line_ID_IN 0x03fa0001 #define SYSCALL_nbgl_front_draw_img_ID_IN 0x04fa0002 #define SYSCALL_nbgl_front_refresh_area_ID_IN 0x03fa0003 #define SYSCALL_nbgl_front_draw_img_file_ID_IN 0x05fa0004 #define SYSCALL_nbgl_side_draw_rect_ID_IN 0x01fa0005 #define SYSCALL_nbgl_side_draw_horizontal_line_ID_IN 0x03fa0006 #define SYSCALL_nbgl_side_draw_img_ID_IN 0x04fa0007 #define SYSCALL_nbgl_side_refresh_area_ID_IN 0x02fa0008 #define SYSCALL_nbgl_screen_reinit_ID_IN 0x00fa000d #define SYSCALL_nbgl_front_draw_img_rle_ID_IN 0x05fa0010 #define SYSCALL_nbgl_front_control_area_masking_ID_IN 0x03fa0012 #define SYSCALL_nbgl_wait_pipeline_ID_IN 0x00fa0011 #define SYSCALL_nbgl_screen_update_temperature_ID_IN 0x01fa0011 #define SYSCALL_nbgl_screen_config_fast_mode_ID_IN 0x00fa0012 #define SYSCALL_fetch_background_img 0x01fa0009 #define SYSCALL_delete_background_img 0x01fa000a #define SYSCALL_touch_get_last_info_ID_IN 0x01fa000b #define SYSCALL_touch_exclude_borders_ID_IN 0x01fa000d #define SYSCALL_touch_set_state_ID_IN 0x01fa000e #define SYSCALL_touch_debug_ID_IN 0x03fa000f // -- Pre API_LEVEL_23 #define SYSCALL_os_endorsement_get_code_hash_ID_IN 0x01000055 #define SYSCALL_os_endorsement_get_public_key_ID_IN 0x03000056 #define SYSCALL_os_endorsement_get_public_key_certificate_ID_IN 0x03000057 #define SYSCALL_os_endorsement_key1_get_app_secret_ID_IN 0x01000058 #define SYSCALL_os_endorsement_key1_sign_data_ID_IN 0x03000059 #define SYSCALL_os_endorsement_key2_derive_sign_data_ID_IN 0x0300005a #define SYSCALL_os_endorsement_key1_sign_without_code_hash_ID_IN 0x0300005b // -- Pre API_LEVEL_26 #define SYSCALL_ENDORSEMENT_get_code_hash_ID_IN 0x01000055 #define SYSCALL_ENDORSEMENT_get_public_key_ID_IN 0x03000056 #define SYSCALL_ENDORSEMENT_get_public_key_certificate_ID_IN 0x03000057 #define SYSCALL_ENDORSEMENT_key1_get_app_secret_ID_IN 0x01000058 #define SYSCALL_ENDORSEMENT_key1_sign_data_ID_IN 0x03000059 #define SYSCALL_ENDORSEMENT_key2_derive_and_sign_data_ID_IN 0x0300005a #define SYSCALL_ENDORSEMENT_key1_sign_without_code_hash_ID_IN 0x0300005b // -- Pre API_LEVEL_25 #define SYSCALL_io_seph_send_ID_IN 0x02000083 #define SYSCALL_io_seph_is_status_sent_ID_IN 0x00000084 #define SYSCALL_io_seph_recv_ID_IN 0x03000085 #define SYSCALL_os_registry_get_current_app_tag_ID_IN 0x03000074 #define SYSCALL_nbgl_get_font_ID_IN 0x01fa000c #define SYSCALL_hdkey_derive_ID_IN 0x0a000002 /********************** * TYPEDEFS **********************/ /********************** * STATIC VARIABLES **********************/ /********************** * STATIC INLINE **********************/ /********************** * GLOBAL PROTOTYPES **********************/ // clang-format on ================================================ FILE: setup.py ================================================ #!/usr/bin/env python3 """Install Speculos""" import pathlib import shutil import tempfile from setuptools.command.build_py import build_py as _build_py from setuptools import setup class BuildSpeculos(_build_py): """ Extend "setup.py build_py" to build Speculos launcher and VNC server using cmake. This command requires some system dependencies (ARM compiler, libvncserver headers...) which are documented on https://speculos.ledger.com/installation/build.html distutils documentation about extending the build command: https://docs.python.org/3.8/distutils/extending.html#integrating-new-commands """ def run(self): if not shutil.which("cmake"): raise RuntimeError("cmake is not found and is required to build Speculos") if not self.dry_run: pathlib.Path(self.build_lib).mkdir(parents=True, exist_ok=True) with tempfile.TemporaryDirectory(prefix="build-", dir=self.build_lib) as build_dir: self.spawn( [ "cmake", "-H.", "-B" + build_dir, "-DCMAKE_BUILD_TYPE=Release", "-DBUILD_TESTING=0", "-DWITH_VNC=1", ] ) self.spawn(["cmake", "--build", build_dir]) super().run() setup( cmdclass={ "build_py": BuildSpeculos, }, ) ================================================ FILE: speculos/__init__.py ================================================ from . import api # noqa: F401 from . import client # noqa: F401 from . import mcu # noqa: F401 try: from speculos.__version__ import __version__ # noqa except ImportError: __version__ = "unknown version" # noqa ================================================ FILE: speculos/__main__.py ================================================ from . import main if __name__ == "__main__": main.main(prog="speculos") ================================================ FILE: speculos/api/README.md ================================================ ## Generate Convert the specification file from YAML to JSON: ```shell docker pull docker.io/swaggerapi/swagger-converter:v1.0.2 docker run --rm -it -p 8080:8080 docker.io/swaggerapi/swagger-converter:v1.0.2 wget --quiet -O- --header 'content-type: application/yaml' --post-file api/swagger.yaml \ http://127.0.0.1:8080/api/convert | jq . > api/static/swagger/swagger.json ``` The following command can be used to serve (and retrieve) the swagger-ui using the generated JSON file: ```shell docker run --rm -p 8080:8080 -e SWAGGER_JSON=/api/swagger/swagger.json -v "$(pwd)/speculos/api:/api" docker.io/swaggerapi/swagger-ui for f in index.html swagger-ui.css favicon-32x32.png favicon-16x16.png swagger-ui-bundle.js swagger-ui-standalone-preset.js; do wget --quiet -O "speculos/api/static/swagger/$f" "http://127.0.0.1:8080/$f" done ``` ## References - https://editor.swagger.io/ - https://swagger.io/specification/ - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md - https://openapi-generator.tech/docs/online/ ================================================ FILE: speculos/api/__init__.py ================================================ from .api import ApiRunner # noqa: F401 from .events import EventsBroadcaster # noqa: F401 ================================================ FILE: speculos/api/apdu.py ================================================ import json import threading import jsonschema from flask import stream_with_context, Response, request from typing import Generator, Optional from speculos.resources_importer import get_resource_schema_as_json from ..mcu.seproxyhal import SeProxyHal from .restful import SephResource class APDUBridge: def __init__(self, seph: SeProxyHal): # We want to be notified when APDU response is transmitted from the SE self.endpoint_lock = threading.Lock() self.response_condition = threading.Condition() self._seph = seph self._seph.apdu_callbacks.append(self.seph_apdu_callback) self.response: Optional[bytes] def exchange(self, data: bytes, tick_timeout: int = 5 * 60 * 10) -> Generator[bytes, None, None]: # force headers to be sent yield b"" tick_count_before_exchange = self._seph.get_tick_count() with self.endpoint_lock: # Lock for a command/response for one client with self.response_condition: self.response = None self._seph.to_app(data) with self.response_condition: while self.response is None: self.response_condition.wait(0.1) exchange_tick_count = self._seph.get_tick_count() - tick_count_before_exchange if tick_timeout != 0 and exchange_tick_count > tick_timeout: raise TimeoutError() yield json.dumps({"data": self.response.hex()}).encode() def seph_apdu_callback(self, data: bytes) -> None: """ Called by seph when data is transmitted by the SE. That data should be the response to a prior APDU request """ with self.response_condition: self.response = data self.response_condition.notify() class APDU(SephResource): schema = get_resource_schema_as_json("api", "apdu.schema") def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._bridge = APDUBridge(self.seph) def post(self): args = request.get_json(force=True) try: jsonschema.validate(instance=args, schema=self.schema) except jsonschema.exceptions.ValidationError as e: return {"error": f"{e}"}, 400 data = bytes.fromhex(args.get("data")) if "tick_timeout" in args: tick_timeout = args["tick_timeout"] return Response(stream_with_context(self._bridge.exchange(data, tick_timeout)), content_type="application/json") return Response(stream_with_context(self._bridge.exchange(data)), content_type="application/json") ================================================ FILE: speculos/api/api.py ================================================ import socket import threading from typing import Any, Dict from flask import Flask from flask_restful import Api from flask_cors import CORS import flask.cli from speculos.mcu.display import DisplayNotifier, IODevice from speculos.mcu.readerror import ReadError from speculos.mcu.seproxyhal import SeProxyHal from speculos.observer import BroadcastInterface from speculos.resources_importer import resources from .apdu import APDU from .automation import Automation from .button import Button from .events import Events from .finger import Finger from .screenshot import Screenshot from .swagger import Swagger from .web_interface import WebInterface from .ticker import Ticker class ApiRunner(IODevice): """Run the Speculos API server in a dedicated thread, with a notification when it stops""" def __init__(self, api_port: int) -> None: self._api_wrapper: ApiWrapper # self.sock is used by Screen.add_notifier. Closing self._notify_exit # signals it that the API is no longer running. self.sock: socket.socket self._notify_exit: socket.socket self.sock, self._notify_exit = socket.socketpair() self._port: int = api_port self._api_thread: threading.Thread @property def file(self): return self.sock def can_read(self, screen: DisplayNotifier) -> None: # Being able to read from the socket only happens when the API server exited. raise ReadError("API server exited") def start_server_thread(self, screen_: DisplayNotifier, seph_: SeProxyHal, automation_server: BroadcastInterface) -> None: self._api_wrapper = ApiWrapper(self._port, screen_, seph_, automation_server) self._api_thread = threading.Thread(target=self._api_wrapper.run, name="API-server", daemon=True) self._api_thread.start() def stop(self): self._notify_exit.close() class ApiWrapper: def __init__(self, api_port: int, screen: DisplayNotifier, seph: SeProxyHal, automation_server: BroadcastInterface): self._port = api_port static_folder = str(resources.files(__package__) / "static") # Remove the Flask startup banner flask.cli.show_server_banner = lambda *a: None self._app = Flask(__name__, static_url_path="", static_folder=static_folder) self._app.env = "development" CORS(self._app, resources={r"*": {"origins": "*"}}, supports_credentials=True) screen_kwargs = {"screen": screen} seph_kwargs = {"seph": seph} app_kwargs = {"app": self._app} event_kwargs: Dict[str, Any] = {**app_kwargs, "automation_server": automation_server} self._api = Api(self._app) self._api.add_resource(APDU, "/apdu", resource_class_kwargs=seph_kwargs) self._api.add_resource(Automation, "/automation", resource_class_kwargs=seph_kwargs) self._api.add_resource(Button, "/button/left", "/button/right", "/button/both", resource_class_kwargs=seph_kwargs) self._api.add_resource(Events, "/events", resource_class_kwargs=event_kwargs) self._api.add_resource(Finger, "/finger", resource_class_kwargs=seph_kwargs) self._api.add_resource(Screenshot, "/screenshot", resource_class_kwargs=screen_kwargs) self._api.add_resource(Swagger, "/swagger/", resource_class_kwargs=app_kwargs) self._api.add_resource(WebInterface, "/", resource_class_kwargs=app_kwargs) self._api.add_resource(Ticker, "/ticker/", resource_class_kwargs=seph_kwargs) def run(self): # threaded must be set to allow serving requests along events streaming self._app.run(host="0.0.0.0", port=self._port, threaded=True, use_reloader=False) ================================================ FILE: speculos/api/automation.py ================================================ import json import jsonschema from flask import request from ..mcu import automation as mcu_automation from .restful import SephResource class Automation(SephResource): def post(self): document = request.get_data() try: document = document.decode("ascii") except UnicodeDecodeError: return "invalid encoding", 400 if document.startswith("file:"): return "invalid document", 400 try: rules = mcu_automation.Automation(document) except json.decoder.JSONDecodeError: return "invalid document", 400 except jsonschema.exceptions.ValidationError: return "invalid document", 400 self.seph.automation = rules return {}, 200 ================================================ FILE: speculos/api/button.py ================================================ import jsonschema from flask import request from speculos.resources_importer import get_resource_schema_as_json from .restful import SephResource class Button(SephResource): schema = get_resource_schema_as_json("api", "button.schema") def post(self): args = request.get_json(force=True) try: jsonschema.validate(instance=args, schema=self.schema) except jsonschema.exceptions.ValidationError as e: return {"error": f"{e}"}, 400 button = request.base_url.split("/")[-1] buttons = {"left": [1], "right": [2], "both": [1, 2]} action = args["action"] delay = args.get("delay", 0.1) if action == "press-and-release": for b in buttons[button]: self.seph.handle_button(b, True) self.seph.handle_wait(delay) for b in buttons[button]: self.seph.handle_button(b, False) # Some app tests rely on this delay to make sure the screen is updated # and the app is ready to process next button press. # This is dangerous but we keep it as is to not break everything. self.seph.handle_wait(delay) else: for b in buttons[button]: self.seph.handle_button(b, action == "press") return {}, 200 ================================================ FILE: speculos/api/events.py ================================================ import json import logging import threading from typing import Dict, Generator, List, Optional, Tuple, Union from dataclasses import asdict from flask import stream_with_context, Response from flask_restful import inputs, reqparse from speculos.observer import BroadcastInterface, ObserverInterface, TextEvent from .restful import AppResource class EventsBroadcaster(BroadcastInterface): """This used to be the 'Automation Server'.""" def __init__(self) -> None: super().__init__() self.screen_content: List[TextEvent] = [] self.events: List[TextEvent] = [] self.condition = threading.Condition() self.logger = logging.getLogger("events") def clear_events(self) -> None: self.logger.debug("Clearing events") self.screen_content = [] def broadcast(self, event: TextEvent) -> None: if event.clear: self.clear_events() return self.logger.debug("events: broadcasting %s to %d client(s)", asdict(event), len(self.clients)) self.screen_content.append(event) self.events.append(event) for client in self.clients: client.send_screen_event(event) with self.condition: self.condition.notify_all() class EventClient(ObserverInterface): def __init__(self, broadcaster: EventsBroadcaster) -> None: self.events: List[TextEvent] = [] self._broadcaster = broadcaster def generate(self) -> Generator[bytes, None, None]: try: # force headers to be sent yield b"" while True: with self._broadcaster.condition: self._broadcaster.condition.wait(1) while self.events: event = self.events.pop(0) data = json.dumps(asdict(event)) # Format the event as specified in the specification: # https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream yield f"data: {data}\n\n".encode() finally: self._broadcaster.remove_client(self) def send_screen_event(self, event: TextEvent) -> None: self.events.append(event) class Events(AppResource): def __init__(self, *args, automation_server: Optional[EventsBroadcaster] = None, **kwargs) -> None: if automation_server is None: raise RuntimeError("Argument 'automation_server' must not be None") self._broadcaster = automation_server self.parser = reqparse.RequestParser() self.parser.add_argument("stream", type=inputs.boolean, default=False, location='values') self.parser.add_argument("currentscreenonly", type=inputs.boolean, default=False, location='values') super().__init__(*args, **kwargs) def get(self) -> Union[Response, Tuple[Dict[str, List], int]]: args = self.parser.parse_args() if args.stream: client = EventClient(self._broadcaster) self._broadcaster.add_client(client) return Response(stream_with_context(client.generate()), content_type="text/event-stream") elif args.currentscreenonly: event_list = self._broadcaster.screen_content else: event_list = self._broadcaster.events return {"events": [asdict(e) for e in event_list]}, 200 def delete(self) -> Tuple[Dict, int]: self._broadcaster.events.clear() return {}, 200 ================================================ FILE: speculos/api/finger.py ================================================ import jsonschema from flask import request from speculos.resources_importer import get_resource_schema_as_json from .restful import SephResource class Finger(SephResource): schema = get_resource_schema_as_json("api", "finger.schema") def post(self): args = request.get_json(force=True) try: jsonschema.validate(instance=args, schema=self.schema) except jsonschema.exceptions.ValidationError as e: return {"error": f"{e}"}, 400 action = args["action"] delay = args.get("delay", 0.1) x1, y1 = args["x"], args["y"] if action == "press-and-release": self.seph.handle_finger(x1, y1, True) self.seph.handle_wait(delay) x2, y2 = args.get("x2", x1), args.get("y2", y1) self.seph.handle_finger(x2, y2, False) else: self.seph.handle_finger(x1, y1, action == "press") return {}, 200 ================================================ FILE: speculos/api/resources/apdu.schema ================================================ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "data": { "type": "string", "pattern": "^([a-fA-F0-9]{2})+$" }, "tick_timeout": { "type": "number"} }, "required": [ "data" ], "additionalProperties": false } ================================================ FILE: speculos/api/resources/button.schema ================================================ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "action": { "enum": [ "press", "release", "press-and-release" ] }, "delay": { "type": "number" } }, "required": [ "action" ], "additionalProperties": false } ================================================ FILE: speculos/api/resources/finger.schema ================================================ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "x": { "type": "integer", "minimum": 0 }, "y": { "type": "integer", "minimum": 0 }, "x2": { "type": "integer", "minimum": 0 }, "y2": { "type": "integer", "minimum": 0 }, "action": { "enum": [ "press", "release", "press-and-release" ] }, "delay": { "type": "number" } }, "required": [ "action", "x", "y" ], "additionalProperties": false } ================================================ FILE: speculos/api/resources/ticker.schema ================================================ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "action": { "enum": [ "pause", "resume", "single-step"] } }, "required": [ "action" ], "additionalProperties": false } ================================================ FILE: speculos/api/restful.py ================================================ from flask import Flask from typing import Optional from flask_restful import Resource from ..mcu.seproxyhal import SeProxyHal class SephResource(Resource): def __init__(self, *args, seph: Optional[SeProxyHal] = None, **kwargs): if seph is None: raise RuntimeError("Argument 'seph' must not be None") super().__init__(*args, **kwargs) self._seph = seph @property def seph(self): return self._seph class AppResource(Resource): def __init__(self, *args, app: Optional[Flask] = None, **kwargs): if app is None: raise RuntimeError("Argument 'app' must not be None") super().__init__(*args, **kwargs) self._app = app @property def app(self): return self._app class ScreenResource(Resource): def __init__(self, *args, screen=None, **kwargs): if screen is None: raise RuntimeError("Argument 'screen' must not be None") super().__init__(*args, **kwargs) self._screen = screen @property def screen(self): return self._screen ================================================ FILE: speculos/api/screenshot.py ================================================ from flask import Response from .restful import ScreenResource class Screenshot(ScreenResource): def get(self): iobytes_value = self.screen.display.m.get_public_screenshot() response = Response(iobytes_value, mimetype="image/png") response.headers.add("Cache-control", "no-cache,no-store") return response ================================================ FILE: speculos/api/static/index.html ================================================ Speculos Web Interface
Device screen

APDUs

Events

================================================ FILE: speculos/api/static/swagger/README.md ================================================ This directory is automatically generated using instructions from ../../README.md. ================================================ FILE: speculos/api/static/swagger/index.html ================================================ Swagger UI
================================================ FILE: speculos/api/static/swagger/swagger-ui-bundle.js ================================================ /*! For license information please see swagger-ui-bundle.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(function(){try{return require("esprima")}catch(e){}}()):"function"==typeof define&&define.amd?define(["esprima"],t):"object"==typeof exports?exports.SwaggerUIBundle=t(function(){try{return require("esprima")}catch(e){}}()):e.SwaggerUIBundle=t(e.esprima)}(this,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist",n(n.s=555)}([function(e,t,n){"use strict";e.exports=n(131)},function(e,t,n){e.exports=function(){"use strict";var e=Array.prototype.slice;function t(e,t){t&&(e.prototype=Object.create(t.prototype)),e.prototype.constructor=e}function n(e){return i(e)?e:J(e)}function r(e){return s(e)?e:K(e)}function o(e){return u(e)?e:Y(e)}function a(e){return i(e)&&!c(e)?e:G(e)}function i(e){return!(!e||!e[p])}function s(e){return!(!e||!e[f])}function u(e){return!(!e||!e[h])}function c(e){return s(e)||u(e)}function l(e){return!(!e||!e[d])}t(r,n),t(o,n),t(a,n),n.isIterable=i,n.isKeyed=s,n.isIndexed=u,n.isAssociative=c,n.isOrdered=l,n.Keyed=r,n.Indexed=o,n.Set=a;var p="@@__IMMUTABLE_ITERABLE__@@",f="@@__IMMUTABLE_KEYED__@@",h="@@__IMMUTABLE_INDEXED__@@",d="@@__IMMUTABLE_ORDERED__@@",m="delete",v=5,g=1<>>0;if(""+n!==t||4294967295===n)return NaN;t=n}return t<0?A(e)+t:t}function k(){return!0}function j(e,t,n){return(0===e||void 0!==n&&e<=-n)&&(void 0===t||void 0!==n&&t>=n)}function T(e,t){return P(e,t,0)}function I(e,t){return P(e,t,t)}function P(e,t,n){return void 0===e?n:e<0?Math.max(0,t+e):void 0===t?e:Math.min(t,e)}var N=0,M=1,R=2,D="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=D||L;function F(e){this.next=e}function U(e,t,n,r){var o=0===e?t:1===e?n:[t,n];return r?r.value=o:r={value:o,done:!1},r}function q(){return{value:void 0,done:!0}}function z(e){return!!H(e)}function V(e){return e&&"function"==typeof e.next}function W(e){var t=H(e);return t&&t.call(e)}function H(e){var t=e&&(D&&e[D]||e[L]);if("function"==typeof t)return t}function $(e){return e&&"number"==typeof e.length}function J(e){return null==e?ie():i(e)?e.toSeq():ce(e)}function K(e){return null==e?ie().toKeyedSeq():i(e)?s(e)?e.toSeq():e.fromEntrySeq():se(e)}function Y(e){return null==e?ie():i(e)?s(e)?e.entrySeq():e.toIndexedSeq():ue(e)}function G(e){return(null==e?ie():i(e)?s(e)?e.entrySeq():e:ue(e)).toSetSeq()}F.prototype.toString=function(){return"[Iterator]"},F.KEYS=N,F.VALUES=M,F.ENTRIES=R,F.prototype.inspect=F.prototype.toSource=function(){return this.toString()},F.prototype[B]=function(){return this},t(J,n),J.of=function(){return J(arguments)},J.prototype.toSeq=function(){return this},J.prototype.toString=function(){return this.__toString("Seq {","}")},J.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},J.prototype.__iterate=function(e,t){return pe(this,e,t,!0)},J.prototype.__iterator=function(e,t){return fe(this,e,t,!0)},t(K,J),K.prototype.toKeyedSeq=function(){return this},t(Y,J),Y.of=function(){return Y(arguments)},Y.prototype.toIndexedSeq=function(){return this},Y.prototype.toString=function(){return this.__toString("Seq [","]")},Y.prototype.__iterate=function(e,t){return pe(this,e,t,!1)},Y.prototype.__iterator=function(e,t){return fe(this,e,t,!1)},t(G,J),G.of=function(){return G(arguments)},G.prototype.toSetSeq=function(){return this},J.isSeq=ae,J.Keyed=K,J.Set=G,J.Indexed=Y;var Z,X,Q,ee="@@__IMMUTABLE_SEQ__@@";function te(e){this._array=e,this.size=e.length}function ne(e){var t=Object.keys(e);this._object=e,this._keys=t,this.size=t.length}function re(e){this._iterable=e,this.size=e.length||e.size}function oe(e){this._iterator=e,this._iteratorCache=[]}function ae(e){return!(!e||!e[ee])}function ie(){return Z||(Z=new te([]))}function se(e){var t=Array.isArray(e)?new te(e).fromEntrySeq():V(e)?new oe(e).fromEntrySeq():z(e)?new re(e).fromEntrySeq():"object"==typeof e?new ne(e):void 0;if(!t)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+e);return t}function ue(e){var t=le(e);if(!t)throw new TypeError("Expected Array or iterable object of values: "+e);return t}function ce(e){var t=le(e)||"object"==typeof e&&new ne(e);if(!t)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+e);return t}function le(e){return $(e)?new te(e):V(e)?new oe(e):z(e)?new re(e):void 0}function pe(e,t,n,r){var o=e._cache;if(o){for(var a=o.length-1,i=0;i<=a;i++){var s=o[n?a-i:i];if(!1===t(s[1],r?s[0]:i,e))return i+1}return i}return e.__iterateUncached(t,n)}function fe(e,t,n,r){var o=e._cache;if(o){var a=o.length-1,i=0;return new F((function(){var e=o[n?a-i:i];return i++>a?q():U(t,r?e[0]:i-1,e[1])}))}return e.__iteratorUncached(t,n)}function he(e,t){return t?de(t,e,"",{"":e}):me(e)}function de(e,t,n,r){return Array.isArray(t)?e.call(r,n,Y(t).map((function(n,r){return de(e,n,r,t)}))):ve(t)?e.call(r,n,K(t).map((function(n,r){return de(e,n,r,t)}))):t}function me(e){return Array.isArray(e)?Y(e).map(me).toList():ve(e)?K(e).map(me).toMap():e}function ve(e){return e&&(e.constructor===Object||void 0===e.constructor)}function ge(e,t){if(e===t||e!=e&&t!=t)return!0;if(!e||!t)return!1;if("function"==typeof e.valueOf&&"function"==typeof t.valueOf){if((e=e.valueOf())===(t=t.valueOf())||e!=e&&t!=t)return!0;if(!e||!t)return!1}return!("function"!=typeof e.equals||"function"!=typeof t.equals||!e.equals(t))}function ye(e,t){if(e===t)return!0;if(!i(t)||void 0!==e.size&&void 0!==t.size&&e.size!==t.size||void 0!==e.__hash&&void 0!==t.__hash&&e.__hash!==t.__hash||s(e)!==s(t)||u(e)!==u(t)||l(e)!==l(t))return!1;if(0===e.size&&0===t.size)return!0;var n=!c(e);if(l(e)){var r=e.entries();return t.every((function(e,t){var o=r.next().value;return o&&ge(o[1],e)&&(n||ge(o[0],t))}))&&r.next().done}var o=!1;if(void 0===e.size)if(void 0===t.size)"function"==typeof e.cacheResult&&e.cacheResult();else{o=!0;var a=e;e=t,t=a}var p=!0,f=t.__iterate((function(t,r){if(n?!e.has(t):o?!ge(t,e.get(r,b)):!ge(e.get(r,b),t))return p=!1,!1}));return p&&e.size===f}function be(e,t){if(!(this instanceof be))return new be(e,t);if(this._value=e,this.size=void 0===t?1/0:Math.max(0,t),0===this.size){if(X)return X;X=this}}function _e(e,t){if(!e)throw new Error(t)}function xe(e,t,n){if(!(this instanceof xe))return new xe(e,t,n);if(_e(0!==n,"Cannot step a Range by 0"),e=e||0,void 0===t&&(t=1/0),n=void 0===n?1:Math.abs(n),tr?q():U(e,o,n[t?r-o++:o++])}))},t(ne,K),ne.prototype.get=function(e,t){return void 0===t||this.has(e)?this._object[e]:t},ne.prototype.has=function(e){return this._object.hasOwnProperty(e)},ne.prototype.__iterate=function(e,t){for(var n=this._object,r=this._keys,o=r.length-1,a=0;a<=o;a++){var i=r[t?o-a:a];if(!1===e(n[i],i,this))return a+1}return a},ne.prototype.__iterator=function(e,t){var n=this._object,r=this._keys,o=r.length-1,a=0;return new F((function(){var i=r[t?o-a:a];return a++>o?q():U(e,i,n[i])}))},ne.prototype[d]=!0,t(re,Y),re.prototype.__iterateUncached=function(e,t){if(t)return this.cacheResult().__iterate(e,t);var n=W(this._iterable),r=0;if(V(n))for(var o;!(o=n.next()).done&&!1!==e(o.value,r++,this););return r},re.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult().__iterator(e,t);var n=W(this._iterable);if(!V(n))return new F(q);var r=0;return new F((function(){var t=n.next();return t.done?t:U(e,r++,t.value)}))},t(oe,Y),oe.prototype.__iterateUncached=function(e,t){if(t)return this.cacheResult().__iterate(e,t);for(var n,r=this._iterator,o=this._iteratorCache,a=0;a=r.length){var t=n.next();if(t.done)return t;r[o]=t.value}return U(e,o,r[o++])}))},t(be,Y),be.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},be.prototype.get=function(e,t){return this.has(e)?this._value:t},be.prototype.includes=function(e){return ge(this._value,e)},be.prototype.slice=function(e,t){var n=this.size;return j(e,t,n)?this:new be(this._value,I(t,n)-T(e,n))},be.prototype.reverse=function(){return this},be.prototype.indexOf=function(e){return ge(this._value,e)?0:-1},be.prototype.lastIndexOf=function(e){return ge(this._value,e)?this.size:-1},be.prototype.__iterate=function(e,t){for(var n=0;n=0&&t=0&&nn?q():U(e,a++,i)}))},xe.prototype.equals=function(e){return e instanceof xe?this._start===e._start&&this._end===e._end&&this._step===e._step:ye(this,e)},t(we,n),t(Ee,we),t(Se,we),t(Ce,we),we.Keyed=Ee,we.Indexed=Se,we.Set=Ce;var Ae="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(e,t){var n=65535&(e|=0),r=65535&(t|=0);return n*r+((e>>>16)*r+n*(t>>>16)<<16>>>0)|0};function Oe(e){return e>>>1&1073741824|3221225471&e}function ke(e){if(!1===e||null==e)return 0;if("function"==typeof e.valueOf&&(!1===(e=e.valueOf())||null==e))return 0;if(!0===e)return 1;var t=typeof e;if("number"===t){if(e!=e||e===1/0)return 0;var n=0|e;for(n!==e&&(n^=4294967295*e);e>4294967295;)n^=e/=4294967295;return Oe(n)}if("string"===t)return e.length>Fe?je(e):Te(e);if("function"==typeof e.hashCode)return e.hashCode();if("object"===t)return Ie(e);if("function"==typeof e.toString)return Te(e.toString());throw new Error("Value type "+t+" cannot be hashed.")}function je(e){var t=ze[e];return void 0===t&&(t=Te(e),qe===Ue&&(qe=0,ze={}),qe++,ze[e]=t),t}function Te(e){for(var t=0,n=0;n0)switch(e.nodeType){case 1:return e.uniqueID;case 9:return e.documentElement&&e.documentElement.uniqueID}}var Re,De="function"==typeof WeakMap;De&&(Re=new WeakMap);var Le=0,Be="__immutablehash__";"function"==typeof Symbol&&(Be=Symbol(Be));var Fe=16,Ue=255,qe=0,ze={};function Ve(e){_e(e!==1/0,"Cannot perform this action with an infinite size.")}function We(e){return null==e?ot():He(e)&&!l(e)?e:ot().withMutations((function(t){var n=r(e);Ve(n.size),n.forEach((function(e,n){return t.set(n,e)}))}))}function He(e){return!(!e||!e[Je])}t(We,Ee),We.of=function(){var t=e.call(arguments,0);return ot().withMutations((function(e){for(var n=0;n=t.length)throw new Error("Missing value for key: "+t[n]);e.set(t[n],t[n+1])}}))},We.prototype.toString=function(){return this.__toString("Map {","}")},We.prototype.get=function(e,t){return this._root?this._root.get(0,void 0,e,t):t},We.prototype.set=function(e,t){return at(this,e,t)},We.prototype.setIn=function(e,t){return this.updateIn(e,b,(function(){return t}))},We.prototype.remove=function(e){return at(this,e,b)},We.prototype.deleteIn=function(e){return this.updateIn(e,(function(){return b}))},We.prototype.update=function(e,t,n){return 1===arguments.length?e(this):this.updateIn([e],t,n)},We.prototype.updateIn=function(e,t,n){n||(n=t,t=void 0);var r=vt(this,wn(e),t,n);return r===b?void 0:r},We.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):ot()},We.prototype.merge=function(){return ft(this,void 0,arguments)},We.prototype.mergeWith=function(t){return ft(this,t,e.call(arguments,1))},We.prototype.mergeIn=function(t){var n=e.call(arguments,1);return this.updateIn(t,ot(),(function(e){return"function"==typeof e.merge?e.merge.apply(e,n):n[n.length-1]}))},We.prototype.mergeDeep=function(){return ft(this,ht,arguments)},We.prototype.mergeDeepWith=function(t){var n=e.call(arguments,1);return ft(this,dt(t),n)},We.prototype.mergeDeepIn=function(t){var n=e.call(arguments,1);return this.updateIn(t,ot(),(function(e){return"function"==typeof e.mergeDeep?e.mergeDeep.apply(e,n):n[n.length-1]}))},We.prototype.sort=function(e){return zt(pn(this,e))},We.prototype.sortBy=function(e,t){return zt(pn(this,t,e))},We.prototype.withMutations=function(e){var t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this},We.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new S)},We.prototype.asImmutable=function(){return this.__ensureOwner()},We.prototype.wasAltered=function(){return this.__altered},We.prototype.__iterator=function(e,t){return new et(this,e,t)},We.prototype.__iterate=function(e,t){var n=this,r=0;return this._root&&this._root.iterate((function(t){return r++,e(t[1],t[0],n)}),t),r},We.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?rt(this.size,this._root,e,this.__hash):(this.__ownerID=e,this.__altered=!1,this)},We.isMap=He;var $e,Je="@@__IMMUTABLE_MAP__@@",Ke=We.prototype;function Ye(e,t){this.ownerID=e,this.entries=t}function Ge(e,t,n){this.ownerID=e,this.bitmap=t,this.nodes=n}function Ze(e,t,n){this.ownerID=e,this.count=t,this.nodes=n}function Xe(e,t,n){this.ownerID=e,this.keyHash=t,this.entries=n}function Qe(e,t,n){this.ownerID=e,this.keyHash=t,this.entry=n}function et(e,t,n){this._type=t,this._reverse=n,this._stack=e._root&&nt(e._root)}function tt(e,t){return U(e,t[0],t[1])}function nt(e,t){return{node:e,index:0,__prev:t}}function rt(e,t,n,r){var o=Object.create(Ke);return o.size=e,o._root=t,o.__ownerID=n,o.__hash=r,o.__altered=!1,o}function ot(){return $e||($e=rt(0))}function at(e,t,n){var r,o;if(e._root){var a=w(_),i=w(x);if(r=it(e._root,e.__ownerID,0,void 0,t,n,a,i),!i.value)return e;o=e.size+(a.value?n===b?-1:1:0)}else{if(n===b)return e;o=1,r=new Ye(e.__ownerID,[[t,n]])}return e.__ownerID?(e.size=o,e._root=r,e.__hash=void 0,e.__altered=!0,e):r?rt(o,r):ot()}function it(e,t,n,r,o,a,i,s){return e?e.update(t,n,r,o,a,i,s):a===b?e:(E(s),E(i),new Qe(t,r,[o,a]))}function st(e){return e.constructor===Qe||e.constructor===Xe}function ut(e,t,n,r,o){if(e.keyHash===r)return new Xe(t,r,[e.entry,o]);var a,i=(0===n?e.keyHash:e.keyHash>>>n)&y,s=(0===n?r:r>>>n)&y;return new Ge(t,1<>>=1)i[s]=1&n?t[a++]:void 0;return i[r]=o,new Ze(e,a+1,i)}function ft(e,t,n){for(var o=[],a=0;a>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,e+=e>>8,127&(e+=e>>16)}function yt(e,t,n,r){var o=r?e:C(e);return o[t]=n,o}function bt(e,t,n,r){var o=e.length+1;if(r&&t+1===o)return e[t]=n,e;for(var a=new Array(o),i=0,s=0;s=xt)return ct(e,u,r,o);var f=e&&e===this.ownerID,h=f?u:C(u);return p?s?c===l-1?h.pop():h[c]=h.pop():h[c]=[r,o]:h.push([r,o]),f?(this.entries=h,this):new Ye(e,h)}},Ge.prototype.get=function(e,t,n,r){void 0===t&&(t=ke(n));var o=1<<((0===e?t:t>>>e)&y),a=this.bitmap;return 0==(a&o)?r:this.nodes[gt(a&o-1)].get(e+v,t,n,r)},Ge.prototype.update=function(e,t,n,r,o,a,i){void 0===n&&(n=ke(r));var s=(0===t?n:n>>>t)&y,u=1<=wt)return pt(e,f,c,s,d);if(l&&!d&&2===f.length&&st(f[1^p]))return f[1^p];if(l&&d&&1===f.length&&st(d))return d;var m=e&&e===this.ownerID,g=l?d?c:c^u:c|u,_=l?d?yt(f,p,d,m):_t(f,p,m):bt(f,p,d,m);return m?(this.bitmap=g,this.nodes=_,this):new Ge(e,g,_)},Ze.prototype.get=function(e,t,n,r){void 0===t&&(t=ke(n));var o=(0===e?t:t>>>e)&y,a=this.nodes[o];return a?a.get(e+v,t,n,r):r},Ze.prototype.update=function(e,t,n,r,o,a,i){void 0===n&&(n=ke(r));var s=(0===t?n:n>>>t)&y,u=o===b,c=this.nodes,l=c[s];if(u&&!l)return this;var p=it(l,e,t+v,n,r,o,a,i);if(p===l)return this;var f=this.count;if(l){if(!p&&--f0&&r=0&&e>>t&y;if(r>=this.array.length)return new kt([],e);var o,a=0===r;if(t>0){var i=this.array[r];if((o=i&&i.removeBefore(e,t-v,n))===i&&a)return this}if(a&&!o)return this;var s=Lt(this,e);if(!a)for(var u=0;u>>t&y;if(o>=this.array.length)return this;if(t>0){var a=this.array[o];if((r=a&&a.removeAfter(e,t-v,n))===a&&o===this.array.length-1)return this}var i=Lt(this,e);return i.array.splice(o+1),r&&(i.array[o]=r),i};var jt,Tt,It={};function Pt(e,t){var n=e._origin,r=e._capacity,o=qt(r),a=e._tail;return i(e._root,e._level,0);function i(e,t,n){return 0===t?s(e,n):u(e,t,n)}function s(e,i){var s=i===o?a&&a.array:e&&e.array,u=i>n?0:n-i,c=r-i;return c>g&&(c=g),function(){if(u===c)return It;var e=t?--c:u++;return s&&s[e]}}function u(e,o,a){var s,u=e&&e.array,c=a>n?0:n-a>>o,l=1+(r-a>>o);return l>g&&(l=g),function(){for(;;){if(s){var e=s();if(e!==It)return e;s=null}if(c===l)return It;var n=t?--l:c++;s=i(u&&u[n],o-v,a+(n<=e.size||t<0)return e.withMutations((function(e){t<0?Ft(e,t).set(0,n):Ft(e,0,t+1).set(t,n)}));t+=e._origin;var r=e._tail,o=e._root,a=w(x);return t>=qt(e._capacity)?r=Dt(r,e.__ownerID,0,t,n,a):o=Dt(o,e.__ownerID,e._level,t,n,a),a.value?e.__ownerID?(e._root=o,e._tail=r,e.__hash=void 0,e.__altered=!0,e):Nt(e._origin,e._capacity,e._level,o,r):e}function Dt(e,t,n,r,o,a){var i,s=r>>>n&y,u=e&&s0){var c=e&&e.array[s],l=Dt(c,t,n-v,r,o,a);return l===c?e:((i=Lt(e,t)).array[s]=l,i)}return u&&e.array[s]===o?e:(E(a),i=Lt(e,t),void 0===o&&s===i.array.length-1?i.array.pop():i.array[s]=o,i)}function Lt(e,t){return t&&e&&t===e.ownerID?e:new kt(e?e.array.slice():[],t)}function Bt(e,t){if(t>=qt(e._capacity))return e._tail;if(t<1<0;)n=n.array[t>>>r&y],r-=v;return n}}function Ft(e,t,n){void 0!==t&&(t|=0),void 0!==n&&(n|=0);var r=e.__ownerID||new S,o=e._origin,a=e._capacity,i=o+t,s=void 0===n?a:n<0?a+n:o+n;if(i===o&&s===a)return e;if(i>=s)return e.clear();for(var u=e._level,c=e._root,l=0;i+l<0;)c=new kt(c&&c.array.length?[void 0,c]:[],r),l+=1<<(u+=v);l&&(i+=l,o+=l,s+=l,a+=l);for(var p=qt(a),f=qt(s);f>=1<p?new kt([],r):h;if(h&&f>p&&iv;g-=v){var b=p>>>g&y;m=m.array[b]=Lt(m.array[b],r)}m.array[p>>>v&y]=h}if(s=f)i-=f,s-=f,u=v,c=null,d=d&&d.removeBefore(r,0,i);else if(i>o||f>>u&y;if(_!==f>>>u&y)break;_&&(l+=(1<o&&(c=c.removeBefore(r,u,i-l)),c&&fa&&(a=c.size),i(u)||(c=c.map((function(e){return he(e)}))),r.push(c)}return a>e.size&&(e=e.setSize(a)),mt(e,t,r)}function qt(e){return e>>v<=g&&i.size>=2*a.size?(r=(o=i.filter((function(e,t){return void 0!==e&&s!==t}))).toKeyedSeq().map((function(e){return e[0]})).flip().toMap(),e.__ownerID&&(r.__ownerID=o.__ownerID=e.__ownerID)):(r=a.remove(t),o=s===i.size-1?i.pop():i.set(s,void 0))}else if(u){if(n===i.get(s)[1])return e;r=a,o=i.set(s,[t,n])}else r=a.set(t,i.size),o=i.set(i.size,[t,n]);return e.__ownerID?(e.size=r.size,e._map=r,e._list=o,e.__hash=void 0,e):Wt(r,o)}function Jt(e,t){this._iter=e,this._useKeys=t,this.size=e.size}function Kt(e){this._iter=e,this.size=e.size}function Yt(e){this._iter=e,this.size=e.size}function Gt(e){this._iter=e,this.size=e.size}function Zt(e){var t=bn(e);return t._iter=e,t.size=e.size,t.flip=function(){return e},t.reverse=function(){var t=e.reverse.apply(this);return t.flip=function(){return e.reverse()},t},t.has=function(t){return e.includes(t)},t.includes=function(t){return e.has(t)},t.cacheResult=_n,t.__iterateUncached=function(t,n){var r=this;return e.__iterate((function(e,n){return!1!==t(n,e,r)}),n)},t.__iteratorUncached=function(t,n){if(t===R){var r=e.__iterator(t,n);return new F((function(){var e=r.next();if(!e.done){var t=e.value[0];e.value[0]=e.value[1],e.value[1]=t}return e}))}return e.__iterator(t===M?N:M,n)},t}function Xt(e,t,n){var r=bn(e);return r.size=e.size,r.has=function(t){return e.has(t)},r.get=function(r,o){var a=e.get(r,b);return a===b?o:t.call(n,a,r,e)},r.__iterateUncached=function(r,o){var a=this;return e.__iterate((function(e,o,i){return!1!==r(t.call(n,e,o,i),o,a)}),o)},r.__iteratorUncached=function(r,o){var a=e.__iterator(R,o);return new F((function(){var o=a.next();if(o.done)return o;var i=o.value,s=i[0];return U(r,s,t.call(n,i[1],s,e),o)}))},r}function Qt(e,t){var n=bn(e);return n._iter=e,n.size=e.size,n.reverse=function(){return e},e.flip&&(n.flip=function(){var t=Zt(e);return t.reverse=function(){return e.flip()},t}),n.get=function(n,r){return e.get(t?n:-1-n,r)},n.has=function(n){return e.has(t?n:-1-n)},n.includes=function(t){return e.includes(t)},n.cacheResult=_n,n.__iterate=function(t,n){var r=this;return e.__iterate((function(e,n){return t(e,n,r)}),!n)},n.__iterator=function(t,n){return e.__iterator(t,!n)},n}function en(e,t,n,r){var o=bn(e);return r&&(o.has=function(r){var o=e.get(r,b);return o!==b&&!!t.call(n,o,r,e)},o.get=function(r,o){var a=e.get(r,b);return a!==b&&t.call(n,a,r,e)?a:o}),o.__iterateUncached=function(o,a){var i=this,s=0;return e.__iterate((function(e,a,u){if(t.call(n,e,a,u))return s++,o(e,r?a:s-1,i)}),a),s},o.__iteratorUncached=function(o,a){var i=e.__iterator(R,a),s=0;return new F((function(){for(;;){var a=i.next();if(a.done)return a;var u=a.value,c=u[0],l=u[1];if(t.call(n,l,c,e))return U(o,r?c:s++,l,a)}}))},o}function tn(e,t,n){var r=We().asMutable();return e.__iterate((function(o,a){r.update(t.call(n,o,a,e),0,(function(e){return e+1}))})),r.asImmutable()}function nn(e,t,n){var r=s(e),o=(l(e)?zt():We()).asMutable();e.__iterate((function(a,i){o.update(t.call(n,a,i,e),(function(e){return(e=e||[]).push(r?[i,a]:a),e}))}));var a=yn(e);return o.map((function(t){return mn(e,a(t))}))}function rn(e,t,n,r){var o=e.size;if(void 0!==t&&(t|=0),void 0!==n&&(n===1/0?n=o:n|=0),j(t,n,o))return e;var a=T(t,o),i=I(n,o);if(a!=a||i!=i)return rn(e.toSeq().cacheResult(),t,n,r);var s,u=i-a;u==u&&(s=u<0?0:u);var c=bn(e);return c.size=0===s?s:e.size&&s||void 0,!r&&ae(e)&&s>=0&&(c.get=function(t,n){return(t=O(this,t))>=0&&ts)return q();var e=o.next();return r||t===M?e:U(t,u-1,t===N?void 0:e.value[1],e)}))},c}function on(e,t,n){var r=bn(e);return r.__iterateUncached=function(r,o){var a=this;if(o)return this.cacheResult().__iterate(r,o);var i=0;return e.__iterate((function(e,o,s){return t.call(n,e,o,s)&&++i&&r(e,o,a)})),i},r.__iteratorUncached=function(r,o){var a=this;if(o)return this.cacheResult().__iterator(r,o);var i=e.__iterator(R,o),s=!0;return new F((function(){if(!s)return q();var e=i.next();if(e.done)return e;var o=e.value,u=o[0],c=o[1];return t.call(n,c,u,a)?r===R?e:U(r,u,c,e):(s=!1,q())}))},r}function an(e,t,n,r){var o=bn(e);return o.__iterateUncached=function(o,a){var i=this;if(a)return this.cacheResult().__iterate(o,a);var s=!0,u=0;return e.__iterate((function(e,a,c){if(!s||!(s=t.call(n,e,a,c)))return u++,o(e,r?a:u-1,i)})),u},o.__iteratorUncached=function(o,a){var i=this;if(a)return this.cacheResult().__iterator(o,a);var s=e.__iterator(R,a),u=!0,c=0;return new F((function(){var e,a,l;do{if((e=s.next()).done)return r||o===M?e:U(o,c++,o===N?void 0:e.value[1],e);var p=e.value;a=p[0],l=p[1],u&&(u=t.call(n,l,a,i))}while(u);return o===R?e:U(o,a,l,e)}))},o}function sn(e,t){var n=s(e),o=[e].concat(t).map((function(e){return i(e)?n&&(e=r(e)):e=n?se(e):ue(Array.isArray(e)?e:[e]),e})).filter((function(e){return 0!==e.size}));if(0===o.length)return e;if(1===o.length){var a=o[0];if(a===e||n&&s(a)||u(e)&&u(a))return a}var c=new te(o);return n?c=c.toKeyedSeq():u(e)||(c=c.toSetSeq()),(c=c.flatten(!0)).size=o.reduce((function(e,t){if(void 0!==e){var n=t.size;if(void 0!==n)return e+n}}),0),c}function un(e,t,n){var r=bn(e);return r.__iterateUncached=function(r,o){var a=0,s=!1;function u(e,c){var l=this;e.__iterate((function(e,o){return(!t||c0}function dn(e,t,r){var o=bn(e);return o.size=new te(r).map((function(e){return e.size})).min(),o.__iterate=function(e,t){for(var n,r=this.__iterator(M,t),o=0;!(n=r.next()).done&&!1!==e(n.value,o++,this););return o},o.__iteratorUncached=function(e,o){var a=r.map((function(e){return e=n(e),W(o?e.reverse():e)})),i=0,s=!1;return new F((function(){var n;return s||(n=a.map((function(e){return e.next()})),s=n.some((function(e){return e.done}))),s?q():U(e,i++,t.apply(null,n.map((function(e){return e.value}))))}))},o}function mn(e,t){return ae(e)?t:e.constructor(t)}function vn(e){if(e!==Object(e))throw new TypeError("Expected [K, V] tuple: "+e)}function gn(e){return Ve(e.size),A(e)}function yn(e){return s(e)?r:u(e)?o:a}function bn(e){return Object.create((s(e)?K:u(e)?Y:G).prototype)}function _n(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):J.prototype.cacheResult.call(this)}function xn(e,t){return e>t?1:e=0;n--)t={value:arguments[n],next:t};return this.__ownerID?(this.size=e,this._head=t,this.__hash=void 0,this.__altered=!0,this):Kn(e,t)},Vn.prototype.pushAll=function(e){if(0===(e=o(e)).size)return this;Ve(e.size);var t=this.size,n=this._head;return e.reverse().forEach((function(e){t++,n={value:e,next:n}})),this.__ownerID?(this.size=t,this._head=n,this.__hash=void 0,this.__altered=!0,this):Kn(t,n)},Vn.prototype.pop=function(){return this.slice(1)},Vn.prototype.unshift=function(){return this.push.apply(this,arguments)},Vn.prototype.unshiftAll=function(e){return this.pushAll(e)},Vn.prototype.shift=function(){return this.pop.apply(this,arguments)},Vn.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Yn()},Vn.prototype.slice=function(e,t){if(j(e,t,this.size))return this;var n=T(e,this.size);if(I(t,this.size)!==this.size)return Se.prototype.slice.call(this,e,t);for(var r=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=r,this._head=o,this.__hash=void 0,this.__altered=!0,this):Kn(r,o)},Vn.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?Kn(this.size,this._head,e,this.__hash):(this.__ownerID=e,this.__altered=!1,this)},Vn.prototype.__iterate=function(e,t){if(t)return this.reverse().__iterate(e);for(var n=0,r=this._head;r&&!1!==e(r.value,n++,this);)r=r.next;return n},Vn.prototype.__iterator=function(e,t){if(t)return this.reverse().__iterator(e);var n=0,r=this._head;return new F((function(){if(r){var t=r.value;return r=r.next,U(e,n++,t)}return q()}))},Vn.isStack=Wn;var Hn,$n="@@__IMMUTABLE_STACK__@@",Jn=Vn.prototype;function Kn(e,t,n,r){var o=Object.create(Jn);return o.size=e,o._head=t,o.__ownerID=n,o.__hash=r,o.__altered=!1,o}function Yn(){return Hn||(Hn=Kn(0))}function Gn(e,t){var n=function(n){e.prototype[n]=t[n]};return Object.keys(t).forEach(n),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach(n),e}Jn[$n]=!0,Jn.withMutations=Ke.withMutations,Jn.asMutable=Ke.asMutable,Jn.asImmutable=Ke.asImmutable,Jn.wasAltered=Ke.wasAltered,n.Iterator=F,Gn(n,{toArray:function(){Ve(this.size);var e=new Array(this.size||0);return this.valueSeq().__iterate((function(t,n){e[n]=t})),e},toIndexedSeq:function(){return new Kt(this)},toJS:function(){return this.toSeq().map((function(e){return e&&"function"==typeof e.toJS?e.toJS():e})).__toJS()},toJSON:function(){return this.toSeq().map((function(e){return e&&"function"==typeof e.toJSON?e.toJSON():e})).__toJS()},toKeyedSeq:function(){return new Jt(this,!0)},toMap:function(){return We(this.toKeyedSeq())},toObject:function(){Ve(this.size);var e={};return this.__iterate((function(t,n){e[n]=t})),e},toOrderedMap:function(){return zt(this.toKeyedSeq())},toOrderedSet:function(){return Ln(s(this)?this.valueSeq():this)},toSet:function(){return jn(s(this)?this.valueSeq():this)},toSetSeq:function(){return new Yt(this)},toSeq:function(){return u(this)?this.toIndexedSeq():s(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Vn(s(this)?this.valueSeq():this)},toList:function(){return St(s(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(e,t){return 0===this.size?e+t:e+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+t},concat:function(){return mn(this,sn(this,e.call(arguments,0)))},includes:function(e){return this.some((function(t){return ge(t,e)}))},entries:function(){return this.__iterator(R)},every:function(e,t){Ve(this.size);var n=!0;return this.__iterate((function(r,o,a){if(!e.call(t,r,o,a))return n=!1,!1})),n},filter:function(e,t){return mn(this,en(this,e,t,!0))},find:function(e,t,n){var r=this.findEntry(e,t);return r?r[1]:n},forEach:function(e,t){return Ve(this.size),this.__iterate(t?e.bind(t):e)},join:function(e){Ve(this.size),e=void 0!==e?""+e:",";var t="",n=!0;return this.__iterate((function(r){n?n=!1:t+=e,t+=null!=r?r.toString():""})),t},keys:function(){return this.__iterator(N)},map:function(e,t){return mn(this,Xt(this,e,t))},reduce:function(e,t,n){var r,o;return Ve(this.size),arguments.length<2?o=!0:r=t,this.__iterate((function(t,a,i){o?(o=!1,r=t):r=e.call(n,r,t,a,i)})),r},reduceRight:function(e,t,n){var r=this.toKeyedSeq().reverse();return r.reduce.apply(r,arguments)},reverse:function(){return mn(this,Qt(this,!0))},slice:function(e,t){return mn(this,rn(this,e,t,!0))},some:function(e,t){return!this.every(tr(e),t)},sort:function(e){return mn(this,pn(this,e))},values:function(){return this.__iterator(M)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return void 0!==this.size?0===this.size:!this.some((function(){return!0}))},count:function(e,t){return A(e?this.toSeq().filter(e,t):this)},countBy:function(e,t){return tn(this,e,t)},equals:function(e){return ye(this,e)},entrySeq:function(){var e=this;if(e._cache)return new te(e._cache);var t=e.toSeq().map(er).toIndexedSeq();return t.fromEntrySeq=function(){return e.toSeq()},t},filterNot:function(e,t){return this.filter(tr(e),t)},findEntry:function(e,t,n){var r=n;return this.__iterate((function(n,o,a){if(e.call(t,n,o,a))return r=[o,n],!1})),r},findKey:function(e,t){var n=this.findEntry(e,t);return n&&n[0]},findLast:function(e,t,n){return this.toKeyedSeq().reverse().find(e,t,n)},findLastEntry:function(e,t,n){return this.toKeyedSeq().reverse().findEntry(e,t,n)},findLastKey:function(e,t){return this.toKeyedSeq().reverse().findKey(e,t)},first:function(){return this.find(k)},flatMap:function(e,t){return mn(this,cn(this,e,t))},flatten:function(e){return mn(this,un(this,e,!0))},fromEntrySeq:function(){return new Gt(this)},get:function(e,t){return this.find((function(t,n){return ge(n,e)}),void 0,t)},getIn:function(e,t){for(var n,r=this,o=wn(e);!(n=o.next()).done;){var a=n.value;if((r=r&&r.get?r.get(a,b):b)===b)return t}return r},groupBy:function(e,t){return nn(this,e,t)},has:function(e){return this.get(e,b)!==b},hasIn:function(e){return this.getIn(e,b)!==b},isSubset:function(e){return e="function"==typeof e.includes?e:n(e),this.every((function(t){return e.includes(t)}))},isSuperset:function(e){return(e="function"==typeof e.isSubset?e:n(e)).isSubset(this)},keyOf:function(e){return this.findKey((function(t){return ge(t,e)}))},keySeq:function(){return this.toSeq().map(Qn).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(e){return this.toKeyedSeq().reverse().keyOf(e)},max:function(e){return fn(this,e)},maxBy:function(e,t){return fn(this,t,e)},min:function(e){return fn(this,e?nr(e):ar)},minBy:function(e,t){return fn(this,t?nr(t):ar,e)},rest:function(){return this.slice(1)},skip:function(e){return this.slice(Math.max(0,e))},skipLast:function(e){return mn(this,this.toSeq().reverse().skip(e).reverse())},skipWhile:function(e,t){return mn(this,an(this,e,t,!0))},skipUntil:function(e,t){return this.skipWhile(tr(e),t)},sortBy:function(e,t){return mn(this,pn(this,t,e))},take:function(e){return this.slice(0,Math.max(0,e))},takeLast:function(e){return mn(this,this.toSeq().reverse().take(e).reverse())},takeWhile:function(e,t){return mn(this,on(this,e,t))},takeUntil:function(e,t){return this.takeWhile(tr(e),t)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=ir(this))}});var Zn=n.prototype;Zn[p]=!0,Zn[B]=Zn.values,Zn.__toJS=Zn.toArray,Zn.__toStringMapper=rr,Zn.inspect=Zn.toSource=function(){return this.toString()},Zn.chain=Zn.flatMap,Zn.contains=Zn.includes,Gn(r,{flip:function(){return mn(this,Zt(this))},mapEntries:function(e,t){var n=this,r=0;return mn(this,this.toSeq().map((function(o,a){return e.call(t,[a,o],r++,n)})).fromEntrySeq())},mapKeys:function(e,t){var n=this;return mn(this,this.toSeq().flip().map((function(r,o){return e.call(t,r,o,n)})).flip())}});var Xn=r.prototype;function Qn(e,t){return t}function er(e,t){return[t,e]}function tr(e){return function(){return!e.apply(this,arguments)}}function nr(e){return function(){return-e.apply(this,arguments)}}function rr(e){return"string"==typeof e?JSON.stringify(e):String(e)}function or(){return C(arguments)}function ar(e,t){return et?-1:0}function ir(e){if(e.size===1/0)return 0;var t=l(e),n=s(e),r=t?1:0;return sr(e.__iterate(n?t?function(e,t){r=31*r+ur(ke(e),ke(t))|0}:function(e,t){r=r+ur(ke(e),ke(t))|0}:t?function(e){r=31*r+ke(e)|0}:function(e){r=r+ke(e)|0}),r)}function sr(e,t){return t=Ae(t,3432918353),t=Ae(t<<15|t>>>-15,461845907),t=Ae(t<<13|t>>>-13,5),t=Ae((t=(t+3864292196|0)^e)^t>>>16,2246822507),t=Oe((t=Ae(t^t>>>13,3266489909))^t>>>16)}function ur(e,t){return e^t+2654435769+(e<<6)+(e>>2)|0}return Xn[f]=!0,Xn[B]=Zn.entries,Xn.__toJS=Zn.toObject,Xn.__toStringMapper=function(e,t){return JSON.stringify(t)+": "+rr(e)},Gn(o,{toKeyedSeq:function(){return new Jt(this,!1)},filter:function(e,t){return mn(this,en(this,e,t,!1))},findIndex:function(e,t){var n=this.findEntry(e,t);return n?n[0]:-1},indexOf:function(e){var t=this.keyOf(e);return void 0===t?-1:t},lastIndexOf:function(e){var t=this.lastKeyOf(e);return void 0===t?-1:t},reverse:function(){return mn(this,Qt(this,!1))},slice:function(e,t){return mn(this,rn(this,e,t,!1))},splice:function(e,t){var n=arguments.length;if(t=Math.max(0|t,0),0===n||2===n&&!t)return this;e=T(e,e<0?this.count():this.size);var r=this.slice(0,e);return mn(this,1===n?r:r.concat(C(arguments,2),this.slice(e+t)))},findLastIndex:function(e,t){var n=this.findLastEntry(e,t);return n?n[0]:-1},first:function(){return this.get(0)},flatten:function(e){return mn(this,un(this,e,!1))},get:function(e,t){return(e=O(this,e))<0||this.size===1/0||void 0!==this.size&&e>this.size?t:this.find((function(t,n){return n===e}),void 0,t)},has:function(e){return(e=O(this,e))>=0&&(void 0!==this.size?this.size===1/0||e1)try{return decodeURIComponent(t[1])}catch(e){console.error(e)}return null}function Ne(e){return t=e.replace(/\.[^./]*$/,""),Y()(J()(t));var t}function Me(e,t,n,r,a){if(!t)return[];var s=[],u=t.get("nullable"),c=t.get("required"),p=t.get("maximum"),h=t.get("minimum"),d=t.get("type"),m=t.get("format"),g=t.get("maxLength"),b=t.get("minLength"),x=t.get("uniqueItems"),w=t.get("maxItems"),E=t.get("minItems"),S=t.get("pattern"),C=n||!0===c,A=null!=e;if(u&&null===e||!d||!(C||A&&"array"===d||!(!C&&!A)))return[];var O="string"===d&&e,k="array"===d&&l()(e)&&e.length,j="array"===d&&W.a.List.isList(e)&&e.count(),T=[O,k,j,"array"===d&&"string"==typeof e&&e,"file"===d&&e instanceof se.a.File,"boolean"===d&&(e||!1===e),"number"===d&&(e||0===e),"integer"===d&&(e||0===e),"object"===d&&"object"===i()(e)&&null!==e,"object"===d&&"string"==typeof e&&e],I=P()(T).call(T,(function(e){return!!e}));if(C&&!I&&!r)return s.push("Required field is not provided"),s;if("object"===d&&(null===a||"application/json"===a)){var N,M=e;if("string"==typeof e)try{M=JSON.parse(e)}catch(e){return s.push("Parameter string value must be valid JSON"),s}if(t&&t.has("required")&&Se(c.isList)&&c.isList()&&y()(c).call(c,(function(e){void 0===M[e]&&s.push({propKey:e,error:"Required property not found"})})),t&&t.has("properties"))y()(N=t.get("properties")).call(N,(function(e,t){var n=Me(M[t],e,!1,r,a);s.push.apply(s,o()(f()(n).call(n,(function(e){return{propKey:t,error:e}}))))}))}if(S){var R=function(e,t){if(!new RegExp(t).test(e))return"Value must follow pattern "+t}(e,S);R&&s.push(R)}if(E&&"array"===d){var D=function(e,t){var n;if(!e&&t>=1||e&&e.lengtht)return v()(n="Array must not contain more then ".concat(t," item")).call(n,1===t?"":"s")}(e,w);L&&s.push({needRemove:!0,error:L})}if(x&&"array"===d){var B=function(e,t){if(e&&("true"===t||!0===t)){var n=Object(V.fromJS)(e),r=n.toSet();if(e.length>r.size){var o=Object(V.Set)();if(y()(n).call(n,(function(e,t){_()(n).call(n,(function(t){return Se(t.equals)?t.equals(e):t===e})).size>1&&(o=o.add(t))})),0!==o.size)return f()(o).call(o,(function(e){return{index:e,error:"No duplicates allowed."}})).toArray()}}}(e,x);B&&s.push.apply(s,o()(B))}if(g||0===g){var F=function(e,t){var n;if(e.length>t)return v()(n="Value must be no longer than ".concat(t," character")).call(n,1!==t?"s":"")}(e,g);F&&s.push(F)}if(b){var U=function(e,t){var n;if(e.lengtht)return"Value must be less than ".concat(t)}(e,p);q&&s.push(q)}if(h||0===h){var z=function(e,t){if(e2&&void 0!==arguments[2]?arguments[2]:{},r=n.isOAS3,o=void 0!==r&&r,a=n.bypassRequiredCheck,i=void 0!==a&&a,s=e.get("required"),u=Object(le.a)(e,{isOAS3:o}),c=u.schema,l=u.parameterContentMediaType;return Me(t,c,s,i,l)},De=function(e,t,n){if(e&&(!e.xml||!e.xml.name)){if(e.xml=e.xml||{},!e.$$ref)return e.type||e.items||e.properties||e.additionalProperties?'\n\x3c!-- XML example cannot be generated; root element name is undefined --\x3e':null;var r=e.$$ref.match(/\S*\/(\S+)$/);e.xml.name=r[1]}return Object(ie.memoizedCreateXMLExample)(e,t,n)},Le=[{when:/json/,shouldStringifyTypes:["string"]}],Be=["object"],Fe=function(e,t,n,r){var a=Object(ie.memoizedSampleFromSchema)(e,t,r),s=i()(a),u=S()(Le).call(Le,(function(e,t){var r;return t.when.test(n)?v()(r=[]).call(r,o()(e),o()(t.shouldStringifyTypes)):e}),Be);return te()(u,(function(e){return e===s}))?M()(a,null,2):a},Ue=function(e,t,n,r){var o,a=Fe(e,t,n,r);try{"\n"===(o=ve.a.safeDump(ve.a.safeLoad(a),{lineWidth:-1}))[o.length-1]&&(o=T()(o).call(o,0,o.length-1))}catch(e){return console.error(e),"error: could not generate yaml example"}return o.replace(/\t/g," ")},qe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0;return e&&Se(e.toJS)&&(e=e.toJS()),r&&Se(r.toJS)&&(r=r.toJS()),/xml/.test(t)?De(e,n,r):/(yaml|yml)/.test(t)?Ue(e,n,t,r):Fe(e,n,t,r)},ze=function(){var e={},t=se.a.location.search;if(!t)return{};if(""!=t){var n=t.substr(1).split("&");for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(r=n[r].split("="),e[decodeURIComponent(r[0])]=r[1]&&decodeURIComponent(r[1])||"")}return e},Ve=function(t){return(t instanceof e?t:e.from(t.toString(),"utf-8")).toString("base64")},We={operationsSorter:{alpha:function(e,t){return e.get("path").localeCompare(t.get("path"))},method:function(e,t){return e.get("method").localeCompare(t.get("method"))}},tagsSorter:{alpha:function(e,t){return e.localeCompare(t)}}},He=function(e){var t=[];for(var n in e){var r=e[n];void 0!==r&&""!==r&&t.push([n,"=",encodeURIComponent(r).replace(/%20/g,"+")].join(""))}return t.join("&")},$e=function(e,t,n){return!!Q()(n,(function(n){return re()(e[n],t[n])}))};function Je(e){return"string"!=typeof e||""===e?"":Object(H.sanitizeUrl)(e)}function Ke(e){return!(!e||D()(e).call(e,"localhost")>=0||D()(e).call(e,"127.0.0.1")>=0||"none"===e)}function Ye(e){if(!W.a.OrderedMap.isOrderedMap(e))return null;if(!e.size)return null;var t=B()(e).call(e,(function(e,t){return U()(t).call(t,"2")&&w()(e.get("content")||{}).length>0})),n=e.get("default")||W.a.OrderedMap(),r=(n.get("content")||W.a.OrderedMap()).keySeq().toJS().length?n:null;return t||r}var Ge=function(e){return"string"==typeof e||e instanceof String?z()(e).call(e).replace(/\s/g,"%20"):""},Ze=function(e){return ce()(Ge(e).replace(/%20/g,"_"))},Xe=function(e){return _()(e).call(e,(function(e,t){return/^x-/.test(t)}))},Qe=function(e){return _()(e).call(e,(function(e,t){return/^pattern|maxLength|minLength|maximum|minimum/.test(t)}))};function et(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return!0};if("object"!==i()(e)||l()(e)||null===e||!t)return e;var o=A()({},e);return y()(n=w()(o)).call(n,(function(e){e===t&&r(o[e],e)?delete o[e]:o[e]=et(o[e],t,r)})),o}function tt(e){if("string"==typeof e)return e;if(e&&e.toJS&&(e=e.toJS()),"object"===i()(e)&&null!==e)try{return M()(e,null,2)}catch(t){return String(e)}return null==e?"":e.toString()}function nt(e){return"number"==typeof e?e.toString():e}function rt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.returnAll,r=void 0!==n&&n,o=t.allowHashes,a=void 0===o||o;if(!W.a.Map.isMap(e))throw new Error("paramToIdentifier: received a non-Im.Map parameter as input");var i,s,u,c=e.get("name"),l=e.get("in"),p=[];e&&e.hashCode&&l&&c&&a&&p.push(v()(i=v()(s="".concat(l,".")).call(s,c,".hash-")).call(i,e.hashCode()));l&&c&&p.push(v()(u="".concat(l,".")).call(u,c));return p.push(c),r?p:p[0]||""}function ot(e,t){var n,r=rt(e,{returnAll:!0});return _()(n=f()(r).call(r,(function(e){return t[e]}))).call(n,(function(e){return void 0!==e}))[0]}function at(){return st(fe()(32).toString("base64"))}function it(e){return st(de()("sha256").update(e).digest("base64"))}function st(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var ut=function(e){return!e||!(!ye(e)||!e.isEmpty())}}).call(this,n(65).Buffer)},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(247);function o(e,t){for(var n=0;n1?t-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:r,n=null,a=null;return function(){return o(t,n,arguments)||(a=e.apply(null,arguments)),n=arguments,a}}))},function(e,t,n){e.exports=n(674)},function(e,t,n){var r=n(181),o=n(582);function a(t){return"function"==typeof r&&"symbol"==typeof o?(e.exports=a=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=a=function(e){return e&&"function"==typeof r&&e.constructor===r&&e!==r.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),a(t)}e.exports=a,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){e.exports=n(608)},function(e,t,n){e.exports=n(606)},function(e,t,n){"use strict";var r=n(40),o=n(107).f,a=n(369),i=n(33),s=n(110),u=n(70),c=n(54),l=function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t.prototype=e.prototype,t};e.exports=function(e,t){var n,p,f,h,d,m,v,g,y=e.target,b=e.global,_=e.stat,x=e.proto,w=b?r:_?r[y]:(r[y]||{}).prototype,E=b?i:i[y]||(i[y]={}),S=E.prototype;for(f in t)n=!a(b?f:y+(_?".":"#")+f,e.forced)&&w&&c(w,f),d=E[f],n&&(m=e.noTargetGet?(g=o(w,f))&&g.value:w[f]),h=n&&m?m:t[f],n&&typeof d==typeof h||(v=e.bind&&n?s(h,r):e.wrap&&n?l(h):x&&"function"==typeof h?s(Function.call,h):h,(e.sham||h&&h.sham||d&&d.sham)&&u(v,"sham",!0),E[f]=v,x&&(c(i,p=y+"Prototype")||u(i,p,{}),i[p][f]=h,e.real&&S&&!S[f]&&u(S,f,h)))}},function(e,t,n){e.exports=n(611)},function(e,t,n){e.exports=n(408)},function(e,t,n){var r=n(457),o=n(458),a=n(881),i=n(459),s=n(886),u=n(888),c=n(893),l=n(247),p=n(3);function f(e,t){var n=r(e);if(o){var s=o(e);t&&(s=a(s).call(s,(function(t){return i(e,t).enumerable}))),n.push.apply(n,s)}return n}e.exports=function(e){for(var t=1;t>",i=function(){invariant(!1,"ImmutablePropTypes type checking code is stripped in production.")};i.isRequired=i;var s=function(){return i};function u(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":e instanceof o.Iterable?"Immutable."+e.toSource().split(" ")[0]:t}function c(e){function t(t,n,r,o,i,s){for(var u=arguments.length,c=Array(u>6?u-6:0),l=6;l4)}function l(e){var t=e.get("swagger");return"string"==typeof t&&i()(t).call(t,"2.0")}function p(e){return function(t,n){return function(r){return n&&n.specSelectors&&n.specSelectors.specJson?c(n.specSelectors.specJson())?u.a.createElement(e,o()({},r,n,{Ori:t})):u.a.createElement(t,r):(console.warn("OAS3 wrapper: couldn't get spec"),null)}}}},function(e,t,n){e.exports=n(602)},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){"use strict";var r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function i(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,s,u=i(e),c=1;c0){var o=v()(n).call(n,(function(e){return console.error(e),e.line=e.fullPath?_(x,e.fullPath):null,e.path=e.fullPath?e.fullPath.join("."):null,e.level="error",e.type="thrown",e.source="resolver",y()(e,"message",{enumerable:!0,value:e.message}),e}));a.newThrownErrBatch(o)}return r.updateResolved(t)}))}},Se=[],Ce=G()(u()(f.a.mark((function e(){var t,n,r,o,a,i,s,c,l,p,h,m,g,b,x,E,C,O;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Se.system){e.next=4;break}return console.error("debResolveSubtrees: don't have a system to operate on, aborting."),e.abrupt("return");case 4:if(n=t.errActions,r=t.errSelectors,o=t.fn,a=o.resolveSubtree,i=o.fetch,s=o.AST,c=void 0===s?{}:s,l=t.specSelectors,p=t.specActions,a){e.next=8;break}return console.error("Error: Swagger-Client did not provide a `resolveSubtree` method, doing nothing."),e.abrupt("return");case 8:return h=c.getLineNumberForPath?c.getLineNumberForPath:function(){},m=l.specStr(),g=t.getConfigs(),b=g.modelPropertyMacro,x=g.parameterMacro,E=g.requestInterceptor,C=g.responseInterceptor,e.prev=11,e.next=14,_()(Se).call(Se,function(){var e=u()(f.a.mark((function e(t,o){var s,c,p,g,_,O,j,T,I;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t;case 2:return s=e.sent,c=s.resultMap,p=s.specWithCurrentSubtrees,e.next=7,a(p,o,{baseDoc:l.url(),modelPropertyMacro:b,parameterMacro:x,requestInterceptor:E,responseInterceptor:C});case 7:if(g=e.sent,_=g.errors,O=g.spec,r.allErrors().size&&n.clearBy((function(e){var t;return"thrown"!==e.get("type")||"resolver"!==e.get("source")||!w()(t=e.get("fullPath")).call(t,(function(e,t){return e===o[t]||void 0===o[t]}))})),d()(_)&&_.length>0&&(j=v()(_).call(_,(function(e){return e.line=e.fullPath?h(m,e.fullPath):null,e.path=e.fullPath?e.fullPath.join("."):null,e.level="error",e.type="thrown",e.source="resolver",y()(e,"message",{enumerable:!0,value:e.message}),e})),n.newThrownErrBatch(j)),!O||!l.isOAS3()||"components"!==o[0]||"securitySchemes"!==o[1]){e.next=15;break}return e.next=15,S.a.all(v()(T=A()(I=k()(O)).call(I,(function(e){return"openIdConnect"===e.type}))).call(T,function(){var e=u()(f.a.mark((function e(t){var n,r;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={url:t.openIdConnectUrl,requestInterceptor:E,responseInterceptor:C},e.prev=1,e.next=4,i(n);case 4:(r=e.sent)instanceof Error||r.status>=400?console.error(r.statusText+" "+n.url):t.openIdConnectData=JSON.parse(r.text),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}()));case 15:return X()(c,o,O),X()(p,o,O),e.abrupt("return",{resultMap:c,specWithCurrentSubtrees:p});case 18:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),S.a.resolve({resultMap:(l.specResolvedSubtree([])||Object(V.Map)()).toJS(),specWithCurrentSubtrees:l.specJson().toJS()}));case 14:O=e.sent,delete Se.system,Se=[],e.next=22;break;case 19:e.prev=19,e.t0=e.catch(11),console.error(e.t0);case 22:p.updateResolvedSubtree([],O.resultMap);case 23:case"end":return e.stop()}}),e,null,[[11,19]])}))),35),Ae=function(e){return function(t){var n;T()(n=v()(Se).call(Se,(function(e){return e.join("@@")}))).call(n,e.join("@@"))>-1||(Se.push(e),Se.system=t,Ce())}};function Oe(e,t,n,r,o){return{type:re,payload:{path:e,value:r,paramName:t,paramIn:n,isXml:o}}}function ke(e,t,n,r){return{type:re,payload:{path:e,param:t,value:n,isXml:r}}}var je=function(e,t){return{type:me,payload:{path:e,value:t}}},Te=function(){return{type:me,payload:{path:[],value:Object(V.Map)()}}},Ie=function(e,t){return{type:ae,payload:{pathMethod:e,isOAS3:t}}},Pe=function(e,t,n,r){return{type:oe,payload:{pathMethod:e,paramName:t,paramIn:n,includeEmptyValue:r}}};function Ne(e){return{type:fe,payload:{pathMethod:e}}}function Me(e,t){return{type:he,payload:{path:e,value:t,key:"consumes_value"}}}function Re(e,t){return{type:he,payload:{path:e,value:t,key:"produces_value"}}}var De=function(e,t,n){return{payload:{path:e,method:t,res:n},type:ie}},Le=function(e,t,n){return{payload:{path:e,method:t,req:n},type:se}},Be=function(e,t,n){return{payload:{path:e,method:t,req:n},type:ue}},Fe=function(e){return{payload:e,type:ce}},Ue=function(e){return function(t){var n,r,o=t.fn,a=t.specActions,i=t.specSelectors,s=t.getConfigs,c=t.oas3Selectors,l=e.pathName,p=e.method,h=e.operation,m=s(),g=m.requestInterceptor,y=m.responseInterceptor,b=h.toJS();h&&h.get("parameters")&&P()(n=A()(r=h.get("parameters")).call(r,(function(e){return e&&!0===e.get("allowEmptyValue")}))).call(n,(function(t){if(i.parameterInclusionSettingFor([l,p],t.get("name"),t.get("in"))){e.parameters=e.parameters||{};var n=Object(Q.B)(t,e.parameters);(!n||n&&0===n.size)&&(e.parameters[t.get("name")]="")}}));if(e.contextUrl=H()(i.url()).toString(),b&&b.operationId?e.operationId=b.operationId:b&&l&&p&&(e.operationId=o.opId(b,l,p)),i.isOAS3()){var _,x=M()(_="".concat(l,":")).call(_,p);e.server=c.selectedServer(x)||c.selectedServer();var w=c.serverVariables({server:e.server,namespace:x}).toJS(),E=c.serverVariables({server:e.server}).toJS();e.serverVariables=D()(w).length?w:E,e.requestContentType=c.requestContentType(l,p),e.responseContentType=c.responseContentType(l,p)||"*/*";var S,C=c.requestBodyValue(l,p),O=c.requestBodyInclusionSetting(l,p);if(C&&C.toJS)e.requestBody=A()(S=v()(C).call(C,(function(e){return V.Map.isMap(e)?e.get("value"):e}))).call(S,(function(e,t){return(d()(e)?0!==e.length:!Object(Q.q)(e))||O.get(t)})).toJS();else e.requestBody=C}var k=B()({},e);k=o.buildRequest(k),a.setRequest(e.pathName,e.method,k);var j=function(){var t=u()(f.a.mark((function t(n){var r,o;return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,g.apply(undefined,[n]);case 2:return r=t.sent,o=B()({},r),a.setMutatedRequest(e.pathName,e.method,o),t.abrupt("return",r);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();e.requestInterceptor=j,e.responseInterceptor=y;var T=U()();return o.execute(e).then((function(t){t.duration=U()()-T,a.setResponse(e.pathName,e.method,t)})).catch((function(t){"Failed to fetch"===t.message&&(t.name="",t.message='**Failed to fetch.** \n**Possible Reasons:** \n - CORS \n - Network Failure \n - URL scheme must be "http" or "https" for CORS request.'),a.setResponse(e.pathName,e.method,{error:!0,err:Object($.serializeError)(t)})}))}},qe=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.path,n=e.method,r=i()(e,["path","method"]);return function(e){var a=e.fn.fetch,i=e.specSelectors,s=e.specActions,u=i.specJsonWithResolvedSubtrees().toJS(),c=i.operationScheme(t,n),l=i.contentTypeValues([t,n]).toJS(),p=l.requestContentType,f=l.responseContentType,h=/xml/i.test(p),d=i.parameterValues([t,n],h).toJS();return s.executeRequest(o()(o()({},r),{},{fetch:a,spec:u,pathName:t,method:n,parameters:d,requestContentType:p,scheme:c,responseContentType:f}))}};function ze(e,t){return{type:le,payload:{path:e,method:t}}}function Ve(e,t){return{type:pe,payload:{path:e,method:t}}}function We(e,t,n){return{type:ve,payload:{scheme:e,path:t,method:n}}}},function(e,t,n){var r=n(33),o=n(54),a=n(243),i=n(71).f;e.exports=function(e){var t=r.Symbol||(r.Symbol={});o(t,e)||i(t,e,{value:a.f(e)})}},function(e,t,n){"use strict";var r=n(167),o=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],a=["scalar","sequence","mapping"];e.exports=function(e,t){var n,i;if(t=t||{},Object.keys(t).forEach((function(t){if(-1===o.indexOf(t))throw new r('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.defaultStyle=t.defaultStyle||null,this.styleAliases=(n=t.styleAliases||null,i={},null!==n&&Object.keys(n).forEach((function(e){n[e].forEach((function(t){i[String(t)]=e}))})),i),-1===a.indexOf(this.kind))throw new r('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}},function(e,t,n){var r=n(37);e.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},function(e,t,n){var r=n(181),o=n(250),a=n(249),i=n(190);e.exports=function(e,t){var n=void 0!==r&&o(e)||e["@@iterator"];if(!n){if(a(e)||(n=i(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var s=0,u=function(){};return{s:u,n:function(){return s>=e.length?{done:!0}:{done:!1,value:e[s++]}},e:function(e){throw e},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,l=!0,p=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){p=!0,c=e},f:function(){try{l||null==n.return||n.return()}finally{if(p)throw c}}}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(45);e.exports=function(e){if(!r(e))throw TypeError(String(e)+" is not an object");return e}},function(e,t){var n=Array.isArray;e.exports=n},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){var r=n(62),o={}.hasOwnProperty;e.exports=function(e,t){return o.call(r(e),t)}},function(e,t,n){var r=n(458),o=n(460),a=n(898);e.exports=function(e,t){if(null==e)return{};var n,i,s=a(e,t);if(r){var u=r(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){"use strict";n.r(t),n.d(t,"UPDATE_SELECTED_SERVER",(function(){return r})),n.d(t,"UPDATE_REQUEST_BODY_VALUE",(function(){return o})),n.d(t,"UPDATE_REQUEST_BODY_VALUE_RETAIN_FLAG",(function(){return a})),n.d(t,"UPDATE_REQUEST_BODY_INCLUSION",(function(){return i})),n.d(t,"UPDATE_ACTIVE_EXAMPLES_MEMBER",(function(){return s})),n.d(t,"UPDATE_REQUEST_CONTENT_TYPE",(function(){return u})),n.d(t,"UPDATE_RESPONSE_CONTENT_TYPE",(function(){return c})),n.d(t,"UPDATE_SERVER_VARIABLE_VALUE",(function(){return l})),n.d(t,"SET_REQUEST_BODY_VALIDATE_ERROR",(function(){return p})),n.d(t,"CLEAR_REQUEST_BODY_VALIDATE_ERROR",(function(){return f})),n.d(t,"CLEAR_REQUEST_BODY_VALUE",(function(){return h})),n.d(t,"setSelectedServer",(function(){return d})),n.d(t,"setRequestBodyValue",(function(){return m})),n.d(t,"setRetainRequestBodyValueFlag",(function(){return v})),n.d(t,"setRequestBodyInclusion",(function(){return g})),n.d(t,"setActiveExamplesMember",(function(){return y})),n.d(t,"setRequestContentType",(function(){return b})),n.d(t,"setResponseContentType",(function(){return _})),n.d(t,"setServerVariableValue",(function(){return x})),n.d(t,"setRequestBodyValidateError",(function(){return w})),n.d(t,"clearRequestBodyValidateError",(function(){return E})),n.d(t,"initRequestBodyValidateError",(function(){return S})),n.d(t,"clearRequestBodyValue",(function(){return C}));var r="oas3_set_servers",o="oas3_set_request_body_value",a="oas3_set_request_body_retain_flag",i="oas3_set_request_body_inclusion",s="oas3_set_active_examples_member",u="oas3_set_request_content_type",c="oas3_set_response_content_type",l="oas3_set_server_variable_value",p="oas3_set_request_body_validate_error",f="oas3_clear_request_body_validate_error",h="oas3_clear_request_body_value";function d(e,t){return{type:r,payload:{selectedServerUrl:e,namespace:t}}}function m(e){var t=e.value,n=e.pathMethod;return{type:o,payload:{value:t,pathMethod:n}}}var v=function(e){var t=e.value,n=e.pathMethod;return{type:a,payload:{value:t,pathMethod:n}}};function g(e){var t=e.value,n=e.pathMethod,r=e.name;return{type:i,payload:{value:t,pathMethod:n,name:r}}}function y(e){var t=e.name,n=e.pathMethod,r=e.contextType,o=e.contextName;return{type:s,payload:{name:t,pathMethod:n,contextType:r,contextName:o}}}function b(e){var t=e.value,n=e.pathMethod;return{type:u,payload:{value:t,pathMethod:n}}}function _(e){var t=e.value,n=e.path,r=e.method;return{type:c,payload:{value:t,path:n,method:r}}}function x(e){var t=e.server,n=e.namespace,r=e.key,o=e.val;return{type:l,payload:{server:t,namespace:n,key:r,val:o}}}var w=function(e){var t=e.path,n=e.method,r=e.validationErrors;return{type:p,payload:{path:t,method:n,validationErrors:r}}},E=function(e){var t=e.path,n=e.method;return{type:f,payload:{path:t,method:n}}},S=function(e){var t=e.pathMethod;return{type:f,payload:{path:t[0],method:t[1]}}},C=function(e){var t=e.pathMethod;return{type:h,payload:{pathMethod:t}}}},function(e,t,n){"use strict";var r=!("undefined"==typeof window||!window.document||!window.document.createElement),o={canUseDOM:r,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:r&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:r&&!!window.screen,isInWorker:!r};e.exports=o},function(e,t,n){e.exports=n(677)},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,n){"use strict";n.d(t,"b",(function(){return m})),n.d(t,"e",(function(){return v})),n.d(t,"c",(function(){return y})),n.d(t,"a",(function(){return b})),n.d(t,"d",(function(){return _}));var r=n(50),o=n.n(r),a=n(18),i=n.n(a),s=n(2),u=n.n(s),c=n(59),l=n.n(c),p=n(363),f=n.n(p),h=function(e){return String.prototype.toLowerCase.call(e)},d=function(e){return e.replace(/[^\w]/gi,"_")};function m(e){var t=e.openapi;return!!t&&f()(t,"3")}function v(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=r.v2OperationIdCompatibilityMode;if(!e||"object"!==i()(e))return null;var a=(e.operationId||"").replace(/\s/g,"");return a.length?d(e.operationId):g(t,n,{v2OperationIdCompatibilityMode:o})}function g(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.v2OperationIdCompatibilityMode;if(o){var a,i,s=u()(a="".concat(t.toLowerCase(),"_")).call(a,e).replace(/[\s!@#$%^&*()_+=[{\]};:<>|./?,\\'""-]/g,"_");return(s=s||u()(i="".concat(e.substring(1),"_")).call(i,t)).replace(/((_){2,})/g,"_").replace(/^(_)*/g,"").replace(/([_])*$/g,"")}return u()(n="".concat(h(t))).call(n,d(e))}function y(e,t){var n;return u()(n="".concat(h(t),"-")).call(n,e)}function b(e,t){return e&&e.paths?function(e,t){return function(e,t,n){if(!e||"object"!==i()(e)||!e.paths||"object"!==i()(e.paths))return null;var r=e.paths;for(var o in r)for(var a in r[o])if("PARAMETERS"!==a.toUpperCase()){var s=r[o][a];if(s&&"object"===i()(s)){var u={spec:e,pathName:o,method:a.toUpperCase(),operation:s},c=t(u);if(n&&c)return u}}return}(e,t,!0)||null}(e,(function(e){var n=e.pathName,r=e.method,o=e.operation;if(!o||"object"!==i()(o))return!1;var a=o.operationId;return[v(o,n,r),y(n,r),a].some((function(e){return e&&e===t}))})):null}function _(e){var t=e.spec,n=t.paths,r={};if(!n||t.$$normalized)return e;for(var a in n){var i=n[a];if(l()(i)){var s=i.parameters,c=function(e){var n=i[e];if(!l()(n))return"continue";var c=v(n,a,e);if(c){r[c]?r[c].push(n):r[c]=[n];var p=r[c];if(p.length>1)p.forEach((function(e,t){var n;e.__originalOperationId=e.__originalOperationId||e.operationId,e.operationId=u()(n="".concat(c)).call(n,t+1)}));else if(void 0!==n.operationId){var f=p[0];f.__originalOperationId=f.__originalOperationId||n.operationId,f.operationId=c}}if("parameters"!==e){var h=[],d={};for(var m in t)"produces"!==m&&"consumes"!==m&&"security"!==m||(d[m]=t[m],h.push(d));if(s&&(d.parameters=s,h.push(d)),h.length){var g,y=o()(h);try{for(y.s();!(g=y.n()).done;){var b=g.value;for(var _ in b)if(n[_]){if("parameters"===_){var x,w=o()(b[_]);try{var E=function(){var e=x.value;n[_].some((function(t){return t.name&&t.name===e.name||t.$ref&&t.$ref===e.$ref||t.$$ref&&t.$$ref===e.$$ref||t===e}))||n[_].push(e)};for(w.s();!(x=w.n()).done;)E()}catch(e){w.e(e)}finally{w.f()}}}else n[_]=b[_]}}catch(e){y.e(e)}finally{y.f()}}}};for(var p in i)c(p)}}return t.$$normalized=!0,e}},function(e,t,n){"use strict";n.r(t),n.d(t,"NEW_THROWN_ERR",(function(){return o})),n.d(t,"NEW_THROWN_ERR_BATCH",(function(){return a})),n.d(t,"NEW_SPEC_ERR",(function(){return i})),n.d(t,"NEW_SPEC_ERR_BATCH",(function(){return s})),n.d(t,"NEW_AUTH_ERR",(function(){return u})),n.d(t,"CLEAR",(function(){return c})),n.d(t,"CLEAR_BY",(function(){return l})),n.d(t,"newThrownErr",(function(){return p})),n.d(t,"newThrownErrBatch",(function(){return f})),n.d(t,"newSpecErr",(function(){return h})),n.d(t,"newSpecErrBatch",(function(){return d})),n.d(t,"newAuthErr",(function(){return m})),n.d(t,"clear",(function(){return v})),n.d(t,"clearBy",(function(){return g}));var r=n(146),o="err_new_thrown_err",a="err_new_thrown_err_batch",i="err_new_spec_err",s="err_new_spec_err_batch",u="err_new_auth_err",c="err_clear",l="err_clear_by";function p(e){return{type:o,payload:Object(r.serializeError)(e)}}function f(e){return{type:a,payload:e}}function h(e){return{type:i,payload:e}}function d(e){return{type:s,payload:e}}function m(e){return{type:u,payload:e}}function v(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:c,payload:e}}function g(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!0};return{type:l,payload:e}}},function(e,t,n){var r=n(109);e.exports=function(e){return Object(r(e))}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t,n){var r=n(65),o=r.Buffer;function a(e,t){for(var n in e)t[n]=e[n]}function i(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=r:(a(r,t),t.Buffer=i),a(o,i),i.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},i.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t,n){"use strict";(function(e){var r=n(598),o=n(599),a=n(383);function i(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(i()=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(e).length;default:if(r)return q(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return T(this,t,n);case"utf8":case"utf-8":return A(this,t,n);case"ascii":return k(this,t,n);case"latin1":case"binary":return j(this,t,n);case"base64":return C(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function v(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function g(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,o){var a,i=1,s=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;i=2,s/=2,u/=2,n/=2}function c(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(o){var l=-1;for(a=n;as&&(n=s-u),a=n;a>=0;a--){for(var p=!0,f=0;fo&&(r=o):r=o;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var i=0;i>8,o=n%256,a.push(o),a.push(r);return a}(t,e.length-n),e,n,r)}function C(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function A(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o239?4:c>223?3:c>191?2:1;if(o+p<=n)switch(p){case 1:c<128&&(l=c);break;case 2:128==(192&(a=e[o+1]))&&(u=(31&c)<<6|63&a)>127&&(l=u);break;case 3:a=e[o+1],i=e[o+2],128==(192&a)&&128==(192&i)&&(u=(15&c)<<12|(63&a)<<6|63&i)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:a=e[o+1],i=e[o+2],s=e[o+3],128==(192&a)&&128==(192&i)&&128==(192&s)&&(u=(15&c)<<18|(63&a)<<12|(63&i)<<6|63&s)>65535&&u<1114112&&(l=u)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=p}return function(e){var t=e.length;if(t<=O)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},u.prototype.compare=function(e,t,n,r,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var a=(o>>>=0)-(r>>>=0),i=(n>>>=0)-(t>>>=0),s=Math.min(a,i),c=this.slice(r,o),l=e.slice(t,n),p=0;po)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return b(this,e,t,n);case"utf8":case"utf-8":return _(this,e,t,n);case"ascii":return x(this,e,t,n);case"latin1":case"binary":return w(this,e,t,n);case"base64":return E(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var O=4096;function k(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;or)&&(n=r);for(var o="",a=t;an)throw new RangeError("Trying to access beyond buffer length")}function N(e,t,n,r,o,a){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function M(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,a=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function R(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,a=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function D(e,t,n,r,o,a){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,r,a){return a||D(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function B(e,t,n,r,a){return a||D(e,0,n,8),o.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(o*=256);)r+=this[e+--t]*o;return r},u.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],o=1,a=0;++a=(o*=128)&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=t,o=1,a=this[e+--r];r>0&&(o*=256);)a+=this[e+--r]*o;return a>=(o*=128)&&(a-=Math.pow(2,8*t)),a},u.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||N(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+o]=e/a&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):R(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);N(this,e,t,n,o-1,-o)}var a=0,i=1,s=0;for(this[t]=255&e;++a>0)-s&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);N(this,e,t,n,o-1,-o)}var a=n-1,i=1,s=0;for(this[t+a]=255&e;--a>=0&&(i*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/i>>0)-s&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):R(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return B(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return B(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else if(a<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(a=t;a55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(i+1===r){(t-=3)>-1&&a.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&a.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function z(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(this,n(53))},function(e,t,n){var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t0?o(r(e),9007199254740991):0}},function(e,t,n){var r,o,a,i=n(374),s=n(40),u=n(45),c=n(70),l=n(54),p=n(235),f=n(188),h=n(159),d="Object already initialized",m=s.WeakMap;if(i){var v=p.state||(p.state=new m),g=v.get,y=v.has,b=v.set;r=function(e,t){if(y.call(v,e))throw new TypeError(d);return t.facade=e,b.call(v,e,t),t},o=function(e){return g.call(v,e)||{}},a=function(e){return y.call(v,e)}}else{var _=f("state");h[_]=!0,r=function(e,t){if(l(e,_))throw new TypeError(d);return t.facade=e,c(e,_,t),t},o=function(e){return l(e,_)?e[_]:{}},a=function(e){return l(e,_)}}e.exports={set:r,get:o,has:a,enforce:function(e){return a(e)?o(e):r(e,{})},getterFor:function(e){return function(t){var n;if(!u(t)||(n=o(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}}},function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,n){"use strict";var r=n(30),o=n(38),a=n(481),i=n(124),s=n(482),u=n(142),c=n(208),l=n(25),p=[],f=0,h=a.getPooled(),d=!1,m=null;function v(){w.ReactReconcileTransaction&&m||r("123")}var g=[{initialize:function(){this.dirtyComponentsLength=p.length},close:function(){this.dirtyComponentsLength!==p.length?(p.splice(0,this.dirtyComponentsLength),x()):p.length=0}},{initialize:function(){this.callbackQueue.reset()},close:function(){this.callbackQueue.notifyAll()}}];function y(){this.reinitializeTransaction(),this.dirtyComponentsLength=null,this.callbackQueue=a.getPooled(),this.reconcileTransaction=w.ReactReconcileTransaction.getPooled(!0)}function b(e,t){return e._mountOrder-t._mountOrder}function _(e){var t=e.dirtyComponentsLength;t!==p.length&&r("124",t,p.length),p.sort(b),f++;for(var n=0;n",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(c),p=["%","/","?",";","#"].concat(l),f=["/","?","#"],h=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},v={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=n(1107);function b(e,t,n){if(e&&o.isObject(e)&&e instanceof a)return e;var r=new a;return r.parse(e,t,n),r}a.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var a=e.indexOf("?"),s=-1!==a&&a127?N+="x":N+=P[M];if(!N.match(h)){var D=T.slice(0,O),L=T.slice(O+1),B=P.match(d);B&&(D.push(B[1]),L.unshift(B[2])),L.length&&(b="/"+L.join(".")+b),this.hostname=D.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),j||(this.hostname=r.toASCII(this.hostname));var F=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+F,this.href+=this.host,j&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!m[w])for(O=0,I=l.length;O0)&&n.host.split("@"))&&(n.auth=j.shift(),n.host=n.hostname=j.shift());return n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!E.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var C=E.slice(-1)[0],A=(n.host||e.host||E.length>1)&&("."===C||".."===C)||""===C,O=0,k=E.length;k>=0;k--)"."===(C=E[k])?E.splice(k,1):".."===C?(E.splice(k,1),O++):O&&(E.splice(k,1),O--);if(!x&&!w)for(;O--;O)E.unshift("..");!x||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),A&&"/"!==E.join("/").substr(-1)&&E.push("");var j,T=""===E[0]||E[0]&&"/"===E[0].charAt(0);S&&(n.hostname=n.host=T?"":E.length?E.shift():"",(j=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=j.shift(),n.host=n.hostname=j.shift()));return(x=x||n.host&&E.length)&&!T&&E.unshift(""),E.length?n.pathname=E.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},a.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,n){"use strict";n.r(t),n.d(t,"SHOW_AUTH_POPUP",(function(){return h})),n.d(t,"AUTHORIZE",(function(){return d})),n.d(t,"LOGOUT",(function(){return m})),n.d(t,"PRE_AUTHORIZE_OAUTH2",(function(){return v})),n.d(t,"AUTHORIZE_OAUTH2",(function(){return g})),n.d(t,"VALIDATE",(function(){return y})),n.d(t,"CONFIGURE_AUTH",(function(){return b})),n.d(t,"RESTORE_AUTHORIZATION",(function(){return _})),n.d(t,"showDefinitions",(function(){return x})),n.d(t,"authorize",(function(){return w})),n.d(t,"authorizeWithPersistOption",(function(){return E})),n.d(t,"logout",(function(){return S})),n.d(t,"logoutWithPersistOption",(function(){return C})),n.d(t,"preAuthorizeImplicit",(function(){return A})),n.d(t,"authorizeOauth2",(function(){return O})),n.d(t,"authorizeOauth2WithPersistOption",(function(){return k})),n.d(t,"authorizePassword",(function(){return j})),n.d(t,"authorizeApplication",(function(){return T})),n.d(t,"authorizeAccessCodeWithFormParams",(function(){return I})),n.d(t,"authorizeAccessCodeWithBasicAuthentication",(function(){return P})),n.d(t,"authorizeRequest",(function(){return N})),n.d(t,"configureAuth",(function(){return M})),n.d(t,"restoreAuthorization",(function(){return R})),n.d(t,"persistAuthorizationIfNeeded",(function(){return D}));var r=n(18),o=n.n(r),a=n(32),i=n.n(a),s=n(20),u=n.n(s),c=n(96),l=n.n(c),p=n(26),f=n(5),h="show_popup",d="authorize",m="logout",v="pre_authorize_oauth2",g="authorize_oauth2",y="validate",b="configure_auth",_="restore_authorization";function x(e){return{type:h,payload:e}}function w(e){return{type:d,payload:e}}var E=function(e){return function(t){var n=t.authActions;n.authorize(e),n.persistAuthorizationIfNeeded()}};function S(e){return{type:m,payload:e}}var C=function(e){return function(t){var n=t.authActions;n.logout(e),n.persistAuthorizationIfNeeded()}},A=function(e){return function(t){var n=t.authActions,r=t.errActions,o=e.auth,a=e.token,s=e.isValid,u=o.schema,c=o.name,l=u.get("flow");delete p.a.swaggerUIRedirectOauth2,"accessCode"===l||s||r.newAuthErr({authId:c,source:"auth",level:"warning",message:"Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"}),a.error?r.newAuthErr({authId:c,source:"auth",level:"error",message:i()(a)}):n.authorizeOauth2WithPersistOption({auth:o,token:a})}};function O(e){return{type:g,payload:e}}var k=function(e){return function(t){var n=t.authActions;n.authorizeOauth2(e),n.persistAuthorizationIfNeeded()}},j=function(e){return function(t){var n=t.authActions,r=e.schema,o=e.name,a=e.username,i=e.password,s=e.passwordType,c=e.clientId,l=e.clientSecret,p={grant_type:"password",scope:e.scopes.join(" "),username:a,password:i},h={};switch(s){case"request-body":!function(e,t,n){t&&u()(e,{client_id:t});n&&u()(e,{client_secret:n})}(p,c,l);break;case"basic":h.Authorization="Basic "+Object(f.a)(c+":"+l);break;default:console.warn("Warning: invalid passwordType ".concat(s," was passed, not including client id and secret"))}return n.authorizeRequest({body:Object(f.b)(p),url:r.get("tokenUrl"),name:o,headers:h,query:{},auth:e})}};var T=function(e){return function(t){var n=t.authActions,r=e.schema,o=e.scopes,a=e.name,i=e.clientId,s=e.clientSecret,u={Authorization:"Basic "+Object(f.a)(i+":"+s)},c={grant_type:"client_credentials",scope:o.join(" ")};return n.authorizeRequest({body:Object(f.b)(c),name:a,url:r.get("tokenUrl"),auth:e,headers:u})}},I=function(e){var t=e.auth,n=e.redirectUrl;return function(e){var r=e.authActions,o=t.schema,a=t.name,i=t.clientId,s=t.clientSecret,u=t.codeVerifier,c={grant_type:"authorization_code",code:t.code,client_id:i,client_secret:s,redirect_uri:n,code_verifier:u};return r.authorizeRequest({body:Object(f.b)(c),name:a,url:o.get("tokenUrl"),auth:t})}},P=function(e){var t=e.auth,n=e.redirectUrl;return function(e){var r=e.authActions,o=t.schema,a=t.name,i=t.clientId,s=t.clientSecret,u=t.codeVerifier,c={Authorization:"Basic "+Object(f.a)(i+":"+s)},l={grant_type:"authorization_code",code:t.code,client_id:i,redirect_uri:n,code_verifier:u};return r.authorizeRequest({body:Object(f.b)(l),name:a,url:o.get("tokenUrl"),auth:t,headers:c})}},N=function(e){return function(t){var n,r=t.fn,a=t.getConfigs,s=t.authActions,c=t.errActions,p=t.oas3Selectors,f=t.specSelectors,h=t.authSelectors,d=e.body,m=e.query,v=void 0===m?{}:m,g=e.headers,y=void 0===g?{}:g,b=e.name,_=e.url,x=e.auth,w=(h.getConfigs()||{}).additionalQueryStringParams;if(f.isOAS3()){var E=p.serverEffectiveValue(p.selectedServer());n=l()(_,E,!0)}else n=l()(_,f.url(),!0);"object"===o()(w)&&(n.query=u()({},n.query,w));var S=n.toString(),C=u()({Accept:"application/json, text/plain, */*","Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},y);r.fetch({url:S,method:"post",headers:C,query:v,body:d,requestInterceptor:a().requestInterceptor,responseInterceptor:a().responseInterceptor}).then((function(e){var t=JSON.parse(e.data),n=t&&(t.error||""),r=t&&(t.parseError||"");e.ok?n||r?c.newAuthErr({authId:b,level:"error",source:"auth",message:i()(t)}):s.authorizeOauth2WithPersistOption({auth:x,token:t}):c.newAuthErr({authId:b,level:"error",source:"auth",message:e.statusText})})).catch((function(e){var t=new Error(e).message;if(e.response&&e.response.data){var n=e.response.data;try{var r="string"==typeof n?JSON.parse(n):n;r.error&&(t+=", error: ".concat(r.error)),r.error_description&&(t+=", description: ".concat(r.error_description))}catch(e){}}c.newAuthErr({authId:b,level:"error",source:"auth",message:t})}))}};function M(e){return{type:b,payload:e}}function R(e){return{type:_,payload:e}}var D=function(){return function(e){var t=e.authSelectors;if((0,e.getConfigs)().persistAuthorization){var n=t.authorized();localStorage.setItem("authorized",i()(n.toJS()))}}}},function(e,t,n){var r=n(1072);e.exports=function(e){for(var t=1;tS;S++)if((h||S in x)&&(b=w(y=x[S],S,_),e))if(t)A[S]=b;else if(b)switch(e){case 3:return!0;case 5:return y;case 6:return S;case 2:u.call(A,y)}else switch(e){case 4:return!1;case 7:u.call(A,y)}return p?-1:c||l?l:A}};e.exports={forEach:c(0),map:c(1),filter:c(2),some:c(3),every:c(4),find:c(5),findIndex:c(6),filterOut:c(7)}},function(e,t,n){n(161);var r=n(586),o=n(40),a=n(101),i=n(70),s=n(130),u=n(41)("toStringTag");for(var c in r){var l=o[c],p=l&&l.prototype;p&&a(p)!==u&&i(p,u,c),s[c]=s.Array}},function(e,t,n){"use strict";e.exports={current:null}},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t){var n,r,o=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===a||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:a}catch(e){n=a}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var u,c=[],l=!1,p=-1;function f(){l&&u&&(l=!1,u.length?c=u.concat(c):p=-1,c.length&&h())}function h(){if(!l){var e=s(f);l=!0;for(var t=c.length;t;){for(u=c,c=[];++p1)for(var n=1;n0&&"/"!==t[0]}));function Se(e,t,n){var r;t=t||[];var o=xe.apply(void 0,u()(r=[e]).call(r,i()(t))).get("parameters",Object(I.List)());return w()(o).call(o,(function(e,t){var r=n&&"body"===t.get("in")?t.get("value_xml"):t.get("value");return e.set(Object(T.A)(t,{allowHashes:!1}),r)}),Object(I.fromJS)({}))}function Ce(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(I.List.isList(e))return A()(e).call(e,(function(e){return I.Map.isMap(e)&&e.get("in")===t}))}function Ae(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(I.List.isList(e))return A()(e).call(e,(function(e){return I.Map.isMap(e)&&e.get("type")===t}))}function Oe(e,t){var n,r;t=t||[];var o=z(e).getIn(u()(n=["paths"]).call(n,i()(t)),Object(I.fromJS)({})),a=e.getIn(u()(r=["meta","paths"]).call(r,i()(t)),Object(I.fromJS)({})),s=ke(e,t),c=o.get("parameters")||new I.List,l=a.get("consumes_value")?a.get("consumes_value"):Ae(c,"file")?"multipart/form-data":Ae(c,"formData")?"application/x-www-form-urlencoded":void 0;return Object(I.fromJS)({requestContentType:l,responseContentType:s})}function ke(e,t){var n,r;t=t||[];var o=z(e).getIn(u()(n=["paths"]).call(n,i()(t)),null);if(null!==o){var a=e.getIn(u()(r=["meta","paths"]).call(r,i()(t),["produces_value"]),null),s=o.getIn(["produces",0],null);return a||s||"application/json"}}function je(e,t){var n;t=t||[];var r=z(e),a=r.getIn(u()(n=["paths"]).call(n,i()(t)),null);if(null!==a){var s=t,c=o()(s,1)[0],l=a.get("produces",null),p=r.getIn(["paths",c,"produces"],null),f=r.getIn(["produces"],null);return l||p||f}}function Te(e,t){var n;t=t||[];var r=z(e),a=r.getIn(u()(n=["paths"]).call(n,i()(t)),null);if(null!==a){var s=t,c=o()(s,1)[0],l=a.get("consumes",null),p=r.getIn(["paths",c,"consumes"],null),f=r.getIn(["consumes"],null);return l||p||f}}var Ie=function(e,t,n){var r=e.get("url").match(/^([a-z][a-z0-9+\-.]*):/),o=k()(r)?r[1]:null;return e.getIn(["scheme",t,n])||e.getIn(["scheme","_defaultScheme"])||o||""},Pe=function(e,t,n){var r;return d()(r=["http","https"]).call(r,Ie(e,t,n))>-1},Ne=function(e,t){var n;t=t||[];var r=e.getIn(u()(n=["meta","paths"]).call(n,i()(t),["parameters"]),Object(I.fromJS)([])),o=!0;return f()(r).call(r,(function(e){var t=e.get("errors");t&&t.count()&&(o=!1)})),o},Me=function(e,t){var n,r,o={requestBody:!1,requestContentType:{}},a=e.getIn(u()(n=["resolvedSubtrees","paths"]).call(n,i()(t),["requestBody"]),Object(I.fromJS)([]));return a.size<1||(a.getIn(["required"])&&(o.requestBody=a.getIn(["required"])),f()(r=a.getIn(["content"]).entrySeq()).call(r,(function(e){var t=e[0];if(e[1].getIn(["schema","required"])){var n=e[1].getIn(["schema","required"]).toJS();o.requestContentType[t]=n}}))),o},Re=function(e,t,n,r){var o;if((n||r)&&n===r)return!0;var a=e.getIn(u()(o=["resolvedSubtrees","paths"]).call(o,i()(t),["requestBody","content"]),Object(I.fromJS)([]));if(a.size<2||!n||!r)return!1;var s=a.getIn([n,"schema","properties"],Object(I.fromJS)([])),c=a.getIn([r,"schema","properties"],Object(I.fromJS)([]));return!!s.equals(c)};function De(e){return I.Map.isMap(e)?e:new I.Map}},function(e,t,n){"use strict";(function(t){var r=n(919),o=n(920),a=/^[A-Za-z][A-Za-z0-9+-.]*:[\\/]+/,i=/^([a-z][a-z0-9.+-]*:)?([\\/]{1,})?([\S\s]*)/i,s=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function u(e){return(e||"").toString().replace(s,"")}var c=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],l={hash:1,query:1};function p(e){var n,r=("undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{}).location||{},o={},i=typeof(e=e||r);if("blob:"===e.protocol)o=new h(unescape(e.pathname),{});else if("string"===i)for(n in o=new h(e,{}),l)delete o[n];else if("object"===i){for(n in e)n in l||(o[n]=e[n]);void 0===o.slashes&&(o.slashes=a.test(e.href))}return o}function f(e){e=u(e);var t=i.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!(t[2]&&t[2].length>=2),rest:t[2]&&1===t[2].length?"/"+t[3]:t[3]}}function h(e,t,n){if(e=u(e),!(this instanceof h))return new h(e,t,n);var a,i,s,l,d,m,v=c.slice(),g=typeof t,y=this,b=0;for("object"!==g&&"string"!==g&&(n=t,t=null),n&&"function"!=typeof n&&(n=o.parse),t=p(t),a=!(i=f(e||"")).protocol&&!i.slashes,y.slashes=i.slashes||a&&t.slashes,y.protocol=i.protocol||t.protocol||"",e=i.rest,i.slashes||(v[3]=[/(.*)/,"pathname"]);b=4?[t[0],t[1],t[2],t[3],"".concat(t[0],".").concat(t[1]),"".concat(t[0],".").concat(t[2]),"".concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[0]),"".concat(t[1],".").concat(t[2]),"".concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[1]),"".concat(t[2],".").concat(t[3]),"".concat(t[3],".").concat(t[0]),"".concat(t[3],".").concat(t[1]),"".concat(t[3],".").concat(t[2]),"".concat(t[0],".").concat(t[1],".").concat(t[2]),"".concat(t[0],".").concat(t[1],".").concat(t[3]),"".concat(t[0],".").concat(t[2],".").concat(t[1]),"".concat(t[0],".").concat(t[2],".").concat(t[3]),"".concat(t[0],".").concat(t[3],".").concat(t[1]),"".concat(t[0],".").concat(t[3],".").concat(t[2]),"".concat(t[1],".").concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[2],".").concat(t[0]),"".concat(t[1],".").concat(t[2],".").concat(t[3]),"".concat(t[1],".").concat(t[3],".").concat(t[0]),"".concat(t[1],".").concat(t[3],".").concat(t[2]),"".concat(t[2],".").concat(t[0],".").concat(t[1]),"".concat(t[2],".").concat(t[0],".").concat(t[3]),"".concat(t[2],".").concat(t[1],".").concat(t[0]),"".concat(t[2],".").concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[3],".").concat(t[0]),"".concat(t[2],".").concat(t[3],".").concat(t[1]),"".concat(t[3],".").concat(t[0],".").concat(t[1]),"".concat(t[3],".").concat(t[0],".").concat(t[2]),"".concat(t[3],".").concat(t[1],".").concat(t[0]),"".concat(t[3],".").concat(t[1],".").concat(t[2]),"".concat(t[3],".").concat(t[2],".").concat(t[0]),"".concat(t[3],".").concat(t[2],".").concat(t[1]),"".concat(t[0],".").concat(t[1],".").concat(t[2],".").concat(t[3]),"".concat(t[0],".").concat(t[1],".").concat(t[3],".").concat(t[2]),"".concat(t[0],".").concat(t[2],".").concat(t[1],".").concat(t[3]),"".concat(t[0],".").concat(t[2],".").concat(t[3],".").concat(t[1]),"".concat(t[0],".").concat(t[3],".").concat(t[1],".").concat(t[2]),"".concat(t[0],".").concat(t[3],".").concat(t[2],".").concat(t[1]),"".concat(t[1],".").concat(t[0],".").concat(t[2],".").concat(t[3]),"".concat(t[1],".").concat(t[0],".").concat(t[3],".").concat(t[2]),"".concat(t[1],".").concat(t[2],".").concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[2],".").concat(t[3],".").concat(t[0]),"".concat(t[1],".").concat(t[3],".").concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[3],".").concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[0],".").concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[0],".").concat(t[3],".").concat(t[1]),"".concat(t[2],".").concat(t[1],".").concat(t[0],".").concat(t[3]),"".concat(t[2],".").concat(t[1],".").concat(t[3],".").concat(t[0]),"".concat(t[2],".").concat(t[3],".").concat(t[0],".").concat(t[1]),"".concat(t[2],".").concat(t[3],".").concat(t[1],".").concat(t[0]),"".concat(t[3],".").concat(t[0],".").concat(t[1],".").concat(t[2]),"".concat(t[3],".").concat(t[0],".").concat(t[2],".").concat(t[1]),"".concat(t[3],".").concat(t[1],".").concat(t[0],".").concat(t[2]),"".concat(t[3],".").concat(t[1],".").concat(t[2],".").concat(t[0]),"".concat(t[3],".").concat(t[2],".").concat(t[0],".").concat(t[1]),"".concat(t[3],".").concat(t[2],".").concat(t[1],".").concat(t[0])]:void 0),g[r]}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=e.filter((function(e){return"token"!==e})),o=y(r);return o.reduce((function(e,t){return f()({},e,n[t])}),t)}function _(e){return e.join(" ")}function x(e){var t=e.node,n=e.stylesheet,r=e.style,o=void 0===r?{}:r,a=e.useInlineStyles,i=e.key,s=t.properties,u=t.type,c=t.tagName,l=t.value;if("text"===u)return l;if(c){var p,h=function(e,t){var n=0;return function(r){return n+=1,r.map((function(r,o){return x({node:r,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(o)})}))}}(n,a);if(a){var m=Object.keys(n).reduce((function(e,t){return t.split(".").forEach((function(t){e.includes(t)||e.push(t)})),e}),[]),g=s.className&&s.className.includes("token")?["token"]:[],y=s.className&&g.concat(s.className.filter((function(e){return!m.includes(e)})));p=f()({},s,{className:_(y)||void 0,style:b(s.className,Object.assign({},s.style,o),n)})}else p=f()({},s,{className:_(s.className)});var w=h(t.children);return d.a.createElement(c,v()({key:i},p),w)}}var w=/\n/g;function E(e){var t=e.codeString,n=e.codeStyle,r=e.containerStyle,o=void 0===r?{float:"left",paddingRight:"10px"}:r,a=e.numberStyle,i=void 0===a?{}:a,s=e.startingLineNumber;return d.a.createElement("code",{style:Object.assign({},n,o)},function(e){var t=e.lines,n=e.startingLineNumber,r=e.style;return t.map((function(e,t){var o=t+n;return d.a.createElement("span",{key:"line-".concat(t),className:"react-syntax-highlighter-line-number",style:"function"==typeof r?r(o):r},"".concat(o,"\n"))}))}({lines:t.replace(/\n$/,"").split("\n"),style:i,startingLineNumber:s}))}function S(e,t){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:t},children:[{type:"text",value:e}]}}function C(e,t,n){var r,o={display:"inline-block",minWidth:(r=n,"".concat(r.toString().length,".25em")),paddingRight:"1em",textAlign:"right",userSelect:"none"},a="function"==typeof e?e(t):e;return f()({},o,a)}function A(e){var t=e.children,n=e.lineNumber,r=e.lineNumberStyle,o=e.largestLineNumber,a=e.showInlineLineNumbers,i=e.lineProps,s=void 0===i?{}:i,u=e.className,c=void 0===u?[]:u,l=e.showLineNumbers,p=e.wrapLongLines,h="function"==typeof s?s(n):s;if(h.className=c,n&&a){var d=C(r,n,o);t.unshift(S(n,d))}return p&l&&(h.style=f()({},h.style,{display:"flex"})),{type:"element",tagName:"span",properties:h,children:t}}function O(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=0;r2&&void 0!==arguments[2]?arguments[2]:[];return A({children:e,lineNumber:t,lineNumberStyle:s,largestLineNumber:i,showInlineLineNumbers:o,lineProps:n,className:a,showLineNumbers:r,wrapLongLines:u})}function m(e,t){if(r&&t&&o){var n=C(s,t,i);e.unshift(S(t,n))}return e}function v(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return t||r.length>0?d(e,n,r):m(e,n)}for(var g=function(){var e=l[h],t=e.children[0].value;if(t.match(w)){var n=t.split("\n");n.forEach((function(t,o){var i=r&&p.length+a,s={type:"text",value:"".concat(t,"\n")};if(0===o){var u=v(l.slice(f+1,h).concat(A({children:[s],className:e.properties.className})),i);p.push(u)}else if(o===n.length-1){if(l[h+1]&&l[h+1].children&&l[h+1].children[0]){var c=A({children:[{type:"text",value:"".concat(t)}],className:e.properties.className});l.splice(h+1,0,c)}else{var d=v([s],i,e.properties.className);p.push(d)}}else{var m=v([s],i,e.properties.className);p.push(m)}})),f=h}h++};h .hljs-title":{color:"#88C0D0"},"hljs-keyword":{color:"#81A1C1"},"hljs-literal":{color:"#81A1C1"},"hljs-symbol":{color:"#81A1C1"},"hljs-number":{color:"#B48EAD"},"hljs-regexp":{color:"#EBCB8B"},"hljs-string":{color:"#A3BE8C"},"hljs-title":{color:"#8FBCBB"},"hljs-params":{color:"#D8DEE9"},"hljs-bullet":{color:"#81A1C1"},"hljs-code":{color:"#8FBCBB"},"hljs-emphasis":{fontStyle:"italic"},"hljs-formula":{color:"#8FBCBB"},"hljs-strong":{fontWeight:"bold"},"hljs-link:hover":{textDecoration:"underline"},"hljs-quote":{color:"#4C566A"},"hljs-comment":{color:"#4C566A"},"hljs-doctag":{color:"#8FBCBB"},"hljs-meta":{color:"#5E81AC"},"hljs-meta-keyword":{color:"#5E81AC"},"hljs-meta-string":{color:"#A3BE8C"},"hljs-attr":{color:"#8FBCBB"},"hljs-attribute":{color:"#D8DEE9"},"hljs-builtin-name":{color:"#81A1C1"},"hljs-name":{color:"#81A1C1"},"hljs-section":{color:"#88C0D0"},"hljs-tag":{color:"#81A1C1"},"hljs-variable":{color:"#D8DEE9"},"hljs-template-variable":{color:"#D8DEE9"},"hljs-template-tag":{color:"#5E81AC"},"abnf .hljs-attribute":{color:"#88C0D0"},"abnf .hljs-symbol":{color:"#EBCB8B"},"apache .hljs-attribute":{color:"#88C0D0"},"apache .hljs-section":{color:"#81A1C1"},"arduino .hljs-built_in":{color:"#88C0D0"},"aspectj .hljs-meta":{color:"#D08770"},"aspectj > .hljs-title":{color:"#88C0D0"},"bnf .hljs-attribute":{color:"#8FBCBB"},"clojure .hljs-name":{color:"#88C0D0"},"clojure .hljs-symbol":{color:"#EBCB8B"},"coq .hljs-built_in":{color:"#88C0D0"},"cpp .hljs-meta-string":{color:"#8FBCBB"},"css .hljs-built_in":{color:"#88C0D0"},"css .hljs-keyword":{color:"#D08770"},"diff .hljs-meta":{color:"#8FBCBB"},"ebnf .hljs-attribute":{color:"#8FBCBB"},"glsl .hljs-built_in":{color:"#88C0D0"},"groovy .hljs-meta:not(:first-child)":{color:"#D08770"},"haxe .hljs-meta":{color:"#D08770"},"java .hljs-meta":{color:"#D08770"},"ldif .hljs-attribute":{color:"#8FBCBB"},"lisp .hljs-name":{color:"#88C0D0"},"lua .hljs-built_in":{color:"#88C0D0"},"moonscript .hljs-built_in":{color:"#88C0D0"},"nginx .hljs-attribute":{color:"#88C0D0"},"nginx .hljs-section":{color:"#5E81AC"},"pf .hljs-built_in":{color:"#88C0D0"},"processing .hljs-built_in":{color:"#88C0D0"},"scss .hljs-keyword":{color:"#81A1C1"},"stylus .hljs-keyword":{color:"#81A1C1"},"swift .hljs-meta":{color:"#D08770"},"vim .hljs-built_in":{color:"#88C0D0",fontStyle:"italic"},"yaml .hljs-meta":{color:"#D08770"}},obsidian:{hljs:{display:"block",overflowX:"auto",padding:"0.5em",background:"#282b2e",color:"#e0e2e4"},"hljs-keyword":{color:"#93c763",fontWeight:"bold"},"hljs-selector-tag":{color:"#93c763",fontWeight:"bold"},"hljs-literal":{color:"#93c763",fontWeight:"bold"},"hljs-selector-id":{color:"#93c763"},"hljs-number":{color:"#ffcd22"},"hljs-attribute":{color:"#668bb0"},"hljs-code":{color:"white"},"hljs-class .hljs-title":{color:"white"},"hljs-section":{color:"white",fontWeight:"bold"},"hljs-regexp":{color:"#d39745"},"hljs-link":{color:"#d39745"},"hljs-meta":{color:"#557182"},"hljs-tag":{color:"#8cbbad"},"hljs-name":{color:"#8cbbad",fontWeight:"bold"},"hljs-bullet":{color:"#8cbbad"},"hljs-subst":{color:"#8cbbad"},"hljs-emphasis":{color:"#8cbbad"},"hljs-type":{color:"#8cbbad",fontWeight:"bold"},"hljs-built_in":{color:"#8cbbad"},"hljs-selector-attr":{color:"#8cbbad"},"hljs-selector-pseudo":{color:"#8cbbad"},"hljs-addition":{color:"#8cbbad"},"hljs-variable":{color:"#8cbbad"},"hljs-template-tag":{color:"#8cbbad"},"hljs-template-variable":{color:"#8cbbad"},"hljs-string":{color:"#ec7600"},"hljs-symbol":{color:"#ec7600"},"hljs-comment":{color:"#818e96"},"hljs-quote":{color:"#818e96"},"hljs-deletion":{color:"#818e96"},"hljs-selector-class":{color:"#A082BD"},"hljs-doctag":{fontWeight:"bold"},"hljs-title":{fontWeight:"bold"},"hljs-strong":{fontWeight:"bold"}},"tomorrow-night":{"hljs-comment":{color:"#969896"},"hljs-quote":{color:"#969896"},"hljs-variable":{color:"#cc6666"},"hljs-template-variable":{color:"#cc6666"},"hljs-tag":{color:"#cc6666"},"hljs-name":{color:"#cc6666"},"hljs-selector-id":{color:"#cc6666"},"hljs-selector-class":{color:"#cc6666"},"hljs-regexp":{color:"#cc6666"},"hljs-deletion":{color:"#cc6666"},"hljs-number":{color:"#de935f"},"hljs-built_in":{color:"#de935f"},"hljs-builtin-name":{color:"#de935f"},"hljs-literal":{color:"#de935f"},"hljs-type":{color:"#de935f"},"hljs-params":{color:"#de935f"},"hljs-meta":{color:"#de935f"},"hljs-link":{color:"#de935f"},"hljs-attribute":{color:"#f0c674"},"hljs-string":{color:"#b5bd68"},"hljs-symbol":{color:"#b5bd68"},"hljs-bullet":{color:"#b5bd68"},"hljs-addition":{color:"#b5bd68"},"hljs-title":{color:"#81a2be"},"hljs-section":{color:"#81a2be"},"hljs-keyword":{color:"#b294bb"},"hljs-selector-tag":{color:"#b294bb"},hljs:{display:"block",overflowX:"auto",background:"#1d1f21",color:"#c5c8c6",padding:"0.5em"},"hljs-emphasis":{fontStyle:"italic"},"hljs-strong":{fontWeight:"bold"}}},Q=o()(X),ee=function(e){return i()(Q).call(Q,e)?X[e]:(console.warn("Request style '".concat(e,"' is not available, returning default instead")),Z)}},function(e,t){e.exports=!0},function(e,t,n){var r=n(244),o=n(71).f,a=n(70),i=n(54),s=n(560),u=n(41)("toStringTag");e.exports=function(e,t,n,c){if(e){var l=n?e:e.prototype;i(l,u)||o(l,u,{configurable:!0,value:t}),c&&!r&&a(l,"toString",s)}}},function(e,t,n){var r=n(244),o=n(152),a=n(41)("toStringTag"),i="Arguments"==o(function(){return arguments}());e.exports=r?o:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),a))?n:i?o(t):"Object"==(r=o(t))&&"function"==typeof t.callee?"Arguments":r}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){e.exports=n(685)},function(e,t,n){"use strict";function r(e){return function(e){try{return!!JSON.parse(e)}catch(e){return null}}(e)?"json":null}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.r(t),n.d(t,"UPDATE_LAYOUT",(function(){return o})),n.d(t,"UPDATE_FILTER",(function(){return a})),n.d(t,"UPDATE_MODE",(function(){return i})),n.d(t,"SHOW",(function(){return s})),n.d(t,"updateLayout",(function(){return u})),n.d(t,"updateFilter",(function(){return c})),n.d(t,"show",(function(){return l})),n.d(t,"changeMode",(function(){return p}));var r=n(5),o="layout_update_layout",a="layout_update_filter",i="layout_update_mode",s="layout_show";function u(e){return{type:o,payload:e}}function c(e){return{type:a,payload:e}}function l(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e=Object(r.v)(e),{type:s,payload:{thing:e,shown:t}}}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return e=Object(r.v)(e),{type:i,payload:{thing:e,mode:t}}}},function(e,t,n){var r=n(428),o=n(165),a=n(197),i=n(52),s=n(117),u=n(198),c=n(164),l=n(256),p=Object.prototype.hasOwnProperty;e.exports=function(e){if(null==e)return!0;if(s(e)&&(i(e)||"string"==typeof e||"function"==typeof e.splice||u(e)||l(e)||a(e)))return!e.length;var t=o(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(c(e))return!r(e).length;for(var n in e)if(p.call(e,n))return!1;return!0}},function(e,t,n){var r=n(49),o=n(182),a=n(108),i=n(69),s=n(184),u=n(54),c=n(368),l=Object.getOwnPropertyDescriptor;t.f=r?l:function(e,t){if(e=i(e),t=s(t,!0),c)try{return l(e,t)}catch(e){}if(u(e,t))return a(!o.f.call(e,t),e[t])}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t){e.exports=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var r=n(78);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,o){return e.call(t,n,r,o)}}return function(){return e.apply(t,arguments)}}},function(e,t,n){var r,o=n(51),a=n(237),i=n(240),s=n(159),u=n(373),c=n(232),l=n(188),p=l("IE_PROTO"),f=function(){},h=function(e){return"