├── .clang-format ├── .eslintrc.js ├── .gitignore ├── .markdownlintrc ├── .npmrc ├── .pylintrc ├── CPPLINT.cfg ├── Dockerfile ├── HACK.md ├── LICENSE ├── OWNERS ├── PRESUBMIT.cfg ├── README.md ├── hterm ├── .gitignore ├── LICENSE ├── README.md ├── audio │ └── bell.ogg ├── bin │ ├── hterm.py │ ├── lint │ ├── load_tests │ ├── mkdist │ └── vtscope.py ├── concat │ ├── hterm.concat │ ├── hterm_all.concat │ ├── hterm_deps.concat │ ├── hterm_resources.concat │ └── hterm_test_resources.concat ├── doc │ ├── AUTHORS.md │ ├── ChangeLog.md │ ├── ControlSequences.md │ ├── KeyboardBindings.md │ ├── embed.md │ ├── hack.md │ └── internals │ │ ├── README.md │ │ ├── lifecycle.md │ │ └── source.md ├── etc │ ├── hterm-notify.sh │ ├── hterm-show-file.sh │ ├── osc52.el │ ├── osc52.sh │ └── osc52.vim ├── html │ ├── find_bar.html │ ├── find_screen.html │ ├── hterm.html │ └── hterm_test.html ├── images │ ├── README.md │ ├── close.svg │ ├── copy.svg │ ├── icon-96.png │ ├── keyboard_arrow_down.svg │ └── keyboard_arrow_up.svg ├── js │ ├── hterm.js │ ├── hterm_accessibility_reader.js │ ├── hterm_accessibility_reader_tests.js │ ├── hterm_contextmenu.js │ ├── hterm_contextmenu_tests.js │ ├── hterm_find_bar.js │ ├── hterm_find_bar_tests.js │ ├── hterm_frame.js │ ├── hterm_keyboard.js │ ├── hterm_keyboard_bindings.js │ ├── hterm_keyboard_keymap.js │ ├── hterm_keyboard_keymap_tests.js │ ├── hterm_keyboard_keypattern.js │ ├── hterm_mock_notification.js │ ├── hterm_mock_row_provider.js │ ├── hterm_notifications.js │ ├── hterm_notifications_tests.js │ ├── hterm_options.js │ ├── hterm_parser.js │ ├── hterm_parser_identifiers.js │ ├── hterm_parser_tests.js │ ├── hterm_preference_manager.js │ ├── hterm_preference_manager_tests.js │ ├── hterm_pubsub.js │ ├── hterm_pubsub_tests.js │ ├── hterm_screen.js │ ├── hterm_screen_tests.js │ ├── hterm_scrollport.js │ ├── hterm_scrollport_tests.js │ ├── hterm_terminal.js │ ├── hterm_terminal_io.js │ ├── hterm_terminal_io_tests.js │ ├── hterm_terminal_tests.js │ ├── hterm_test.js │ ├── hterm_tests.js │ ├── hterm_text_attributes.js │ ├── hterm_text_attributes_tests.js │ ├── hterm_vt.js │ ├── hterm_vt_canned_tests.js │ ├── hterm_vt_character_map.js │ ├── hterm_vt_character_map_tests.js │ └── hterm_vt_tests.js ├── package.json └── test_data │ ├── .gitignore │ ├── README.md │ ├── charsets.log │ ├── deva.txt │ ├── unicode-sampler.txt │ ├── utf-8.html │ ├── utf-8.py │ ├── utf-8.txt │ ├── vttest-01.log │ └── vttest-02.log ├── kokoro ├── README.md ├── build ├── container ├── kokoro.py └── lint ├── libdot ├── .gitignore ├── LICENSE ├── README.md ├── bin │ ├── .gitignore │ ├── closure-compiler │ ├── concat │ ├── cpplint │ ├── eslint │ ├── fetch │ ├── headless-chrome │ ├── imgcrush │ ├── jsonlint │ ├── libdot.py │ ├── lint │ ├── load_tests │ ├── mdlint │ ├── minify-translations │ ├── mkdist │ ├── node │ ├── node_modules_create_bundle │ ├── node_sync_with_chromium │ ├── npm │ ├── plugin-to-platform-specific.py │ ├── pylint │ └── readlink ├── concat │ └── libdot.concat ├── css │ └── mocha-dark-theme.css ├── doc │ ├── ChangeLog.md │ └── tools.md ├── externs │ ├── .gitignore │ ├── browser.js │ ├── chai.js │ └── mocha.js ├── html │ └── lib_test.html ├── js │ ├── lib.js │ ├── lib_array.js │ ├── lib_array_tests.js │ ├── lib_codec.js │ ├── lib_codec_tests.js │ ├── lib_colors.js │ ├── lib_colors_tests.js │ ├── lib_credential_cache.js │ ├── lib_credential_cache_tests.js │ ├── lib_event.js │ ├── lib_event_tests.js │ ├── lib_f.js │ ├── lib_f_tests.js │ ├── lib_fs.js │ ├── lib_i18n.js │ ├── lib_i18n_tests.js │ ├── lib_message_manager.js │ ├── lib_message_manager_tests.js │ ├── lib_polyfill.js │ ├── lib_polyfill_tests.js │ ├── lib_preference_manager.js │ ├── lib_preference_manager_tests.js │ ├── lib_resource.js │ ├── lib_storage.js │ ├── lib_storage_chrome.js │ ├── lib_storage_chrome_tests.js │ ├── lib_storage_local.js │ ├── lib_storage_local_tests.js │ ├── lib_storage_memory.js │ ├── lib_storage_memory_tests.js │ ├── lib_storage_terminal_private.js │ ├── lib_storage_terminal_private_tests.js │ ├── lib_storage_tests.js │ └── lib_test.js ├── package.json └── third_party │ ├── intl-segmenter │ ├── LICENSE.md │ ├── METADATA │ ├── README.md │ ├── intl-segmenter.js │ └── intl-segmenter_tests.js │ └── wcwidth │ ├── .gitignore │ ├── LICENSE.md │ ├── METADATA │ ├── README.md │ ├── lib_wc.js │ ├── lib_wc_tests.js │ └── ranges.py ├── nassh ├── .gitignore ├── LICENSE ├── README.md ├── _locales │ ├── af │ │ └── messages.json │ ├── am │ │ └── messages.json │ ├── ar │ │ └── messages.json │ ├── bg │ │ └── messages.json │ ├── bn │ │ └── messages.json │ ├── bs │ │ └── messages.json │ ├── ca │ │ └── messages.json │ ├── cs │ │ └── messages.json │ ├── da │ │ └── messages.json │ ├── de │ │ └── messages.json │ ├── el │ │ └── messages.json │ ├── en │ │ └── messages.json │ ├── en_GB │ │ └── messages.json │ ├── es │ │ └── messages.json │ ├── es_419 │ │ └── messages.json │ ├── et │ │ └── messages.json │ ├── fa │ │ └── messages.json │ ├── fi │ │ └── messages.json │ ├── fil │ │ └── messages.json │ ├── fr │ │ └── messages.json │ ├── fr_CA │ │ └── messages.json │ ├── gl │ │ └── messages.json │ ├── gu │ │ └── messages.json │ ├── he │ │ └── messages.json │ ├── hi │ │ └── messages.json │ ├── hr │ │ └── messages.json │ ├── hu │ │ └── messages.json │ ├── id │ │ └── messages.json │ ├── is │ │ └── messages.json │ ├── it │ │ └── messages.json │ ├── ja │ │ └── messages.json │ ├── ka │ │ └── messages.json │ ├── km │ │ └── messages.json │ ├── kn │ │ └── messages.json │ ├── ko │ │ └── messages.json │ ├── lo │ │ └── messages.json │ ├── lt │ │ └── messages.json │ ├── lv │ │ └── messages.json │ ├── ml │ │ └── messages.json │ ├── mr │ │ └── messages.json │ ├── ms │ │ └── messages.json │ ├── ne │ │ └── messages.json │ ├── nl │ │ └── messages.json │ ├── no │ │ └── messages.json │ ├── pa │ │ └── messages.json │ ├── pl │ │ └── messages.json │ ├── pt_BR │ │ └── messages.json │ ├── pt_PT │ │ └── messages.json │ ├── ro │ │ └── messages.json │ ├── ru │ │ └── messages.json │ ├── si │ │ └── messages.json │ ├── sk │ │ └── messages.json │ ├── sl │ │ └── messages.json │ ├── sq │ │ └── messages.json │ ├── sr │ │ └── messages.json │ ├── sv │ │ └── messages.json │ ├── sw │ │ └── messages.json │ ├── ta │ │ └── messages.json │ ├── te │ │ └── messages.json │ ├── th │ │ └── messages.json │ ├── tr │ │ └── messages.json │ ├── uk │ │ └── messages.json │ ├── ur │ │ └── messages.json │ ├── vi │ │ └── messages.json │ ├── zh_CN │ │ └── messages.json │ ├── zh_TW │ │ └── messages.json │ └── zu │ │ └── messages.json ├── bin │ ├── filter_translations.py │ ├── fonts │ ├── fonts_create_bundle │ ├── generate-changelog │ ├── import-translations │ ├── lint │ ├── load_tests │ ├── mkdeps │ ├── mkdist │ └── nassh.py ├── concat │ ├── nassh_deps.concat │ └── release-highlights.txt ├── css │ ├── nassh_box.css │ ├── nassh_connect_dialog.css │ ├── nassh_preferences_editor.css │ └── nassh_sftp_fsp_config_dialog.css ├── doc │ ├── AUTHORS.md │ ├── ChangeLog.md │ ├── FAQ.md │ ├── api.md │ ├── app-to-ext-migration.md │ ├── chromeos-crosh.md │ ├── fonts.md │ ├── hack.md │ ├── hardware-keys.md │ ├── options.md │ ├── processes.md │ ├── relay-protocol.md │ ├── translations.md │ └── uri.md ├── externs │ ├── asn1.js │ ├── google-smart-card-client-library.js │ ├── pki.js │ └── punycode.js ├── html │ ├── changelog.html.in │ ├── crosh.html │ ├── licenses.html.in │ ├── nassh.html │ ├── nassh_background.html │ ├── nassh_connect_dialog.html │ ├── nassh_google_relay.html │ ├── nassh_popup.html │ ├── nassh_preferences_editor.html │ ├── nassh_sftp_fsp_config_dialog.html │ └── nassh_test.html ├── images │ ├── README.md │ ├── dev │ │ ├── crostini-192.png │ │ ├── crostini-fullsize.webp │ │ ├── crostini.svg │ │ ├── icon-128.png │ │ ├── icon-16.png │ │ ├── icon-24.png │ │ ├── icon-32.png │ │ ├── icon-48.png │ │ └── icon-fullsize.png │ ├── promo-440.png │ ├── promo-920.png │ ├── screenshot-icon-640.png │ ├── screenshot-light-640.png │ ├── screenshot-nethack-640.jpg │ ├── screenshot-osc-1337-640.png │ ├── screenshot-split-screen-640.jpg │ ├── screenshot-vim-source-640.jpg │ ├── screenshot-wargames-640.jpg │ ├── screenshot-zork-640.png │ ├── stable │ │ ├── icon-128.png │ │ ├── icon-16.png │ │ ├── icon-16.svg │ │ ├── icon-24.png │ │ ├── icon-32.png │ │ ├── icon-48.png │ │ ├── icon-48.svg │ │ └── icon-512.svg │ ├── visibility.svg │ └── visibility_off.svg ├── js │ ├── chrome_mock_for_test.js │ ├── crosh.js │ ├── licenses.js │ ├── nasftp.js │ ├── nasftp_cli.js │ ├── nasftp_cli_tests.js │ ├── nassh.js │ ├── nassh_agent.js │ ├── nassh_agent_backend.js │ ├── nassh_agent_backend_gsc.js │ ├── nassh_agent_message.js │ ├── nassh_agent_message_tests.js │ ├── nassh_agent_message_types.js │ ├── nassh_agent_message_types_tests.js │ ├── nassh_agent_tests.js │ ├── nassh_app.js │ ├── nassh_background.js │ ├── nassh_buffer.js │ ├── nassh_buffer_concat.js │ ├── nassh_buffer_concat_tests.js │ ├── nassh_buffer_scatgat.js │ ├── nassh_buffer_scatgat_tests.js │ ├── nassh_buffer_tests.js │ ├── nassh_column_list.js │ ├── nassh_command_instance.js │ ├── nassh_command_instance_tests.js │ ├── nassh_connect_dialog.js │ ├── nassh_deps_rollup_shim.js │ ├── nassh_extension_popup.js │ ├── nassh_external_api.js │ ├── nassh_google.js │ ├── nassh_google_relay_html.js │ ├── nassh_main.js │ ├── nassh_preference_manager.js │ ├── nassh_preference_manager_tests.js │ ├── nassh_preferences_editor.js │ ├── nassh_preferences_protocol_register.js │ ├── nassh_preferences_ssh_files.js │ ├── nassh_relay.js │ ├── nassh_relay_corp.js │ ├── nassh_relay_corpv4.js │ ├── nassh_relay_sshfe.js │ ├── nassh_sftp_client.js │ ├── nassh_sftp_fsp.js │ ├── nassh_sftp_fsp_config_dialog.js │ ├── nassh_sftp_fsp_tests.js │ ├── nassh_sftp_packet.js │ ├── nassh_sftp_packet_tests.js │ ├── nassh_sftp_packet_types.js │ ├── nassh_sftp_packet_types_tests.js │ ├── nassh_sftp_status.js │ ├── nassh_stream.js │ ├── nassh_stream_relay_corp.js │ ├── nassh_stream_relay_corpv4.js │ ├── nassh_stream_relay_corpv4_tests.js │ ├── nassh_stream_relay_sshfe.js │ ├── nassh_stream_set.js │ ├── nassh_stream_sftp.js │ ├── nassh_stream_sshagent.js │ ├── nassh_stream_sshagent_relay.js │ ├── nassh_stream_tty.js │ ├── nassh_test.js │ └── nassh_tests.js ├── manifest.json ├── package.json ├── rollup.config.js └── third_party │ ├── chrome-bootstrap │ ├── LICENSE.md │ ├── METADATA │ └── chrome-bootstrap.css │ ├── google-smart-card │ ├── LICENSE.md │ ├── METADATA │ ├── README.md │ ├── download-google-smart-card-client-library.py │ └── google-smart-card-client-library.js │ ├── nerd-fonts │ ├── 0001-Generate-Powerline-fonts-for-nassh.patch │ ├── LICENSE │ └── METADATA │ └── powerline │ ├── LICENSE │ └── METADATA ├── navbar.md ├── package.json ├── ssh_client ├── .gitignore ├── LICENSE ├── README.md ├── bin │ ├── lint │ ├── pylint │ └── ssh_client.py ├── build.sh ├── echosshd │ ├── .gitignore │ ├── Makefile │ ├── README.md │ └── echosshd.cc ├── include │ └── nacl-mounts │ │ └── base │ │ ├── irt_syscalls.h │ │ └── nacl_stat.h ├── src │ ├── Makefile │ ├── dev_null.cc │ ├── dev_null.h │ ├── dev_random.cc │ ├── dev_random.h │ ├── file_interfaces.h │ ├── file_system.cc │ ├── file_system.h │ ├── js_file.cc │ ├── js_file.h │ ├── pepper_file.cc │ ├── pepper_file.h │ ├── proxy_stream.h │ ├── pthread_helpers.h │ ├── ssh_plugin.cc │ ├── ssh_plugin.h │ ├── syscalls.cc │ ├── tcp_server_socket.cc │ ├── tcp_server_socket.h │ ├── tcp_socket.cc │ ├── tcp_socket.h │ ├── udp_socket.cc │ └── udp_socket.h ├── ssh_client.nmf ├── third_party │ ├── bazel-0.17 │ │ ├── LICENSE │ │ ├── METADATA │ │ └── build │ ├── binaryen │ │ ├── LICENSE │ │ ├── METADATA │ │ └── build │ ├── glibc-compat │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ └── include │ │ │ ├── arpa │ │ │ └── nameser.h │ │ │ ├── net │ │ │ └── if.h │ │ │ ├── netdb.h │ │ │ ├── netinet │ │ │ ├── in_systm.h │ │ │ └── ip.h │ │ │ ├── readpassphrase.h │ │ │ ├── resolv.h │ │ │ ├── sys │ │ │ ├── ioctl.h │ │ │ ├── syslog.h │ │ │ ├── time.h │ │ │ ├── uio.h │ │ │ ├── un.h │ │ │ └── unistd.h │ │ │ └── syslog.h │ ├── gnuconfig │ │ ├── LICENSE │ │ ├── METADATA │ │ └── build │ ├── ldns │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ ├── ldns-CVE-2017-1000231.patch │ │ ├── ldns-CVE-2017-1000232.patch │ │ ├── ldns-no-getproto.patch │ │ ├── ldns-ssl-engine.patch │ │ └── ldns-ssl-headers.patch │ ├── mandoc │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ └── mandoc-1.14.5.patch │ ├── mosh-chrome │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ ├── mosh-chrome-0.5.6-app-to-ext.patch │ │ ├── mosh-chrome-0.5.6-dist-reuse.patch │ │ ├── mosh-chrome-0.5.6-hterm-update.patch │ │ ├── mosh-chrome-0.5.6-libssh-update.patch │ │ ├── mosh-chrome-0.5.6-misc.patch │ │ ├── mosh-chrome-0.5.6-mosh-main.patch │ │ ├── mosh-chrome-0.5.6-private-net.patch │ │ ├── mosh-chrome-0.5.6-ssh-agent.patch │ │ └── mosh-chrome-0.5.6-term-init.patch │ ├── naclsdk │ │ ├── LICENSE │ │ ├── METADATA │ │ └── build │ ├── openssh-7.8 │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ └── openssh-7.8p1.patch │ ├── openssh-7.9 │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ └── openssh-7.9p1.patch │ ├── openssh-8.0 │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ ├── openssh-8.0p1-write-disconnect.patch │ │ └── openssh-8.0p1.patch │ ├── openssh-8.1 │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ ├── openssh-8.1p1-write-disconnect.patch │ │ └── openssh-8.1p1.patch │ ├── openssh-8.2 │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ └── openssh-8.2p1.patch │ ├── openssh-8.3 │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ └── openssh-8.3p1.patch │ ├── openssh-8.4 │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ └── openssh-8.4p1.patch │ ├── openssl │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ ├── nacl.patch │ │ ├── openssl-1.0.0a-ldflags.patch │ │ ├── openssl-1.0.2a-parallel-install-dirs.patch │ │ ├── openssl-1.0.2a-parallel-obj-headers.patch │ │ ├── openssl-1.0.2a-parallel-symlinking.patch │ │ └── openssl-1.0.2i-parallel-build.patch │ ├── wabt │ │ ├── LICENSE │ │ ├── METADATA │ │ └── build │ ├── wasi-sdk │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── build │ │ └── wasi-sdk-11.0-ififo.patch │ ├── wasmtime │ │ ├── LICENSE │ │ ├── METADATA │ │ └── build │ └── zlib │ │ ├── LICENSE │ │ ├── METADATA │ │ └── build └── wassh-libc-sup │ ├── METADATA │ ├── README.md │ ├── build │ ├── docs │ └── WASI-extensions.md │ ├── include │ ├── grp.h │ ├── ifaddrs.h │ ├── net │ │ └── if.h │ ├── netdb.h │ ├── pwd.h │ ├── resolv.h │ ├── signal.h │ ├── stdio.h │ ├── sys │ │ ├── cdefs.h │ │ ├── ioctl.h │ │ ├── select.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── un.h │ │ └── wait.h │ ├── syslog.h │ ├── termios.h │ └── unistd.h │ └── src │ ├── Makefile │ ├── bh-syscalls.c │ ├── bh-syscalls.h │ ├── connect.c │ ├── debug.h │ ├── signal.c │ ├── socket.c │ ├── stubs.c │ └── wassh.imports ├── terminal ├── .gitignore ├── OWNERS ├── README.md ├── bin │ ├── lint │ ├── load_tests │ └── terminal.py ├── externs │ └── lit_element.js ├── html │ ├── terminal.html │ ├── terminal_settings.html │ └── terminal_test.html └── js │ ├── lit_element.js │ ├── terminal.js │ ├── terminal_active_tracker.js │ ├── terminal_active_tracker_tests.js │ ├── terminal_common.js │ ├── terminal_common_tests.js │ ├── terminal_dialog.js │ ├── terminal_dialog_tests.js │ ├── terminal_knob.js │ ├── terminal_main.js │ ├── terminal_settings_ansi_colors.js │ ├── terminal_settings_ansi_colors_tests.js │ ├── terminal_settings_app.js │ ├── terminal_settings_app_tests.js │ ├── terminal_settings_background_image.js │ ├── terminal_settings_background_image_tests.js │ ├── terminal_settings_button.js │ ├── terminal_settings_category_selector.js │ ├── terminal_settings_category_selector_tests.js │ ├── terminal_settings_checkbox.js │ ├── terminal_settings_checkbox_tests.js │ ├── terminal_settings_colorpicker.js │ ├── terminal_settings_colorpicker_tests.js │ ├── terminal_settings_dropdown.js │ ├── terminal_settings_dropdown_tests.js │ ├── terminal_settings_element.js │ ├── terminal_settings_fonts.js │ ├── terminal_settings_fonts_tests.js │ ├── terminal_settings_hue_slider.js │ ├── terminal_settings_hue_slider_tests.js │ ├── terminal_settings_main.js │ ├── terminal_settings_saturation_value_picker.js │ ├── terminal_settings_saturation_value_picker_tests.js │ ├── terminal_settings_styles.js │ ├── terminal_settings_textfield.js │ ├── terminal_settings_textfield_tests.js │ ├── terminal_settings_theme.js │ ├── terminal_settings_theme_tests.js │ ├── terminal_settings_transparency_slider.js │ ├── terminal_settings_transparency_slider_tests.js │ ├── terminal_slider.js │ ├── terminal_slider_tests.js │ ├── terminal_test.js │ ├── terminal_test_mocks.js │ ├── terminal_tests.js │ ├── terminal_textfield.js │ └── terminal_textfield_tests.js ├── wasi-js-bindings ├── LICENSE ├── README.md └── js │ ├── dataview.js │ ├── process.js │ ├── program.js │ ├── syscall_entry.js │ ├── syscall_handler.js │ ├── syscall_lock.js │ ├── util.js │ ├── wasi.js │ ├── wasi │ ├── advice.js │ ├── clock.js │ ├── errno.js │ ├── eventtype.js │ ├── filetype.js │ ├── signal.js │ └── whence.js │ └── worker.js └── wassh ├── .gitignore ├── README.md ├── build.sh ├── js ├── syscall_entry.js ├── syscall_handler.js └── worker.js ├── test.c ├── test.html └── test.js /.clang-format: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The Chromium OS Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # Defines the Chromium style for automatic reformatting. 6 | # https://clang.llvm.org/docs/ClangFormatStyleOptions.html 7 | BasedOnStyle: Chromium 8 | 9 | # Please keep all directives after this one sorted alphabetically. 10 | 11 | # C++ settings. 12 | --- 13 | Language: Cpp 14 | 15 | # This is permitted by the Google and Chromium style guides. 16 | AllowAllParametersOfDeclarationOnNextLine: true 17 | 18 | # JavaScript settings. 19 | --- 20 | Language: JavaScript 21 | 22 | # A few tweaks where the guides permit. 23 | AlignOperands: true 24 | AllowShortFunctionsOnASingleLine: Inline 25 | BinPackArguments: false 26 | MaxEmptyLinesToKeep: 1 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Various temp files and editor configs. 2 | *~ 3 | \#* 4 | .#* 5 | __pycache__/ 6 | *.py[co] 7 | *.swp 8 | .eslintcache 9 | .vscode 10 | 11 | # Stuff we build for distribution 12 | /artifacts/ 13 | dist 14 | /ssh_client-image.tar* 15 | 16 | # npm related dirs. 17 | node_modules 18 | package-lock.json 19 | 20 | # Terminal settings page can be run from a local server if you make some of the 21 | # nassh dirs available at the right path. 22 | /_locales 23 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # https://docs.npmjs.com/files/npmrc 6 | 7 | # We'll manage this ourselves to keep node_modules size small. 8 | puppeteer_skip_chromium_download = true 9 | -------------------------------------------------------------------------------- /CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | filter=-build/header_guard,-build/include,-runtime/int,-readability/casting,-readability/todo 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2009 The Chromium OS Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. Neither the name of Google Inc. nor the names of its 12 | contributors may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | # In case of troubles, people can merge things easily. 2 | * 3 | 4 | # These are the main reviewers. 5 | vapier@chromium.org 6 | vsh@google.com 7 | 8 | # COMPONENT: Platform>Apps>Default>Hterm 9 | -------------------------------------------------------------------------------- /PRESUBMIT.cfg: -------------------------------------------------------------------------------- 1 | [Hook Overrides] 2 | # We don't require bugs or tests since we have (and assume) unittest coverage, 3 | # and we use Bug:/Test: tags instead of BUG=/TEST=. 4 | bug_field_check = false 5 | test_field_check = false 6 | 7 | cros_license_check = true 8 | 9 | # Our own linters handle long line checks. 10 | long_line_check = false 11 | 12 | [Hook Overrides Options] 13 | cros_license_check = 14 | --exclude_regex=METADATA$ 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hello 2 | 3 | This repository contains the libdot JavaScript library and some web applications 4 | that make use of it. 5 | 6 | The official copy of this repository is hosted at 7 | https://chromium.googlesource.com/apps/libapps. 8 | 9 | There is also a mirror on github at https://github.com/libapps/libapps-mirror. 10 | A few subprojects are also extracted out into their own git repo and mirrored. 11 | Keep in mind that these mirrors may occasionally be behind the official 12 | repository. 13 | 14 | All changes must go through the Gerrit code review server on 15 | https://chromium-review.googlesource.com. Github pull requests cannot be 16 | accepted. Please see the [HACK.md](./HACK.md) document in this directory for 17 | the details. 18 | 19 | # Top level directories 20 | 21 | * [libdot/](./libdot/) is a small set of JS libraries initially developed as 22 | part of hterm, now available as shared code. 23 | 24 | * [hterm/](./hterm/) is a JS library that provides a terminal emulator. It is 25 | reasonably fast, reasonably correct, and reasonably portable across browsers. 26 | 27 | * [nassh/](./nassh/) is the Secure Shell Chrome extension that combines hterm 28 | with a NaCl build of OpenSSH to provide a PuTTY-like app for Chrome users. 29 | 30 | * [ssh_client/](./ssh_client/) is the NaCl port of OpenSSH. It is used by 31 | [nassh](./nassh/) to create the Secure Shell App. 32 | -------------------------------------------------------------------------------- /hterm/.gitignore: -------------------------------------------------------------------------------- 1 | # Stuff we build for distribution 2 | dist 3 | /hterm-*.tgz 4 | /js/hterm_all.* 5 | 6 | # npm related dirs. 7 | node_modules 8 | -------------------------------------------------------------------------------- /hterm/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2009 The Chromium OS Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. Neither the name of Google Inc. nor the names of its 12 | contributors may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /hterm/audio/bell.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/hterm/audio/bell.ogg -------------------------------------------------------------------------------- /hterm/bin/hterm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Common hterm util code.""" 7 | 8 | from pathlib import Path 9 | import sys 10 | 11 | 12 | BIN_DIR = Path(__file__).resolve().parent 13 | DIR = BIN_DIR.parent 14 | LIBAPPS_DIR = DIR.parent 15 | 16 | 17 | sys.path.insert(0, str(LIBAPPS_DIR / 'libdot' / 'bin')) 18 | 19 | # pylint: disable=unused-import 20 | import libdot # pylint: disable=wrong-import-position 21 | -------------------------------------------------------------------------------- /hterm/bin/load_tests: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Run unittests in a new browser.""" 7 | 8 | import os 9 | import subprocess 10 | import sys 11 | 12 | import hterm 13 | import libdot 14 | 15 | 16 | # Path to our html test page. 17 | TEST_PAGE = os.path.join(hterm.DIR, 'html', 'hterm_test.html') 18 | 19 | 20 | def mkdeps(_opts): 21 | """Build the required deps for the test suite.""" 22 | subprocess.check_call([os.path.join(hterm.BIN_DIR, 'mkdist')]) 23 | 24 | 25 | def main(argv): 26 | """The main func!""" 27 | return libdot.load_tests.test_runner_main( 28 | argv, 'file://%s' % (TEST_PAGE,), mkdeps=mkdeps) 29 | 30 | 31 | if __name__ == '__main__': 32 | sys.exit(main(sys.argv[1:])) 33 | -------------------------------------------------------------------------------- /hterm/concat/hterm.concat: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file lists the hterm source files. 6 | # You need both hterm_deps.concat and hterm.concat in order to use hterm in 7 | # your project. 8 | 9 | # Keep this list in sync with ../html/hterm_test.html! 10 | 11 | hterm/js/hterm.js 12 | hterm/js/hterm_accessibility_reader.js 13 | hterm/js/hterm_contextmenu.js 14 | hterm/js/hterm_find_bar.js 15 | hterm/js/hterm_frame.js 16 | hterm/js/hterm_keyboard.js 17 | hterm/js/hterm_keyboard_bindings.js 18 | hterm/js/hterm_keyboard_keymap.js 19 | hterm/js/hterm_keyboard_keypattern.js 20 | hterm/js/hterm_notifications.js 21 | hterm/js/hterm_options.js 22 | hterm/js/hterm_parser.js 23 | hterm/js/hterm_parser_identifiers.js 24 | hterm/js/hterm_preference_manager.js 25 | hterm/js/hterm_pubsub.js 26 | hterm/js/hterm_screen.js 27 | hterm/js/hterm_scrollport.js 28 | hterm/js/hterm_terminal.js 29 | hterm/js/hterm_terminal_io.js 30 | hterm/js/hterm_text_attributes.js 31 | hterm/js/hterm_vt.js 32 | hterm/js/hterm_vt_character_map.js 33 | 34 | @include hterm/concat/hterm_resources.concat 35 | -------------------------------------------------------------------------------- /hterm/concat/hterm_all.concat: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014 The Chromium OS Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | @include hterm/concat/hterm_deps.concat 6 | @include hterm/concat/hterm.concat 7 | -------------------------------------------------------------------------------- /hterm/concat/hterm_deps.concat: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file lists the hterm dependencies on libdot. 6 | 7 | libdot/js/lib.js 8 | libdot/js/lib_polyfill.js 9 | libdot/js/lib_array.js 10 | libdot/js/lib_codec.js 11 | libdot/js/lib_colors.js 12 | libdot/js/lib_f.js 13 | libdot/js/lib_i18n.js 14 | libdot/js/lib_message_manager.js 15 | libdot/js/lib_preference_manager.js 16 | libdot/js/lib_resource.js 17 | libdot/js/lib_storage.js 18 | libdot/js/lib_storage_chrome.js 19 | libdot/js/lib_storage_local.js 20 | libdot/js/lib_storage_memory.js 21 | libdot/js/lib_storage_terminal_private.js 22 | libdot/third_party/intl-segmenter/intl-segmenter.js 23 | libdot/third_party/wcwidth/lib_wc.js 24 | 25 | @resource libdot/changelog/version text/plain \ 26 | changelog version ../../libdot/doc/ChangeLog.md 27 | @resource libdot/changelog/date text/plain \ 28 | changelog date ../../libdot/doc/ChangeLog.md 29 | -------------------------------------------------------------------------------- /hterm/concat/hterm_resources.concat: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file lists the resources needed by hterm. 6 | 7 | @resource hterm/audio/bell audio/ogg;base64 < ../audio/bell.ogg 8 | @resource hterm/images/copy image/svg+xml;utf8 < ../images/copy.svg 9 | @resource hterm/images/close image/svg+xml;utf8 < ../images/close.svg 10 | @resource hterm/images/keyboard_arrow_down image/svg+xml;utf8 < ../images/keyboard_arrow_down.svg 11 | @resource hterm/images/keyboard_arrow_up image/svg+xml;utf8 < ../images/keyboard_arrow_up.svg 12 | @resource hterm/html/find_bar text/html;utf8 < ../html/find_bar.html 13 | @resource hterm/html/find_screen text/html;utf8 < ../html/find_screen.html 14 | @resource hterm/images/icon-96 image/png;base64 < ../images/icon-96.png 15 | @resource hterm/concat/date text/plain date %a, %d %b %Y %H:%M:%S +0000 16 | @resource hterm/changelog/version text/plain changelog version 17 | @resource hterm/changelog/date text/plain changelog date 18 | @resource hterm/git/HEAD text/plain git-rev HEAD 19 | -------------------------------------------------------------------------------- /hterm/concat/hterm_test_resources.concat: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file lists the hterm test dependencies. 6 | 7 | @resource hterm/test/messages raw < ../../nassh/_locales/en/messages.json 8 | @resource hterm/test/canned/charsets text/plain < ../test_data/charsets.log 9 | @resource hterm/test/canned/vttest-01 text/plain < ../test_data/vttest-01.log 10 | @resource hterm/test/canned/vttest-02 text/plain < ../test_data/vttest-02.log 11 | -------------------------------------------------------------------------------- /hterm/doc/AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors & Maintainers & Contributors 2 | 3 | This is part of the Chromium OS project. 4 | 5 | Please do not use this list to contact authors. We have a mailing list for 6 | discussions. See the [README.md](./README.md#Contact) file for details. 7 | 8 | ## Maintainers 9 | 10 | The current maintainers: 11 | 12 | * Rob Ginda : Original author and visionary extraordinaire 13 | * Mike Frysinger : Likes to throw things at the wall until they stick 14 | 15 | ## Contributors 16 | 17 | If you want to throw your name in here after having one of your CLs merged, 18 | feel free! If the work is a bit more significant, feel free to list that too. 19 | 20 | The list is sorted alphabetically by last name. 21 | 22 | * Toni Barzic 23 | * David Benjamin 24 | * Ahmed Fakhry 25 | * Brandon Gilmore 26 | * Zelidrag Hornung 27 | * Evan Jones 28 | * Michael Kelly 29 | * Dmitry Polukhin 30 | * Andrew de los Reyes 31 | * Marius Schilder 32 | * Edoardo Spadolini 33 | * Rob Spies 34 | * Brad Town 35 | -------------------------------------------------------------------------------- /hterm/doc/internals/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | .--~~~~~~~~~~~~~------. 3 | /--===============------\ 4 | | |```````````````| | 5 | | | | | 6 | | | >_< | | 7 | | | | | 8 | | |_______________| | 9 | | ::::| 10 | '=======================' 11 | //-'-'-'-'-'-'-'-'-'-'-\\ 12 | //_'_'_'_'_'_'_'_'_'_'_'_\\ 13 | [-------------------------] 14 | \_________________________/ 15 | 16 | hterm Internals Guide 17 | ``` 18 | 19 | # Introduction 20 | 21 | If you need to dive into the hterm internals, these are the docs for you. 22 | 23 | If you just want to use hterm in your project, then you don't need this. 24 | Check out the [hacking](../hack.md) & [embedding](../embed.md) docs instead. 25 | 26 | If you're a user interacting with hterm, but not actually writing a program 27 | using hterm, then these definitely don't want these docs :). 28 | 29 | ## Chapters 30 | 31 | Here are the various internals topics. 32 | 33 | * [Source Layout](./source.md): The meaning of each piece of the source tree. 34 | * [Life Cycle](./lifecycle.md): General overview of the lifetime of hterm. 35 | -------------------------------------------------------------------------------- /hterm/html/find_screen.html: -------------------------------------------------------------------------------- 1 | 2 | 25 | -------------------------------------------------------------------------------- /hterm/images/README.md: -------------------------------------------------------------------------------- 1 | # Images 2 | 3 | When adding new files here, make sure to crush them first. 4 | You can use [libdot/bin/imgcrush](/libdot/bin/imgcrush) to do so losslessly. 5 | -------------------------------------------------------------------------------- /hterm/images/close.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /hterm/images/copy.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /hterm/images/icon-96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/hterm/images/icon-96.png -------------------------------------------------------------------------------- /hterm/images/keyboard_arrow_down.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /hterm/images/keyboard_arrow_up.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /hterm/js/hterm_contextmenu_tests.js: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview hterm.ContextMenu unit tests. 9 | */ 10 | 11 | describe('hterm_contextmenu_tests.js', () => { 12 | 13 | /** 14 | * Verify we can show/hide an empty menu. 15 | */ 16 | it('contextmenu-stub', () => { 17 | const menu = new hterm.ContextMenu(); 18 | 19 | // Show/hide this stub menu. It should be fine. 20 | menu.show(/** @type {!Event} */ ({clientX: 0, clientY: 0})); 21 | menu.hide(); 22 | }); 23 | 24 | /** 25 | * Verify we can show/hide a simple menu. 26 | */ 27 | it('contextmenu-simple', () => { 28 | const document = window.document; 29 | const menu = new hterm.ContextMenu(); 30 | menu.setDocument(document); 31 | 32 | // Create a basic menu. 33 | menu.setItems([{name: 'Foo', action: () => {}}]); 34 | 35 | // Show/hide this menu. 36 | menu.show(/** @type {!Event} */ ({clientX: 0, clientY: 0})); 37 | menu.hide(); 38 | }); 39 | 40 | /** 41 | * Check separator handling. 42 | */ 43 | it('contextmenu-separator', () => { 44 | const document = window.document; 45 | const menu = new hterm.ContextMenu(); 46 | menu.setDocument(document); 47 | 48 | // Create a basic menu. 49 | menu.setItems([{name: hterm.ContextMenu.SEPARATOR}]); 50 | 51 | // Check the entries. 52 | assert.equal('separator', menu.element_.firstElementChild.className); 53 | 54 | // Show/hide this menu. 55 | menu.show(/** @type {!Event} */ ({clientX: 0, clientY: 0})); 56 | menu.hide(); 57 | }); 58 | 59 | }); 60 | -------------------------------------------------------------------------------- /hterm/js/hterm_options.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview This file implements the hterm.Options class, 9 | * which stores current operating conditions for the terminal. This object is 10 | * used instead of a series of parameters to allow saving/restoring of cursor 11 | * conditions easily, and to provide an easy place for common configuration 12 | * options. 13 | * 14 | * Original code by Cory Maccarrone. 15 | */ 16 | 17 | /** 18 | * Constructor for the hterm.Options class, optionally acting as a copy 19 | * constructor. 20 | * 21 | * The defaults are as defined in http://www.vt100.net/docs/vt510-rm/DECSTR 22 | * except that we enable autowrap (wraparound) by default since that seems to 23 | * be what xterm does. 24 | * 25 | * @param {!hterm.Options=} copy Optional instance to copy. 26 | * @constructor 27 | */ 28 | hterm.Options = function(copy = undefined) { 29 | // All attributes in this class are public to allow easy access by the 30 | // terminal. 31 | 32 | this.wraparound = copy ? copy.wraparound : true; 33 | this.reverseWraparound = copy ? copy.reverseWraparound : false; 34 | this.originMode = copy ? copy.originMode : false; 35 | this.autoCarriageReturn = copy ? copy.autoCarriageReturn : false; 36 | this.cursorVisible = copy ? copy.cursorVisible : false; 37 | this.cursorBlink = copy ? copy.cursorBlink : false; 38 | this.insertMode = copy ? copy.insertMode : false; 39 | this.reverseVideo = copy ? copy.reverseVideo : false; 40 | this.bracketedPaste = copy ? copy.bracketedPaste : false; 41 | }; 42 | -------------------------------------------------------------------------------- /hterm/js/hterm_test.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Test framework setup when run inside the browser. 9 | */ 10 | 11 | // Setup the mocha framework. 12 | mocha.setup('bdd'); 13 | mocha.checkLeaks(); 14 | 15 | // Add a global shortcut to the assert API. 16 | const assert = chai.assert; 17 | 18 | // Catch any random errors before the test runner runs. 19 | let earlyError = null; 20 | /** 21 | * Catch any errors. 22 | * 23 | * @param {*} args Whatever arguments are passed in. 24 | */ 25 | window.onerror = function(...args) { 26 | earlyError = Array.from(args); 27 | }; 28 | 29 | /** Run the test framework once everything is finished. */ 30 | window.onload = async function() { 31 | hterm.defaultStorage = new lib.Storage.Memory(); 32 | 33 | await lib.init(); 34 | mocha.run(); 35 | 36 | if (earlyError !== null) { 37 | assert.fail(`uncaught exception detected:\n${earlyError.join('\n')}\n`); 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /hterm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hterm", 3 | "version": "1.91.0", 4 | "description": "A reasonably correct & fast terminal emulator.", 5 | "main": "js/hterm_all.js", 6 | "unpkg": "js/hterm_all.min.js", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://chromium.googlesource.com/apps/libapps.git" 10 | }, 11 | "author": "Chromium OS Authors", 12 | "license": "BSD-3-Clause", 13 | "files": [ 14 | "doc", 15 | "html/hterm.html", 16 | "js/hterm_all.js", 17 | "js/hterm_all.min.js", 18 | "js/hterm_all.min.js.map", 19 | "README.md" 20 | ], 21 | "bugs": { 22 | "url": "https://goo.gl/vb94JY", 23 | "email": "chromium-hterm@chromium.org" 24 | }, 25 | "homepage": "https://chromium.googlesource.com/apps/libapps/+/HEAD/hterm", 26 | "scripts": { 27 | "prepare": "./bin/mkdist -o js concat/hterm_all.concat && cd js && terser hterm_all.js --compress --mangle --output hterm_all.min.js --source-map url=hterm_all.min.js.map,includeSources", 28 | "test": "./bin/load_tests" 29 | }, 30 | "devDependencies": { 31 | "chai": "~4", 32 | "eslint": "~7", 33 | "mocha": "~8", 34 | "mocha-headless-chrome": "~3", 35 | "terser": "~4" 36 | }, 37 | "dependencies": {} 38 | } 39 | -------------------------------------------------------------------------------- /hterm/test_data/.gitignore: -------------------------------------------------------------------------------- 1 | /log 2 | /vttest.tar.gz 3 | /vttest-*/ 4 | -------------------------------------------------------------------------------- /hterm/test_data/README.md: -------------------------------------------------------------------------------- 1 | # Various Test Data 2 | 3 | These are test files for checking behavior/rendering of hterm. 4 | They come from a bunch of random sources. 5 | 6 | * [deva.txt](./deva.txt): From https://benizi.com/vim/devanagari/. 7 | * [utf-8.html](./utf-8.html): UTF-8 sampler from 8 | http://kermitproject.org/utf8.html. 9 | * [utf-8.txt](./utf-8.txt): Snippets from above page for easier testing. 10 | * [utf-8.py](./utf-8.py): Script to dump ranges of Unicode characters. 11 | * [unicode-sampler.txt](./unicode-sampler.txt): Unicode samples from 12 | http://sheet.shiar.nl/sample. 13 | 14 | ## VT Tests 15 | 16 | These are used by [hterm_vt_canned_tests.js](../js/hterm_vt_canned_tests.js). 17 | 18 | They were created via [Vttest](https://invisible-island.net/vttest/). 19 | 20 | See the [hacking document](../doc/hack.md) and 21 | [bin/vtscope.py](../bin/vtscope.py) for more details. 22 | 23 | * [charsets.log](./charsets.log) 24 | * [vttest-01.log](./vttest-02.log) 25 | * [vttest-02.log](./vttest-02.log) 26 | -------------------------------------------------------------------------------- /hterm/test_data/deva.txt: -------------------------------------------------------------------------------- 1 | अनन्त: वै वेद: । 2 | कार्त्स्न्या । 3 | 1.001.01a अ॒ग्निमी॑ळे पु॒रोहि॑तं य॒ज्ञस्य॑ दे॒वमृ॒त्विज॑म् । 4 | 1.001.01c होता॑रं रत्न॒धात॑मम् ॥ 5 | 1.001.01a a̱gnim ī̍ḻe pu̱rohi̍taṁ ya̱jñasya̍ de̱vam ṛ̱tvija̍m । 6 | 1.001.01c hotā̍raṁ ratna̱dhāta̍mam ॥ 7 | -------------------------------------------------------------------------------- /kokoro/README.md: -------------------------------------------------------------------------------- 1 | # kokoro build 2 | 3 | This directory contains all the logic for building Secure Shell releases in the 4 | kokoro continuous integration platform. 5 | It runs inside of the docker container (see [/Dockerfile]). 6 | This allows us to be isolated from the kokoro runtime and be nice & stable. 7 | 8 | The [./container] script uses docker to set up a runtime env that matches the 9 | kokoro environment. 10 | -------------------------------------------------------------------------------- /kokoro/kokoro.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Common kokoro util code.""" 7 | 8 | from pathlib import Path 9 | import sys 10 | 11 | 12 | DIR = Path(__file__).resolve().parent 13 | LIBAPPS_DIR = DIR.parent 14 | 15 | 16 | sys.path.insert(0, str(LIBAPPS_DIR / 'libdot' / 'bin')) 17 | 18 | # pylint: disable=unused-import 19 | import libdot # pylint: disable=wrong-import-position 20 | -------------------------------------------------------------------------------- /kokoro/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2020 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Lint our source files.""" 7 | 8 | from pathlib import Path 9 | import sys 10 | from typing import List 11 | 12 | import kokoro 13 | import libdot 14 | 15 | 16 | def _get_default_paths(basedir: Path) -> List[Path]: 17 | """Get list of paths to lint by default.""" 18 | kokoro_files = sorted(libdot.lint.get_known_sources(basedir)) 19 | 20 | # Our JS linters don't handle this atm. 21 | IGNORE_FILES = {'.eslintrc.js'} 22 | 23 | # Include files in the root dir as they have no other home. 24 | topdir = kokoro.LIBAPPS_DIR 25 | top_paths = libdot.run( 26 | ['git', 'ls-tree', '--name-only', '-z', 'HEAD'], cwd=topdir, 27 | capture_output=True, encoding='utf-8').stdout[:-1].split('\0') 28 | top_files = [topdir / x for x in top_paths 29 | if ((topdir / x).exists() and 30 | (topdir / x).is_file() and 31 | x not in IGNORE_FILES)] 32 | 33 | return top_files + kokoro_files 34 | 35 | 36 | def main(argv): 37 | """The main func!""" 38 | return libdot.lint.main(argv, basedir=kokoro.DIR, 39 | get_default_paths=_get_default_paths) 40 | 41 | 42 | if __name__ == '__main__': 43 | sys.exit(main(sys.argv[1:])) 44 | -------------------------------------------------------------------------------- /libdot/.gitignore: -------------------------------------------------------------------------------- 1 | # Stuff we build for distribution 2 | dist 3 | *.tar 4 | *.tgz 5 | *.min.js 6 | *.js.map 7 | 8 | /js/libdot.js 9 | 10 | # npm related dirs. 11 | node_modules 12 | -------------------------------------------------------------------------------- /libdot/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2009 The Chromium OS Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. Neither the name of Google Inc. nor the names of its 12 | contributors may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /libdot/README.md: -------------------------------------------------------------------------------- 1 | # libdot 2 | 3 | This is a small set of custom JS utility libraries initially developed as part 4 | of hterm, now available as shared code. It provides a base layer for web 5 | applications. The code is intended to work in any modern browser, in either a 6 | plain web page or a "privileged" environment such as a Chrome platform 7 | application or Firefox extension. In practice, it's only been put to use in 8 | Chrome extensions/platform applications so far. 9 | 10 | Overtime we'll probably convert these to newer JS standards, or replace with 11 | more common npm libraries. 12 | 13 | # Contact 14 | 15 | We re-use the existing hterm project resources for development & support. 16 | 17 | The [chromium-hterm mailing list] can be used to contact other users and 18 | developers for questions. 19 | 20 | Our existing set of bugs/feature requests can be found at 21 | . 22 | 23 | To file an actual report, you can use . This will route 24 | to the right people. 25 | 26 | # Mirrors & Packaging 27 | 28 | * https://chromium.googlesource.com/apps/libapps/+/HEAD/libdot: Main project site. 29 | * https://github.com/libapps/libdot: Mirror of just the libdot/ subdir. 30 | Updated from time to time by developers. 31 | * https://www.npmjs.com/package/libdot: Packaging for npm installs. 32 | 33 | # Documentation 34 | 35 | * [ChangeLog](./doc/ChangeLog.md) -- List of interesting changes in each release 36 | 37 | [chromium-hterm mailing list]: https://groups.google.com/a/chromium.org/forum/?fromgroups#!forum/chromium-hterm 38 | -------------------------------------------------------------------------------- /libdot/bin/.gitignore: -------------------------------------------------------------------------------- 1 | # Cached scripts 2 | /.png.crusher.* 3 | /.closure-compiler* 4 | /.cpplint.* 5 | -------------------------------------------------------------------------------- /libdot/bin/fetch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Simpler helper to download files.""" 7 | 8 | import os 9 | import sys 10 | 11 | import libdot 12 | 13 | 14 | def get_parser(): 15 | """Get a command line parser.""" 16 | parser = libdot.ArgumentParser(description=__doc__) 17 | parser.add_argument('--base64', action='store_true', 18 | help='Decode file using base64.') 19 | parser.add_argument('-o', '--output', type=str, 20 | help='Alternative path to save to.') 21 | parser.add_argument('args', nargs='+', 22 | help='URIs or files to download.') 23 | return parser 24 | 25 | 26 | def main(argv): 27 | """The main func!""" 28 | parser = get_parser() 29 | opts = parser.parse_args(argv) 30 | 31 | for uri in opts.args: 32 | output = opts.output 33 | if not output: 34 | output = os.path.basename(uri) 35 | libdot.fetch(uri, output, b64=opts.base64) 36 | 37 | 38 | if __name__ == '__main__': 39 | sys.exit(main(sys.argv[1:])) 40 | -------------------------------------------------------------------------------- /libdot/bin/mkdist: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Build the library deliverables.""" 7 | 8 | import argparse 9 | import os 10 | import sys 11 | 12 | import libdot 13 | 14 | 15 | def get_parser(): 16 | """Get a command line parser.""" 17 | parser = libdot.ArgumentParser( 18 | description=__doc__, 19 | formatter_class=argparse.RawDescriptionHelpFormatter) 20 | parser.add_argument('-o', '--output', 21 | default=os.path.join(libdot.DIR, 'js'), 22 | help='Output directory. (default: %(default)s)') 23 | return parser 24 | 25 | 26 | def main(argv): 27 | """The main func!""" 28 | parser = get_parser() 29 | opts = parser.parse_args(argv) 30 | 31 | # TODO(vapier): Move more logic out of package.json here, maybe? 32 | os.makedirs(opts.output, exist_ok=True) 33 | libdot.concat.concat( 34 | os.path.join(libdot.DIR, 'concat', 'libdot.concat'), 35 | os.path.join(opts.output, 'libdot.js')) 36 | 37 | 38 | if __name__ == '__main__': 39 | sys.exit(main(sys.argv[1:])) 40 | -------------------------------------------------------------------------------- /libdot/bin/npm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Run npm with the right settings.""" 7 | 8 | import sys 9 | 10 | import libdot 11 | 12 | 13 | def run(cmd, **kwargs): 14 | """Run the npm |cmd|.""" 15 | libdot.node.run(['npm'] + cmd, **kwargs) 16 | 17 | 18 | def main(argv): 19 | """The main func!""" 20 | libdot.setup_logging() 21 | libdot.node_and_npm_setup() 22 | run(argv) 23 | 24 | 25 | if __name__ == '__main__': 26 | sys.exit(main(sys.argv[1:])) 27 | -------------------------------------------------------------------------------- /libdot/bin/readlink: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2018 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """An alternate implementation of readlink that supports the non-standard -f. 7 | 8 | Note that this implementation of -f implies -m, but that shouldn't matter as 9 | readlink isn't used to find missing directories, only canonicalize paths. 10 | """ 11 | 12 | import os 13 | import sys 14 | 15 | import libdot 16 | 17 | 18 | def get_parser(): 19 | """Get a command line parser.""" 20 | parser = libdot.ArgumentParser(description=__doc__) 21 | parser.add_argument('-f', '--canonicalize', action='store_true', 22 | help='Canonicalize the paths.') 23 | parser.add_argument('paths', nargs='+', 24 | help='Paths to process.') 25 | return parser 26 | 27 | 28 | def main(argv): 29 | """The main func!""" 30 | parser = get_parser() 31 | opts = parser.parse_args(argv) 32 | for path in opts.paths: 33 | print(os.path.realpath(path)) 34 | 35 | 36 | if __name__ == '__main__': 37 | sys.exit(main(sys.argv[1:])) 38 | -------------------------------------------------------------------------------- /libdot/concat/libdot.concat: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | libdot/js/lib.js 6 | libdot/js/lib_polyfill.js 7 | libdot/js/lib_array.js 8 | libdot/js/lib_codec.js 9 | libdot/js/lib_colors.js 10 | libdot/js/lib_credential_cache.js 11 | libdot/js/lib_event.js 12 | libdot/js/lib_f.js 13 | libdot/js/lib_fs.js 14 | libdot/js/lib_i18n.js 15 | libdot/js/lib_message_manager.js 16 | libdot/js/lib_preference_manager.js 17 | libdot/js/lib_resource.js 18 | libdot/js/lib_storage.js 19 | libdot/js/lib_storage_chrome.js 20 | libdot/js/lib_storage_local.js 21 | libdot/js/lib_storage_memory.js 22 | libdot/js/lib_storage_terminal_private.js 23 | libdot/third_party/intl-segmenter/intl-segmenter.js 24 | libdot/third_party/wcwidth/lib_wc.js 25 | -------------------------------------------------------------------------------- /libdot/css/mocha-dark-theme.css: -------------------------------------------------------------------------------- 1 | @charset "utf-8"; 2 | 3 | /* 4 | * Copyright 2020 The Chromium OS Authors. All rights reserved. 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | /** 10 | * Apply a dark theme to the mocha html reporter. We don't update all colors, 11 | * just enough to go from white-on-black to black-on-white. 12 | */ 13 | 14 | body { 15 | background-color: black; 16 | color: white; 17 | } 18 | 19 | #mocha .test.pass .duration { 20 | color: #000; 21 | } 22 | 23 | #mocha .test.fail pre { 24 | color: white; 25 | } 26 | 27 | #mocha .test .html-error { 28 | color: white; 29 | } 30 | 31 | #mocha-stats em { 32 | color: white; 33 | } 34 | 35 | #mocha-stats canvas { 36 | filter: invert(1); 37 | } 38 | -------------------------------------------------------------------------------- /libdot/externs/.gitignore: -------------------------------------------------------------------------------- 1 | *chrome-*-v*.js 2 | *closure-*-v*.js 3 | -------------------------------------------------------------------------------- /libdot/externs/mocha.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Externs definitions for mocha. 7 | * 8 | * @externs 9 | */ 10 | 11 | /** @constructor */ 12 | function Mocha() {} 13 | 14 | /** @constructor */ 15 | Mocha.Runner = function() {}; 16 | 17 | /** @param {Error} err */ 18 | Mocha.Runner.prototype.uncaught = function(err) {}; 19 | 20 | var mocha = {}; 21 | 22 | mocha.checkLeaks = mocha.run = function() {}; 23 | 24 | /** @param {string|{globals:!Array}} opts */ 25 | mocha.setup = function(opts) {}; 26 | 27 | /** @param {function(function())} fn */ 28 | var after = function(fn) {}; 29 | 30 | /** @param {function(function())} fn */ 31 | var afterEach = function(fn) {}; 32 | 33 | /** @param {function(function())} fn */ 34 | var before = function(fn) {}; 35 | 36 | /** @param {function(function())} fn */ 37 | var beforeEach = function(fn) {}; 38 | 39 | /** 40 | * @param {string} name 41 | * @param {function()} fn 42 | */ 43 | var describe = function(name, fn) {}; 44 | 45 | /** 46 | * @param {string} name 47 | * @param {function(function())} fn 48 | */ 49 | var it = function(name, fn) {}; 50 | 51 | /** 52 | * @param {string} name 53 | * @param {function(function())} fn 54 | */ 55 | it.skip = function(name, fn) {} 56 | -------------------------------------------------------------------------------- /libdot/js/lib_array.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Helper functions for (typed) arrays. 9 | */ 10 | 11 | lib.array = {}; 12 | 13 | /** 14 | * Concatenate an arbitrary number of typed arrays of the same type into a new 15 | * typed array of this type. 16 | * 17 | * @template TYPED_ARRAY 18 | * @param {...!TYPED_ARRAY} arrays 19 | * @return {!TYPED_ARRAY} 20 | */ 21 | lib.array.concatTyped = function(...arrays) { 22 | let resultLength = 0; 23 | for (const array of arrays) { 24 | resultLength += array.length; 25 | } 26 | const result = new arrays[0].constructor(resultLength); 27 | let pos = 0; 28 | for (const array of arrays) { 29 | result.set(array, pos); 30 | pos += array.length; 31 | } 32 | return result; 33 | }; 34 | 35 | /** 36 | * Compare two array-like objects entrywise. 37 | * 38 | * @template ARRAY_LIKE 39 | * @param {?ARRAY_LIKE} a The first array to compare. 40 | * @param {?ARRAY_LIKE} b The second array to compare. 41 | * @return {boolean} true if both arrays are null or they agree entrywise; 42 | * false otherwise. 43 | */ 44 | lib.array.compare = function(a, b) { 45 | if (a === null || b === null) { 46 | return a === null && b === null; 47 | } 48 | 49 | if (a.length !== b.length) { 50 | return false; 51 | } 52 | 53 | for (let i = 0; i < a.length; i++) { 54 | if (a[i] !== b[i]) { 55 | return false; 56 | } 57 | } 58 | return true; 59 | }; 60 | -------------------------------------------------------------------------------- /libdot/js/lib_codec_tests.js: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Various codec test suites. 9 | */ 10 | 11 | describe('lib_codec_tests.js', () => { 12 | 13 | /** 14 | * Test code unit array conversions to strings. 15 | */ 16 | it('codeUnitArrayToString', () => { 17 | // Check default Array handling. 18 | assert.equal('asdf', lib.codec.codeUnitArrayToString([97, 115, 100, 102])); 19 | 20 | // Check typed array handling. 21 | const u8 = new Uint8Array([97, 115, 100, 102]); 22 | assert.equal('asdf', lib.codec.codeUnitArrayToString(u8)); 23 | 24 | // Check UTF-16 pairs. 25 | assert.equal('\u{1fadc}', lib.codec.codeUnitArrayToString([55358, 57052])); 26 | }); 27 | 28 | /** 29 | * Test string conversions to code unit arrays. 30 | */ 31 | it('stringToCodeUnitArray', () => { 32 | let ret; 33 | 34 | // Check default Uint8Array handling. 35 | ret = lib.codec.stringToCodeUnitArray('asdf'); 36 | assert.deepStrictEqual(new Uint8Array([97, 115, 100, 102]), ret); 37 | assert.isTrue(ArrayBuffer.isView(ret)); 38 | 39 | // Check UTF-16 pairs. 40 | const s = '\u{1fadc}'; 41 | ret = lib.codec.stringToCodeUnitArray(s, new Uint16Array(s.length)); 42 | assert.deepStrictEqual(new Uint16Array([55358, 57052]), ret); 43 | assert.isTrue(ArrayBuffer.isView(ret)); 44 | }); 45 | 46 | }); 47 | -------------------------------------------------------------------------------- /libdot/js/lib_event.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * An event is a JavaScript function with addListener and removeListener 9 | * properties. 10 | * 11 | * When the endpoint function is called, all of the listeners will be invoked 12 | * in the order they were attached. 13 | * 14 | * The returned function will have the list of callbacks as its 'observers' 15 | * property. 16 | * 17 | * @return {function(...*)} A function that, when called, invokes all callbacks 18 | * with whatever arguments it was passed. 19 | */ 20 | lib.Event = function() { 21 | const ep = function(...args) { 22 | ep.observers.forEach((callback) => callback.apply(null, args)); 23 | }; 24 | 25 | /** 26 | * Add a callback function. 27 | * 28 | * @param {function(...*)} callback The function to call back. 29 | */ 30 | ep.addListener = function(callback) { 31 | ep.observers.push(callback); 32 | }; 33 | 34 | /** 35 | * Remove a callback function. 36 | * 37 | * If the function is registered more than once (weird), all will be removed. 38 | * 39 | * @param {function(...*)} callback The function to remove. 40 | */ 41 | ep.removeListener = function(callback) { 42 | ep.observers = ep.observers.filter((cb) => cb !== callback); 43 | }; 44 | 45 | ep.observers = []; 46 | 47 | return ep; 48 | }; 49 | -------------------------------------------------------------------------------- /libdot/js/lib_polyfill.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Polyfills for ES2019+ features we want to use. 9 | * @suppress {duplicate} This file redefines many functions. 10 | */ 11 | 12 | /** @const */ 13 | lib.polyfill = {}; 14 | 15 | /** 16 | * https://developer.mozilla.org/en-US/docs/Web/API/Blob/arrayBuffer 17 | * 18 | * @return {!Promise} 19 | */ 20 | lib.polyfill.BlobArrayBuffer = function() { 21 | return new Promise((resolve, reject) => { 22 | const reader = new FileReader(); 23 | reader.onload = () => resolve(reader.result); 24 | reader.onabort = reader.onerror = () => reject(reader); 25 | reader.readAsArrayBuffer(this); 26 | }); 27 | }; 28 | 29 | if (typeof Blob.prototype.arrayBuffer != 'function') { 30 | Blob.prototype.arrayBuffer = lib.polyfill.BlobArrayBuffer; 31 | } 32 | 33 | /** 34 | * https://developer.mozilla.org/en-US/docs/Web/API/Blob/text 35 | * 36 | * @return {!Promise} 37 | */ 38 | lib.polyfill.BlobText = function() { 39 | return new Promise((resolve, reject) => { 40 | const reader = new FileReader(); 41 | reader.onload = () => resolve(reader.result); 42 | reader.onabort = reader.onerror = () => reject(reader); 43 | reader.readAsText(this); 44 | }); 45 | }; 46 | 47 | if (typeof Blob.prototype.arrayBuffer != 'function') { 48 | Blob.prototype.text = lib.polyfill.BlobText; 49 | } 50 | -------------------------------------------------------------------------------- /libdot/js/lib_preference_manager_tests.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Unit tests for lib.PreferenceManager. 9 | */ 10 | 11 | describe('lib_preference_manager_tests.js', () => { 12 | 13 | /** 14 | * If another window changes a preference to the default it will delete the 15 | * localStorage entry. Here we mock the deleting of a localStorage entry so we 16 | * can test the window correctly return the default value. 17 | */ 18 | it('local-delete-default', (done) => { 19 | const storage = new lib.Storage.Local(); 20 | const preferenceManager = new lib.PreferenceManager(storage); 21 | const defaultColor = 'red'; 22 | 23 | preferenceManager.definePreference('color', defaultColor, function(value) { 24 | assert.strictEqual(value, defaultColor); 25 | done(); 26 | }); 27 | 28 | // Fake current value is 'blue'. 29 | preferenceManager.prefRecords_['color'].currentValue = 'blue'; 30 | 31 | /** 32 | * Workaround bad extern in closure. cl/307771888 33 | * 34 | * @suppress {checkTypes} 35 | * @return {!StorageEvent} 36 | */ 37 | function newEvent() { 38 | return new StorageEvent('storage', { 39 | storageArea: window.localStorage, 40 | key: '/color', 41 | oldValue: JSON.stringify('blue'), 42 | newValue: null, 43 | }); 44 | } 45 | // Simpulate deleting the key on another browser. 46 | const event = newEvent(); 47 | window.dispatchEvent(event); 48 | }); 49 | 50 | }); 51 | -------------------------------------------------------------------------------- /libdot/js/lib_storage_local_tests.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Test suite for local storage. 9 | */ 10 | 11 | describe('lib_storage_local_tests.js', () => { 12 | 13 | /** 14 | * Initialize the storage fakes & APIs. 15 | */ 16 | beforeEach(function() { 17 | // Make sure other/previous tests don't leak. 18 | window.sessionStorage.clear(); 19 | 20 | this.storage = new lib.Storage.Local(window.sessionStorage); 21 | }); 22 | 23 | lib.Storage.ApiTest(); 24 | 25 | }); 26 | -------------------------------------------------------------------------------- /libdot/js/lib_storage_memory_tests.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Test suite for memory storage. 9 | */ 10 | 11 | describe('lib_storage_memory_tests.js', () => { 12 | 13 | /** 14 | * Initialize the storage fakes & APIs. 15 | */ 16 | beforeEach(function() { 17 | this.storage = new lib.Storage.Memory(); 18 | }); 19 | 20 | lib.Storage.ApiTest(); 21 | 22 | }); 23 | -------------------------------------------------------------------------------- /libdot/js/lib_test.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Test framework setup when run inside the browser. 9 | */ 10 | 11 | // Setup the mocha framework. 12 | mocha.setup('bdd'); 13 | mocha.checkLeaks(); 14 | 15 | // Add a global shortcut to the assert API. 16 | const assert = chai.assert; 17 | 18 | // Catch any random errors before the test runner runs. 19 | let earlyError = null; 20 | /** 21 | * Catch any errors. 22 | * 23 | * @param {*} args Whatever arguments are passed in. 24 | */ 25 | window.onerror = function(...args) { 26 | earlyError = Array.from(args); 27 | }; 28 | 29 | /** Run the test framework once everything is finished. */ 30 | window.onload = async function() { 31 | await lib.init(); 32 | mocha.run(); 33 | 34 | if (earlyError !== null) { 35 | assert.fail(`uncaught exception detected:\n${earlyError.join('\n')}\n`); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /libdot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libdot", 3 | "version": "8.0.0", 4 | "description": "Grab bag of JS utility libraries", 5 | "main": "js/libdot.js", 6 | "unpkg": "js/libdot.min.js", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://chromium.googlesource.com/apps/libapps.git" 10 | }, 11 | "author": "Chromium OS Authors", 12 | "license": "BSD-3-Clause", 13 | "files": [ 14 | "README.md", 15 | "js/libdot.js", 16 | "js/libdot.min.js", 17 | "js/libdot.min.js.map" 18 | ], 19 | "bugs": { 20 | "url": "https://goo.gl/vb94JY", 21 | "email": "chromium-hterm@chromium.org" 22 | }, 23 | "homepage": "https://chromium.googlesource.com/apps/libapps/+/HEAD/libdot", 24 | "scripts": { 25 | "prepare": "./bin/mkdist && cd js && terser libdot.js --compress --mangle --output libdot.min.js --source-map url=libdot.min.js.map,includeSources", 26 | "test": "./bin/load_tests" 27 | }, 28 | "devDependencies": { 29 | "chai": "~4", 30 | "eslint": "~7", 31 | "mocha": "~8", 32 | "mocha-headless-chrome": "~3", 33 | "terser": "~4" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /libdot/third_party/intl-segmenter/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Joshua Bell All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright notice, 9 | this list of conditions and the following disclaimer in the documentation 10 | and/or other materials provided with the distribution. 11 | 3. Neither the name of the copyright holder nor the names of its contributors 12 | may be used to endorse or promote products derived from this software 13 | without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /libdot/third_party/intl-segmenter/METADATA: -------------------------------------------------------------------------------- 1 | name: "proposal-intl-segmenter" 2 | description: "Polyfill for Intl.Segmenter" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://github.com/tc39/proposal-intl-segmenter" 8 | } 9 | last_upgrade_date { year: 2019 month: 1 day: 1 } 10 | } 11 | -------------------------------------------------------------------------------- /libdot/third_party/intl-segmenter/README.md: -------------------------------------------------------------------------------- 1 | Polyfill from https://github.com/tc39/proposal-intl-segmenter 2 | -------------------------------------------------------------------------------- /libdot/third_party/wcwidth/.gitignore: -------------------------------------------------------------------------------- 1 | /EastAsianWidth.txt 2 | /PropList.txt 3 | /UCD*.zip 4 | /UnicodeData.txt 5 | -------------------------------------------------------------------------------- /libdot/third_party/wcwidth/METADATA: -------------------------------------------------------------------------------- 1 | name: "wcwidth.js" 2 | description: "A JavaScript port of C's wcwidth() to libdot" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "http://code.woong.org/wcwidth.js" 8 | } 9 | url { 10 | type: HOMEPAGE 11 | value: "https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c" 12 | } 13 | url { 14 | type: GIT 15 | value: "https://github.com/mycoboco/wcwidth.js" 16 | } 17 | version: "0.0.3" 18 | last_upgrade_date { year: 2013 month: 12 day: 30 } 19 | 20 | local_modifications: 21 | "This started out with wcwidth.js, but has been heavily customized and" 22 | "extended since. That includes new features, bug fixes, and integrating" 23 | "with the libdot framework." 24 | "At this point, the code base is very different from upstream." 25 | } 26 | -------------------------------------------------------------------------------- /libdot/third_party/wcwidth/README.md: -------------------------------------------------------------------------------- 1 | This is a port of wcwidth.js (which is a port of wcwidth implemented in C by 2 | Markus Kuhn) to the libdot framework. 3 | 4 | Upstream details can be found in the METADATA file. 5 | 6 | Licensing details can be found in the LICENSE.md file. 7 | 8 | ## Updating 9 | 10 | When a new [Unicode release](https://www.unicode.org/versions/latest/) is made, 11 | it might contain new combining and wide characters, so we'll need to update our 12 | tables. 13 | 14 | You'll first want to grab the latest Unicode release. It's easiest to grab 15 | the entire archive (it's small) and then extract the few files you want. 16 | THe helper script can download & extract the latest files: 17 | ``` 18 | $ ./ranges.py download 19 | ``` 20 | 21 | Then use the helper script to update the tables in [lib_wc.js](./lib_wc.js). 22 | ``` 23 | $ ./ranges.py update 24 | ``` 25 | 26 | Now you'll double check the update to make sure things look sane. G'luck! 27 | -------------------------------------------------------------------------------- /nassh/.gitignore: -------------------------------------------------------------------------------- 1 | # Bundled dependencies 2 | js/*.concat.js 3 | js/*.rollup.js 4 | 5 | # Generated HTML files. 6 | /html/changelog.html 7 | /html/licenses.html 8 | 9 | # Copy of the nacl plugin used when loading as an unpacked extension 10 | /_platform_specific/ 11 | /plugin/ 12 | 13 | # Stuff we build for distribution 14 | /dist 15 | /fonts 16 | /nassh-*.tgz 17 | 18 | # npm related dirs. 19 | node_modules 20 | -------------------------------------------------------------------------------- /nassh/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2009 The Chromium OS Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. Neither the name of Google Inc. nor the names of its 12 | contributors may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /nassh/bin/fonts_create_bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2020 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Update our nassh fonts bundle. See ../doc/fonts.md.""" 7 | 8 | import logging 9 | import os 10 | import sys 11 | 12 | import nassh 13 | import libdot 14 | 15 | 16 | def get_parser(): 17 | """Get a command line parser.""" 18 | parser = libdot.ArgumentParser(description=__doc__) 19 | return parser 20 | 21 | 22 | def main(argv): 23 | """The main func!""" 24 | parser = get_parser() 25 | _opts = parser.parse_args(argv) 26 | 27 | tar = nassh.LIBAPPS_DIR / 'fonts.tar.xz' 28 | 29 | libdot.pack(tar, ['fonts'], exclude=['fonts/.hash'], cwd=nassh.DIR) 30 | 31 | new_hash = libdot.sha256(tar) 32 | final_tar = nassh.LIBAPPS_DIR / f'fonts-{new_hash}.tar.xz' 33 | os.rename(tar, final_tar) 34 | 35 | logging.info( 36 | 'To update the hash, run:\n' 37 | "sed -i \"/^FONTS_HASH *=/s:=.*:= '%s':\" '%s/fonts'", 38 | new_hash, nassh.BIN_DIR) 39 | logging.info('To upload the new fonts:\ngsutil cp -a public-read %s %s/', 40 | final_tar, nassh.fonts.FONTS_GS_URI) 41 | 42 | 43 | if __name__ == '__main__': 44 | sys.exit(main(sys.argv[1:])) 45 | -------------------------------------------------------------------------------- /nassh/bin/load_tests: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Run unittests in a new browser.""" 7 | 8 | import os 9 | import sys 10 | 11 | import nassh 12 | import libdot 13 | 14 | 15 | # Path to our html test page. 16 | TEST_PAGE = os.path.join('nassh', 'html', 'nassh_test.html') 17 | 18 | 19 | def main(argv): 20 | """The main func!""" 21 | return libdot.load_tests.test_runner_main( 22 | argv, TEST_PAGE, serve=True, mkdeps=lambda opts: nassh.mkdeps.mkdeps()) 23 | 24 | 25 | if __name__ == '__main__': 26 | sys.exit(main(sys.argv[1:])) 27 | -------------------------------------------------------------------------------- /nassh/bin/nassh.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2018 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Common nassh util code.""" 7 | 8 | from pathlib import Path 9 | import sys 10 | 11 | 12 | BIN_DIR = Path(__file__).resolve().parent 13 | DIR = BIN_DIR.parent 14 | LIBAPPS_DIR = DIR.parent 15 | 16 | 17 | sys.path.insert(0, str(LIBAPPS_DIR / 'libdot' / 'bin')) 18 | 19 | # pylint: disable=unused-import 20 | import libdot # pylint: disable=wrong-import-position 21 | 22 | 23 | # Wrappers around nassh/bin/ programs for other tools to access directly. 24 | class HelperProgram(libdot.HelperProgram): 25 | """Avoid copying & pasting BIN_DIR setting.""" 26 | _BIN_DIR = BIN_DIR 27 | 28 | generate_changelog = HelperProgram('generate-changelog') 29 | fonts = HelperProgram('fonts') 30 | mkdeps = HelperProgram('mkdeps') 31 | -------------------------------------------------------------------------------- /nassh/concat/nassh_deps.concat: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | @include hterm/concat/hterm_deps.concat 6 | @include hterm/concat/hterm.concat 7 | 8 | @file libdot/js/lib_codec.js 9 | @file libdot/js/lib_credential_cache.js 10 | @file libdot/js/lib_event.js 11 | @file libdot/js/lib_fs.js 12 | 13 | @resource nassh/images/visibility image/svg+xml;utf8 < ../images/visibility.svg 14 | @resource nassh/images/visibility_off image/svg+xml;utf8 < ../images/visibility_off.svg 15 | 16 | @resource nassh/release/lastver text/plain head -1 release-highlights.txt 17 | @resource nassh/release/highlights text/plain grep ^% release-highlights.txt 18 | -------------------------------------------------------------------------------- /nassh/concat/release-highlights.txt: -------------------------------------------------------------------------------- 1 | 0.34 2 | 3 | # The first line tracks the last version that went stable. 4 | # Only features added since then should be kept here. 5 | # When a new version has gone stable, update the version above, 6 | # and delete all the old release notes below. 7 | 8 | # The lines below that start with % will be the actual notes. 9 | # The % symbol is used to split lines. 10 | # Only list significant changes that matter to the user. 11 | # The more lines that we have here, the more cluttered the output. 12 | 13 | # release: 0.35 (stable Sep 11) 14 | % Enable connection resume for Google corp-relay-v4 users. 15 | 16 | # release: 0.36 (stable Nov 11) 17 | % \x1b]8;;https://www.openssh.com/txt/release-8.4\x07OpenSSH upgraded to 8.4p1\x1b]8;;\x07. 18 | 19 | # release: 0.37 20 | % Alpha integration of \x1b]8;;https://github.com/rpwoodbu/mosh-chrome\x07Mosh for Chrome\x1b]8;;\x07. 21 | -------------------------------------------------------------------------------- /nassh/css/nassh_box.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 3 | * Use of this source code is governed by a BSD-style license that can be 4 | * found in the LICENSE file. 5 | */ 6 | 7 | /** 8 | * Utility css to make box layout easier to specify. 9 | * 10 | * Treats ... and ... as horizontal and 11 | * vertical boxes. Also allows attributes, for times when 12 | * some specific tag behavior is important. 13 | */ 14 | 15 | *[x-box] { 16 | display: flex; 17 | flex: 0 0 auto; 18 | } 19 | 20 | x-vbox, *[x-vbox] { 21 | display: flex; 22 | flex-direction: column; 23 | flex: 0 0 auto; 24 | } 25 | 26 | x-hbox, *[x-hbox] { 27 | display: flex; 28 | flex-direction: row; 29 | flex: 0 0 auto; 30 | } 31 | 32 | *[x-flex="1"] { flex: 1 0% } 33 | *[x-flex="2"] { flex: 2 0% } 34 | *[x-flex="3"] { flex: 3 0% } 35 | *[x-flex="4"] { flex: 4 0% } 36 | 37 | *[x-pack="center"] { justify-content: center } 38 | *[x-pack="start"] { justify-content: flex-start } 39 | *[x-pack="end"] { justify-content: flex-end } 40 | 41 | *[x-align="center"] { align-items: center } 42 | *[x-align="baseline"] { align-items: baseline } 43 | -------------------------------------------------------------------------------- /nassh/css/nassh_sftp_fsp_config_dialog.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Chromium OS Authors. All rights reserved. 3 | * Use of this source code is governed by a BSD-style license that can be 4 | * found in the LICENSE file. 5 | */ 6 | 7 | /** 8 | * Styles used by the config dialog box. 9 | */ 10 | 11 | /* Default colors here will be updated on the fly. */ 12 | :root { 13 | --nassh-bg-color: rgb(16, 16, 16); 14 | --nassh-fg-color: rgb(240, 240, 240); 15 | --nassh-cursor-color: rgba(255, 0, 0, 0.5); 16 | } 17 | 18 | body { 19 | margin: 0; 20 | padding: 0.5em; 21 | background-color: var(--nassh-bg-color); 22 | color: var(--nassh-fg-color); 23 | font-family: courier; 24 | font-size: smaller; 25 | } 26 | 27 | input, select { 28 | border: 1px solid; 29 | padding: 3px; 30 | line-height: 1.2; 31 | font-size: inherit; 32 | font-family: inherit; 33 | margin: 0.25em; 34 | background-color: rgba(255, 255, 255, 0.95); /* yes, white */ 35 | } 36 | 37 | .aligned-dialog-labels { 38 | text-align: right; 39 | display: block; 40 | white-space: nowrap; 41 | } 42 | -------------------------------------------------------------------------------- /nassh/doc/AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors & Maintainers & Contributors 2 | 3 | This is part of the Chromium OS project. 4 | 5 | Please do not use this list to contact authors. We have a mailing list for 6 | discussions. See the [README.md](../README.md#Contact) file for details. 7 | 8 | ## Maintainers 9 | 10 | The current maintainers: 11 | 12 | * Rob Ginda : Original author and visionary extraordinaire 13 | * Mike Frysinger : Likes to throw things at the wall until they stick 14 | 15 | The past maintainers: 16 | 17 | * Dmitry Polukhin : NaCl OpenSSH port & integration 18 | 19 | ## Contributors 20 | 21 | If you want to throw your name in here after having one of your CLs merged, 22 | feel free! If the work is a bit more significant, feel free to list that too. 23 | 24 | The list is sorted alphabetically by last name. 25 | 26 | * Toni Barzic 27 | * David Benjamin 28 | * Brandon Gilmore 29 | * Connor Hegarty 30 | * Fabian Henneke : SSH agent & OpenPGP card support 31 | * Joel Hockey 32 | * Nikolay Igotti 33 | * Mitchell McDermott : SFTP mounting/integration 34 | * Renaud Paquay 35 | * Tyler Pirtle 36 | * Marius Schilder 37 | * Rob Spies 38 | * Ben Smith 39 | * Richard Woodbury : Mosh port. 40 | -------------------------------------------------------------------------------- /nassh/externs/asn1.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Minimal externs definitions for asn1js as used in nassh. 7 | * 8 | * @externs 9 | */ 10 | 11 | var asn1js$$module$js$nassh_deps_rollup = {}; 12 | 13 | /** 14 | * @param {!ArrayBuffer} buffer 15 | * @return {{offset: number, result: !BaseBlock}} 16 | */ 17 | asn1js$$module$js$nassh_deps_rollup.fromBER = function(buffer) {}; 18 | 19 | class BaseBlock { 20 | constructor() { 21 | /** @type {!ValueBlock} */ 22 | this.valueBlock; 23 | } 24 | /** 25 | * @param {boolean=} sizeOnly 26 | * @return {!ArrayBuffer} 27 | */ 28 | toBER(sizeOnly = false) {} 29 | } 30 | 31 | class ValueBlock { 32 | constructor() { 33 | /** @type {!ArrayBuffer} */ 34 | this.valueHex; 35 | /** @type {!Array} */ 36 | this.value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /nassh/externs/pki.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Minimal externs definitions for pkijs as used in nassh. 7 | * 8 | * @externs 9 | */ 10 | 11 | var pkijs$$module$js$nassh_deps_rollup = {}; 12 | pkijs$$module$js$nassh_deps_rollup.Certificate = Certificate; 13 | pkijs$$module$js$nassh_deps_rollup.RSAPublicKey = RSAPublicKey; 14 | 15 | class AlgorithmIdentifier { 16 | constructor() { 17 | /** @type {string} */ 18 | this.algorithmId; 19 | /** @type {!BaseBlock} */ 20 | this.algorithmParams; 21 | } 22 | } 23 | 24 | class Certificate { 25 | /** @param {{schema: !BaseBlock}} asn1Result */ 26 | constructor(asn1Result) { 27 | /** @type {!PublicKeyInfo} */ 28 | this.subjectPublicKeyInfo; 29 | } 30 | } 31 | 32 | class PublicKeyInfo { 33 | constructor() { 34 | /** @type {!AlgorithmIdentifier} */ 35 | this.algorithm; 36 | /** @type {!BaseBlock} */ 37 | this.subjectPublicKey; 38 | } 39 | /** @return {!BaseBlock} */ 40 | toSchema() {} 41 | } 42 | 43 | class RSAPublicKey { 44 | /** @param {{schema: !BaseBlock}} asn1Result */ 45 | constructor(asn1Result) { 46 | /** @type {!BaseBlock} */ 47 | this.modulus; 48 | /** @type {!BaseBlock} */ 49 | this.publicExponent; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /nassh/externs/punycode.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Externs definitions for punycode used in nassh. 7 | * 8 | * @externs 9 | */ 10 | 11 | var punycode$$module$js$nassh_deps_rollup = {}; 12 | 13 | /** 14 | * @param {string} input 15 | * @return {string} 16 | */ 17 | punycode$$module$js$nassh_deps_rollup.toASCII = function(input) {}; 18 | -------------------------------------------------------------------------------- /nassh/html/changelog.html.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ChangeLog Since %%TAG%% 6 | 7 | 8 | 13 | 14 | 15 | 16 |

Online ChangeLogs

17 | 23 | 24 |

ChangeLog (since %%TAG%%)

25 | %%COMMITS%% 26 | 27 | 28 | -------------------------------------------------------------------------------- /nassh/html/crosh.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 28 | crosh 29 | 30 | 31 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /nassh/html/licenses.html.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 41 | 42 | 43 |

44 | %%LICENSES%% 45 | 46 | 47 | -------------------------------------------------------------------------------- /nassh/html/nassh_google_relay.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Internal Secure Shell error. 38 | 39 |
40 |
41 | 42 |
43 | 44 | 45 | 46 | Relay server error. 47 | Please contact your relay server administrator for assistance. 48 | 49 |
50 |
51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /nassh/html/nassh_popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Secure Shell Extension Popup 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /nassh/images/README.md: -------------------------------------------------------------------------------- 1 | # Images 2 | 3 | To quickly convert the SVG's to PNG's, use `inkscape`: 4 | ```bash 5 | $ s=64 6 | $ inkscape -h $s -w $s -e icon-$s.png icon-48.svg 7 | 8 | $ s=256 9 | $ inkscape -h $s -w $s -e icon-$s.png icon-512.svg 10 | ``` 11 | 12 | When adding new files here, make sure to crush them first. 13 | You can use [libdot/bin/imgcrush](/libdot/bin/imgcrush) to do so losslessly. 14 | -------------------------------------------------------------------------------- /nassh/images/dev/crostini-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/dev/crostini-192.png -------------------------------------------------------------------------------- /nassh/images/dev/crostini-fullsize.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/dev/crostini-fullsize.webp -------------------------------------------------------------------------------- /nassh/images/dev/icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/dev/icon-128.png -------------------------------------------------------------------------------- /nassh/images/dev/icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/dev/icon-16.png -------------------------------------------------------------------------------- /nassh/images/dev/icon-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/dev/icon-24.png -------------------------------------------------------------------------------- /nassh/images/dev/icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/dev/icon-32.png -------------------------------------------------------------------------------- /nassh/images/dev/icon-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/dev/icon-48.png -------------------------------------------------------------------------------- /nassh/images/dev/icon-fullsize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/dev/icon-fullsize.png -------------------------------------------------------------------------------- /nassh/images/promo-440.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/promo-440.png -------------------------------------------------------------------------------- /nassh/images/promo-920.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/promo-920.png -------------------------------------------------------------------------------- /nassh/images/screenshot-icon-640.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/screenshot-icon-640.png -------------------------------------------------------------------------------- /nassh/images/screenshot-light-640.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/screenshot-light-640.png -------------------------------------------------------------------------------- /nassh/images/screenshot-nethack-640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/screenshot-nethack-640.jpg -------------------------------------------------------------------------------- /nassh/images/screenshot-osc-1337-640.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/screenshot-osc-1337-640.png -------------------------------------------------------------------------------- /nassh/images/screenshot-split-screen-640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/screenshot-split-screen-640.jpg -------------------------------------------------------------------------------- /nassh/images/screenshot-vim-source-640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/screenshot-vim-source-640.jpg -------------------------------------------------------------------------------- /nassh/images/screenshot-wargames-640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/screenshot-wargames-640.jpg -------------------------------------------------------------------------------- /nassh/images/screenshot-zork-640.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/screenshot-zork-640.png -------------------------------------------------------------------------------- /nassh/images/stable/icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/stable/icon-128.png -------------------------------------------------------------------------------- /nassh/images/stable/icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/stable/icon-16.png -------------------------------------------------------------------------------- /nassh/images/stable/icon-16.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /nassh/images/stable/icon-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/stable/icon-24.png -------------------------------------------------------------------------------- /nassh/images/stable/icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/stable/icon-32.png -------------------------------------------------------------------------------- /nassh/images/stable/icon-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/nassh/images/stable/icon-48.png -------------------------------------------------------------------------------- /nassh/images/stable/icon-48.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /nassh/images/stable/icon-512.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 33 | 34 | 36 | SSH 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /nassh/images/visibility.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /nassh/images/visibility_off.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /nassh/js/chrome_mock_for_test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Stub Chrome APIs for tests. 9 | */ 10 | 11 | /** @suppress {constantProperty} Allow tests in browsers. */ 12 | globalThis.chrome = globalThis.chrome || {}; 13 | 14 | class FspEventTarget { 15 | /** @param {!Function} method */ 16 | addListener(method) {} 17 | } 18 | 19 | /** @suppress {checkTypes,constantProperty} */ 20 | chrome.fileSystemProvider = { 21 | onCloseFileRequested: new FspEventTarget(), 22 | onConfigureRequested: new FspEventTarget(), 23 | onCopyEntryRequested: new FspEventTarget(), 24 | onCreateDirectoryRequested: new FspEventTarget(), 25 | onCreateFileRequested: new FspEventTarget(), 26 | onDeleteEntryRequested: new FspEventTarget(), 27 | onGetMetadataRequested: new FspEventTarget(), 28 | onMountRequested: new FspEventTarget(), 29 | onMoveEntryRequested: new FspEventTarget(), 30 | onOpenFileRequested: new FspEventTarget(), 31 | onReadDirectoryRequested: new FspEventTarget(), 32 | onReadFileRequested: new FspEventTarget(), 33 | onTruncateRequested: new FspEventTarget(), 34 | onUnmountRequested: new FspEventTarget(), 35 | onWriteFileRequested: new FspEventTarget(), 36 | 37 | unmount: function(options, callback) {}, 38 | 39 | /** @type {!chrome.fileSystemProvider.ProviderError} */ 40 | ProviderError: { 41 | FAILED: 'FAILED', 42 | INVALID_OPERATION: 'INVALID_OPERATION', 43 | NOT_FOUND: 'NOT_FOUND', 44 | }, 45 | }; 46 | -------------------------------------------------------------------------------- /nassh/js/licenses.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * CSP means that we can't kick off the initialization from the html file, 9 | * so we do it like this instead. 10 | */ 11 | window.addEventListener('DOMContentLoaded', (event) => { 12 | nassh.setupForWebApp(); 13 | lib.init().then(() => { 14 | hterm.messageManager.processI18nAttributes(document); 15 | }); 16 | 17 | document.body.querySelectorAll('h2.package').forEach((ele) => { 18 | ele.onclick = toggle; 19 | }); 20 | }); 21 | 22 | /** 23 | * Toggle display of the associated license data. 24 | * 25 | * @this {Element} 26 | */ 27 | function toggle() { 28 | const id = this.id.replace(/^[^-]*-/, ''); 29 | const ele = document.getElementById(`license-${id}`); 30 | ele.style.display = ele.style.display ? '' : 'block'; 31 | } 32 | -------------------------------------------------------------------------------- /nassh/js/nasftp.js: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Core SFTP logic. 9 | */ 10 | const nasftp = {}; 11 | -------------------------------------------------------------------------------- /nassh/js/nassh_agent_tests.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Test suite for the generic SSH agent in nassh.agent.Agent. 9 | */ 10 | 11 | describe('nassh_agent_tests.js', () => { 12 | 13 | it('keyBlobToAuthorizedKeysFormat', () => { 14 | const asciiToBinary = (str) => { 15 | return lib.codec.stringToCodeUnitArray(atob(str)); 16 | }; 17 | 18 | // eslint-disable-next-line 19 | const keyTypeRsa = 'AAAAB3NzaC1yc2EAAAADAQABAAABAQC3sp7nkdZlKZwNlbtotfGexMf8UJO+Z/s5DCHCc34iOx6ffQgnBpcQEv+WHU8e2Ha+l3FxgBRIi9uaAT8hLNY+BrG8UsGhBDxJPmazL2yovkBI3m8LpOdlCM25DJBybMEM8A91DqPe34bGZk3UHad61IPt9TD/WR863IlwhCLHxZuxTBwhfm3U435EbO4k8XRUbL75P9O00nBsaPy0O7mxZVH3VcKd2RxX58v8l/BhfgKq5PkRDS3I4uMafxObjTPSe/HuZxlBH4EMJvrXZE31hgcv2Cp2QKGyvH3yDW0nIRwBnbGyyaErbiPEq9gxv0urTowo5JdWI67I4LQsmWLr'; 20 | const keyTypeEd25519 = 21 | 'AAAAC3NzaC1lZDI1NTE5AAAAIKsEa2RL2X0d3L3CA9uwTbqQvJfVjIEEJzH/i8lpWkNq'; 22 | 23 | assert.equal( 24 | nassh.agent.Agent.keyBlobToAuthorizedKeysFormat( 25 | asciiToBinary(keyTypeRsa)), 26 | 'ssh-rsa ' + keyTypeRsa); 27 | assert.equal( 28 | nassh.agent.Agent.keyBlobToAuthorizedKeysFormat( 29 | asciiToBinary(keyTypeEd25519)), 30 | 'ssh-ed25519 ' + keyTypeEd25519); 31 | }); 32 | 33 | }); 34 | -------------------------------------------------------------------------------- /nassh/js/nassh_buffer_concat.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Basic buffer that concats inputs together. 9 | */ 10 | 11 | /** 12 | * A very simple buffer that concats inputs together. 13 | */ 14 | nassh.buffer.Concat = class extends nassh.buffer.Interface { 15 | /** @inheritDoc */ 16 | constructor(autoack = false) { 17 | super(autoack); 18 | this.buffer_ = new Uint8Array(0); 19 | this.readPos_ = 0; 20 | } 21 | 22 | /** @inheritDoc */ 23 | write(buffer) { 24 | const u8 = new Uint8Array(buffer); 25 | this.buffer_ = lib.array.concatTyped(this.buffer_, u8); 26 | this.unreadCount_ += u8.length; 27 | } 28 | 29 | /** @inheritDoc */ 30 | read(length) { 31 | const ret = this.buffer_.subarray(this.readPos_, this.readPos_ + length); 32 | this.readPos_ += ret.length; 33 | if (this.autoack_) { 34 | this.ack(ret.length); 35 | } 36 | this.unreadCount_ -= ret.length; 37 | return ret; 38 | } 39 | 40 | /** @inheritDoc */ 41 | ack(length) { 42 | this.buffer_ = this.buffer_.subarray(length); 43 | this.readPos_ -= length; 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /nassh/js/nassh_buffer_concat_tests.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview nassh.buffer.Concat tests. 9 | */ 10 | 11 | describe('nassh_buffer_concat_tests.js', () => { 12 | 13 | /** 14 | * Internal buffer inspector. 15 | */ 16 | class BufferInspector extends nassh.buffer.Inspector { 17 | /** @inheritDoc */ 18 | getUnackedCount() { 19 | return this.buffer.buffer_.length; 20 | } 21 | } 22 | 23 | nassh.buffer.ApiTest('concat', BufferInspector); 24 | 25 | }); 26 | -------------------------------------------------------------------------------- /nassh/js/nassh_buffer_scatgat_tests.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview nassh.buffer.ScatGat tests. 9 | */ 10 | 11 | describe('nassh_buffer_scatgat_tests.js', () => { 12 | 13 | /** 14 | * Internal buffer inspector. 15 | */ 16 | class BufferInspector extends nassh.buffer.Inspector { 17 | /** @inheritDoc */ 18 | getUnackedCount() { 19 | let ret = this.buffer.getUnreadCount(); 20 | let pos = this.buffer.ackPos_; 21 | let off = this.buffer.ackOffset_; 22 | while (pos <= this.buffer.readPos_) { 23 | if (pos === this.buffer.readPos_) { 24 | ret += (this.buffer.readOffset_ - off); 25 | } else { 26 | const curr = this.buffer.queue_[pos]; 27 | ret += (curr.length - off); 28 | off = 0; 29 | } 30 | ++pos; 31 | } 32 | return ret; 33 | } 34 | } 35 | 36 | nassh.buffer.ApiTest('scatgat', BufferInspector); 37 | 38 | }); 39 | -------------------------------------------------------------------------------- /nassh/js/nassh_preferences_protocol_register.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Protocol registration helper dialog. 9 | */ 10 | 11 | /** 12 | * Container for all the dialog settings. 13 | */ 14 | nassh.ProtocolRegisterDialog = {}; 15 | 16 | /** 17 | * Attempt to register all the protocols we support. 18 | */ 19 | nassh.ProtocolRegisterDialog.register = function() { 20 | nassh.registerProtocolHandler('ssh'); 21 | nassh.registerProtocolHandler('sftp'); 22 | }; 23 | 24 | /** 25 | * Open the browser handlers settings page. 26 | */ 27 | nassh.ProtocolRegisterDialog.openSettings = function() { 28 | // NB: We have to use chrome.tabs.create rather than window.open as Chrome 29 | // blocks chrome:// URIs with the latter API. 30 | chrome.tabs.create({url: 'chrome://settings/handlers'}); 31 | }; 32 | 33 | /** 34 | * Event when the window finishes loading. 35 | */ 36 | window.addEventListener('DOMContentLoaded', (event) => { 37 | document.getElementById('proto-register').onclick = 38 | nassh.ProtocolRegisterDialog.register; 39 | document.getElementById('proto-open-settings').onclick = 40 | nassh.ProtocolRegisterDialog.openSettings; 41 | }); 42 | -------------------------------------------------------------------------------- /nassh/js/nassh_relay_sshfe.js: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Implementation for the ssh-fe@google.com proxy. 9 | */ 10 | 11 | /** 12 | * SSH-FE relay implementation. 13 | */ 14 | nassh.relay.Sshfe = class extends nassh.Relay { 15 | /** @inheritDoc */ 16 | constructor(io, options, location, storage) { 17 | super(io, options, location, storage); 18 | this.sshAgent_ = options['--ssh-agent'] || 19 | nassh.goog.gnubby.defaultExtension; 20 | this.relayServer = `wss://${this.proxyHost}:${this.proxyPort}`; 21 | } 22 | 23 | /** @inheritDoc */ 24 | redirect() { 25 | // This shouldn't be called in the first place. 26 | throw new Error('ssh-fe does not redirect'); 27 | } 28 | 29 | /** @inheritDoc */ 30 | init() { 31 | // Most init happens in the stream below. 32 | return true; 33 | } 34 | 35 | /** @inheritDoc */ 36 | saveState() { return {}; } 37 | 38 | /** @inheritDoc */ 39 | loadState(state) {} 40 | 41 | /** @inheritDoc */ 42 | openSocket(fd, host, port, streams, onOpen) { 43 | const settings = { 44 | io: this.io_, 45 | relayHost: this.proxyHost, 46 | relayPort: this.proxyPort, 47 | relayUser: this.username, 48 | host: host, 49 | port: port, 50 | sshAgent: this.sshAgent_, 51 | }; 52 | return streams.openStream(nassh.Stream.RelaySshfeWS, fd, settings, onOpen); 53 | } 54 | }; 55 | -------------------------------------------------------------------------------- /nassh/js/nassh_sftp_status.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * The SFTP Status Error extends the Error class. It takes a 9 | * nassh.sftp.statusPacket and an expectedPacketType and creates an informative 10 | * Error message while preserving the status code. 11 | * 12 | * @param {!Object} statusPacket 13 | * @param {string} expectedPacketType 14 | * @constructor 15 | */ 16 | nassh.sftp.StatusError = function(statusPacket, expectedPacketType) { 17 | this.name = 'StatusError'; 18 | this.code = statusPacket.code; 19 | this.message = 'Received StatusPacket error in response to ' 20 | + expectedPacketType + ' packet: ' + statusPacket.message; 21 | this.stack = lib.f.getStack(); 22 | }; 23 | 24 | nassh.sftp.StatusError.prototype = Object.create(Error.prototype); 25 | /** @override */ 26 | nassh.sftp.StatusError.prototype.constructor = nassh.sftp.StatusError; 27 | -------------------------------------------------------------------------------- /nassh/js/nassh_stream_sftp.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Stream for passing binary SFTP data through. 9 | */ 10 | 11 | /** 12 | * The sftp packet stream. 13 | * 14 | * @param {number} fd 15 | * @param {{client: !nassh.sftp.Client}} info 16 | * @constructor 17 | * @extends {nassh.Stream} 18 | */ 19 | nassh.Stream.Sftp = function(fd, info) { 20 | nassh.Stream.apply(this, [fd]); 21 | 22 | this.acknowledgeCount_ = 0; 23 | this.client_ = info.client; 24 | }; 25 | 26 | nassh.Stream.Sftp.prototype = Object.create(nassh.Stream.prototype); 27 | /** @override */ 28 | nassh.Stream.Sftp.constructor = nassh.Stream.Sftp; 29 | 30 | /** 31 | * Open the stream asynchronously. 32 | * 33 | * @param {!Object} settings 34 | * @param {function(boolean)} onOpen 35 | * @override 36 | */ 37 | nassh.Stream.Sftp.prototype.asyncOpen = function(settings, onOpen) { 38 | this.acknowledgeCount_ = 0; 39 | 40 | setTimeout(() => onOpen(true), 0); 41 | }; 42 | 43 | /** 44 | * Write to the stream asynchronously. 45 | * 46 | * @param {!ArrayBuffer} data 47 | * @param {function(number)} onSuccess 48 | * @override 49 | */ 50 | nassh.Stream.Sftp.prototype.asyncWrite = function(data, onSuccess) { 51 | if (!this.open) { 52 | throw nassh.Stream.ERR_STREAM_CLOSED; 53 | } 54 | 55 | this.acknowledgeCount_ += data.byteLength; 56 | this.client_.writeStreamData(data); 57 | 58 | setTimeout(() => onSuccess(this.acknowledgeCount_), 0); 59 | }; 60 | -------------------------------------------------------------------------------- /nassh/js/nassh_test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 'use strict'; 6 | 7 | /** 8 | * @fileoverview Test framework setup when run inside the browser. 9 | */ 10 | 11 | // Setup the mocha framework. 12 | mocha.setup('bdd'); 13 | mocha.checkLeaks(); 14 | 15 | // Add a global shortcut to the assert API. 16 | const assert = chai.assert; 17 | 18 | // Catch any random errors before the test runner runs. 19 | let earlyError = null; 20 | /** 21 | * Catch any errors. 22 | * 23 | * @param {*} args Whatever arguments are passed in. 24 | */ 25 | window.onerror = function(...args) { 26 | earlyError = Array.from(args); 27 | }; 28 | 29 | /** Run the test framework once everything is finished. */ 30 | window.onload = async function() { 31 | hterm.defaultStorage = new lib.Storage.Memory(); 32 | 33 | await lib.init(); 34 | mocha.run(); 35 | 36 | if (earlyError !== null) { 37 | assert.fail(`uncaught exception detected:\n${earlyError.join('\n')}\n`); 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /nassh/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nassh", 3 | "version": "0.36.0", 4 | "description": "Terminal emulator and SSH and SFTP client", 5 | "main": "js/nassh.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://chromium.googlesource.com/apps/libapps.git" 9 | }, 10 | "author": "Chromium OS Authors", 11 | "license": "BSD-3-Clause", 12 | "files": [ 13 | "_locales", 14 | "css", 15 | "doc", 16 | "html", 17 | "js", 18 | "README.md", 19 | "third_party" 20 | ], 21 | "bugs": { 22 | "url": "https://goo.gl/vb94JY", 23 | "email": "chromium-hterm@chromium.org" 24 | }, 25 | "homepage": "https://chromium.googlesource.com/apps/libapps/+/HEAD/nassh", 26 | "scripts": { 27 | "prepare": "./bin/mkdeps", 28 | "start": "http-server -a localhost -c-1 --cors ..", 29 | "test": "./bin/load_tests" 30 | }, 31 | "devDependencies": { 32 | "chai": "~4", 33 | "eslint": "~7", 34 | "http-server": "~0", 35 | "license-checker": "~25", 36 | "mocha": "~8", 37 | "mocha-headless-chrome": "~3", 38 | "rollup": ">=1.16", 39 | "rollup-plugin-node-resolve": ">=5", 40 | "rollup-plugin-terser": ">=5", 41 | "terser": "~4" 42 | }, 43 | "dependencies": { 44 | "asn1js": "~2", 45 | "lit-element": "^2.3.1", 46 | "pkijs": "~2.1", 47 | "punycode": "~2" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /nassh/rollup.config.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Resolve ES6 import statements in node dependencies used by 7 | * nassh and package them into a single, minified ES6 module. 8 | */ 9 | 10 | import {terser} from 'rollup-plugin-terser'; 11 | import resolve from 'rollup-plugin-node-resolve'; 12 | 13 | export default { 14 | input: 'js/nassh_deps_rollup_shim.js', 15 | output: { 16 | file: 'js/nassh_deps.rollup.js', 17 | format: 'es', 18 | }, 19 | plugins: [ 20 | resolve({ 21 | mainFields: ['module', 'jsnext:main'], 22 | preferBuiltins: false 23 | }), 24 | terser(), 25 | ], 26 | }; 27 | -------------------------------------------------------------------------------- /nassh/third_party/chrome-bootstrap/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2012 Chrome Bootstrap authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /nassh/third_party/chrome-bootstrap/METADATA: -------------------------------------------------------------------------------- 1 | name: "Chrome UI bootstrap" 2 | description: "Chrome's UI stylings recreated for easy reuse" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://www.npmjs.com/package/chrome-bootstrap" 8 | } 9 | url { 10 | type: GIT 11 | value: "https://github.com/better-history/chrome-bootstrap" 12 | } 13 | version: "1.2.1" 14 | last_upgrade_date { year: 2013 month: 12 day: 9 } 15 | } 16 | -------------------------------------------------------------------------------- /nassh/third_party/google-smart-card/METADATA: -------------------------------------------------------------------------------- 1 | name: "google-smart-card-client-library" 2 | description: "Client library for the Smart Card Connector App for Chrome OS" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://github.com/GoogleChrome/chromeos_smart_card_connector/tree/HEAD/example_js_standalone_smart_card_client_library" 8 | } 9 | url { 10 | type: GIT 11 | value: "https://github.com/GoogleChrome/chromeos_smart_card_connector" 12 | } 13 | version: "1.2.10.0" 14 | last_upgrade_date { year: 2017 month: 6 day: 22 } 15 | } 16 | -------------------------------------------------------------------------------- /nassh/third_party/google-smart-card/README.md: -------------------------------------------------------------------------------- 1 | This is the client library for the Google Smart Card Connector App, which is a 2 | Chrome OS implementation of the PC/SC API for smart card operations. 3 | 4 | Upstream details can be found in the METADATA file. 5 | 6 | Licensing details can be found in LICENSE.md. 7 | 8 | For details on the API, consult the upstream site. The main functions are 9 | available under the `GoogleSmartCard` namespace. 10 | 11 | To pull in a newer version, just run `./download-google-smart-card-client-library.py`. 12 | -------------------------------------------------------------------------------- /nassh/third_party/nerd-fonts/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Ryan L McIntyre 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /nassh/third_party/nerd-fonts/METADATA: -------------------------------------------------------------------------------- 1 | name: "Nerd Fonts" 2 | description: "Iconic font aggregator, collection, and patcher" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://github.com/ryanoasis/nerd-fonts" 8 | } 9 | version: "2.0.0" 10 | last_upgrade_date { year: 2019 month: 07 day: 15 } 11 | } 12 | -------------------------------------------------------------------------------- /nassh/third_party/powerline/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013 Kim Silkebækken and other contributors 2 | https://github.com/powerline/powerline 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /nassh/third_party/powerline/METADATA: -------------------------------------------------------------------------------- 1 | name: "Powerline" 2 | description: "Powerline is a statusline plugin for vim" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://github.com/powerline/powerline" 8 | } 9 | version: "2.8.1" 10 | last_upgrade_date { year: 2019 month: 07 day: 15 } 11 | } 12 | -------------------------------------------------------------------------------- /navbar.md: -------------------------------------------------------------------------------- 1 | # hterm and Secure Shell 2 | 3 | [logo]: /nassh/images/dev/icon-32.png 4 | [home]: /README.md 5 | 6 | * [Home][home] 7 | * [FAQ](/nassh/doc/FAQ.md) 8 | * [Contact](https://groups.google.com/a/chromium.org/forum/?fromgroups#!forum/chromium-hterm) 9 | * [Bugs](https://goo.gl/VkasRC) 10 | * [hterm](/hterm/) 11 | * [nassh](/nassh/) 12 | * [ssh_client](/ssh_client/) 13 | * [libdot](/libdot/) 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libapps", 3 | "version": "1.0.0", 4 | "description": "Grab bag of js, including hterm and its support library.", 5 | "main": "libdot/js/lib.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://chromium.googlesource.com/apps/libapps.git" 9 | }, 10 | "author": "Chromium OS Authors", 11 | "license": "BSD-3-Clause", 12 | "files": [ 13 | "README.md" 14 | ], 15 | "scripts": { 16 | "start": "http-server -a localhost -c-1 --cors ." 17 | }, 18 | "devDependencies": {}, 19 | "dependencies": { 20 | "asn1js": "~2", 21 | "chai": "~4", 22 | "csso": ">=3", 23 | "csso-cli": ">=2", 24 | "eslint": "~7", 25 | "eslint-plugin-html": "~6", 26 | "eslint-plugin-jsdoc": "~27", 27 | "firebase-tools": ">=7", 28 | "http-server": "~0", 29 | "jsdoc-to-markdown": "~6", 30 | "license-checker": "~25", 31 | "lit-element": "^2.3.1", 32 | "markdownlint-cli": "~0", 33 | "mocha": "~8", 34 | "mocha-headless-chrome": "~3", 35 | "pkijs": "~2.1", 36 | "@polymer/polymer": "^3.3", 37 | "punycode": "~2", 38 | "rollup": ">=1.16", 39 | "rollup-plugin-node-resolve": ">=5", 40 | "rollup-plugin-terser": ">=5", 41 | "terser": "~4" 42 | }, 43 | "bugs": { 44 | "url": "https://goo.gl/vb94JY", 45 | "email": "chromium-hterm@chromium.org" 46 | }, 47 | "homepage": "https://chromium.googlesource.com/apps/libapps" 48 | } 49 | -------------------------------------------------------------------------------- /ssh_client/.gitignore: -------------------------------------------------------------------------------- 1 | /distfiles 2 | /output* 3 | .sconsign.dblite 4 | ssh_client.pem 5 | 6 | # npm related dirs. 7 | node_modules 8 | -------------------------------------------------------------------------------- /ssh_client/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2009 The Chromium OS Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. Neither the name of Google Inc. nor the names of its 12 | contributors may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /ssh_client/bin/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2020 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Lint our source files.""" 7 | 8 | import sys 9 | 10 | import ssh_client 11 | import libdot 12 | 13 | 14 | def main(argv): 15 | """The main func!""" 16 | return libdot.lint.main(argv, basedir=ssh_client.DIR) 17 | 18 | 19 | if __name__ == '__main__': 20 | sys.exit(main(sys.argv[1:])) 21 | -------------------------------------------------------------------------------- /ssh_client/bin/pylint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2018 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Wrapper to run pylint with the right sys.path.""" 7 | 8 | import sys 9 | 10 | import ssh_client 11 | import libdot 12 | 13 | 14 | if __name__ == '__main__': 15 | sys.exit(libdot.pylint.main( 16 | sys.argv[1:], pythonpaths=(ssh_client.BIN_DIR,))) 17 | -------------------------------------------------------------------------------- /ssh_client/echosshd/.gitignore: -------------------------------------------------------------------------------- 1 | /core 2 | /echosshd 3 | /host_key.* 4 | -------------------------------------------------------------------------------- /ssh_client/echosshd/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Chromium OS Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | PKG_CONFIG ?= pkg-config 6 | PC_MODULES = libssh 7 | PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_MODULES)) 8 | PC_LIBS := $(shell $(PKG_CONFIG) --libs $(PC_MODULES)) 9 | 10 | # We don't bother enabling optimization as perf here isn't important. 11 | DEFAULT_FLAGS = -g 12 | WFLAGS = -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers 13 | 14 | CFLAGS ?= $(DEFAULT_FLAGS) 15 | CFLAGS += $(WFLAGS) 16 | 17 | CXXFLAGS ?= $(DEFAULT_FLAGS) 18 | CXXFLAGS += $(WFLAGS) -std=gnu++14 19 | 20 | CPPFLAGS += $(PC_CFLAGS) 21 | LDLIBS += $(PC_LIBS) 22 | 23 | all: echosshd host_key.rsa host_key.ecdsa 24 | 25 | host_key.%: 26 | ssh-keygen -q -N '' -C '' -t $(@:host_key.%=%) -f $@ 27 | 28 | clean: 29 | rm -f echosshd 30 | 31 | .PHONY: all clean 32 | -------------------------------------------------------------------------------- /ssh_client/echosshd/README.md: -------------------------------------------------------------------------------- 1 | # echosshd testing server 2 | 3 | This is a simple server built on [libssh] for testing Secure Shell locally. 4 | It provides a simple shell interface so content can be sent back & forth. 5 | 6 | ## Requirements 7 | 8 | We require GCC 5+ for the `codecvt` header and the [libssh] development package. 9 | On Debian systems, you can run: 10 | 11 | ```sh 12 | sudo apt-get install gcc libssh-dev 13 | ``` 14 | 15 | ## Build 16 | 17 | You can run `make` to build `echosshd` and generate local keys as needed. 18 | 19 | ## Running 20 | 21 | Just run `./echosshd` to spawn the server. 22 | 23 | By default it listens on `localhost:22222`. 24 | You can log in with the `anon` account (no password required). 25 | 26 | Once you log in, use the `help` command to see available tests. 27 | 28 | [libssh]: https://www.libssh.org/ 29 | -------------------------------------------------------------------------------- /ssh_client/src/dev_null.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef DEV_NULL_H 6 | #define DEV_NULL_H 7 | 8 | #include "file_interfaces.h" 9 | #include "pthread_helpers.h" 10 | 11 | class DevNullHandler : public PathHandler { 12 | public: 13 | DevNullHandler(); 14 | virtual ~DevNullHandler(); 15 | 16 | virtual void addref(); 17 | virtual void release(); 18 | 19 | virtual FileStream* open(int fd, const char* pathname, int oflag, int* err); 20 | virtual int stat(const char* pathname, nacl_abi_stat* out); 21 | 22 | private: 23 | int ref_; 24 | 25 | DISALLOW_COPY_AND_ASSIGN(DevNullHandler); 26 | }; 27 | 28 | class DevNull : public FileStream { 29 | public: 30 | DevNull(int fd, int oflag); 31 | virtual ~DevNull(); 32 | 33 | virtual void addref(); 34 | virtual void release(); 35 | virtual FileStream* dup(int fd); 36 | 37 | virtual void close(); 38 | virtual int read(char* buf, size_t count, size_t* nread); 39 | virtual int write(const char* buf, size_t count, size_t* nwrote); 40 | 41 | virtual int fcntl(int cmd, va_list ap); 42 | 43 | private: 44 | int fd_; 45 | int oflag_; 46 | int ref_; 47 | 48 | DISALLOW_COPY_AND_ASSIGN(DevNull); 49 | }; 50 | 51 | #endif // DEV_NULL_H 52 | -------------------------------------------------------------------------------- /ssh_client/src/dev_random.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef DEV_RANDOM_H 6 | #define DEV_RANDOM_H 7 | 8 | #include "file_interfaces.h" 9 | #include "pthread_helpers.h" 10 | 11 | class DevRandomHandler : public PathHandler { 12 | public: 13 | DevRandomHandler( 14 | int (*get_random_bytes)(void* buf, size_t count, size_t* nread)); 15 | virtual ~DevRandomHandler(); 16 | 17 | virtual void addref(); 18 | virtual void release(); 19 | 20 | virtual FileStream* open(int fd, const char* pathname, int oflag, int* err); 21 | virtual int stat(const char* pathname, nacl_abi_stat* out); 22 | 23 | private: 24 | int ref_; 25 | int (*get_random_bytes_)(void* buf, size_t count, size_t* nread); 26 | 27 | DISALLOW_COPY_AND_ASSIGN(DevRandomHandler); 28 | }; 29 | 30 | class DevRandom : public FileStream { 31 | public: 32 | DevRandom(int fd, int oflag, 33 | int (*get_random_bytes)(void* buf, size_t count, size_t* nread)); 34 | virtual ~DevRandom(); 35 | 36 | virtual void addref(); 37 | virtual void release(); 38 | virtual FileStream* dup(int fd); 39 | 40 | virtual void close(); 41 | virtual int read(char* buf, size_t count, size_t* nread); 42 | virtual int write(const char* buf, size_t count, size_t* nwrote); 43 | 44 | virtual int fstat(nacl_abi_stat* out); 45 | virtual int fcntl(int cmd, va_list ap); 46 | 47 | private: 48 | int fd_; 49 | int oflag_; 50 | int ref_; 51 | int (*get_random_bytes_)(void* buf, size_t count, size_t* nread); 52 | 53 | DISALLOW_COPY_AND_ASSIGN(DevRandom); 54 | }; 55 | 56 | #endif // DEV_RANDOM_H 57 | -------------------------------------------------------------------------------- /ssh_client/ssh_client.nmf: -------------------------------------------------------------------------------- 1 | { 2 | "program": { 3 | "x86-32": {"url": "ssh_client_nl_x86_32.nexe"}, 4 | "x86-64": {"url": "ssh_client_nl_x86_64.nexe"}, 5 | "arm": { "url": "ssh_client_nl_arm.nexe"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /ssh_client/third_party/bazel-0.17/METADATA: -------------------------------------------------------------------------------- 1 | name: "bazel" 2 | description: "a fast, scalable, multi-language and extensible build system" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://bazel.build/" 8 | } 9 | version: "0.17.2" 10 | last_upgrade_date { year: 2018 month: 9 day: 21 } 11 | } 12 | -------------------------------------------------------------------------------- /ssh_client/third_party/bazel-0.17/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2020 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Build (old) bazel package. 7 | 8 | The mosh-chrome project needs this old version. 9 | """ 10 | 11 | import os 12 | from pathlib import Path 13 | import sys 14 | 15 | FILESDIR = os.path.dirname(os.path.realpath(__file__)) 16 | sys.path.insert(0, os.path.join(FILESDIR, '..', '..', 'bin')) 17 | 18 | import ssh_client # pylint: disable=wrong-import-position 19 | 20 | 21 | ARCHIVES = ('%(P)s-linux-x86_64.tar.xz',) 22 | S = '%(workdir)s' 23 | 24 | 25 | def src_install(metadata): 26 | """Install the package.""" 27 | target = next(Path(metadata['S']).glob('bazel-*')) 28 | path = os.path.join(ssh_client.BUILD_BINDIR, 'bazel-0.17') 29 | ssh_client.symlink(target, path) 30 | 31 | 32 | ssh_client.build_package(sys.modules[__name__], 'build') 33 | -------------------------------------------------------------------------------- /ssh_client/third_party/binaryen/METADATA: -------------------------------------------------------------------------------- 1 | name: "binaryen" 2 | description: "Compiler infrastructure and toolchain library for WebAssembly" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://github.com/WebAssembly/binaryen" 8 | } 9 | version: "97" 10 | } 11 | -------------------------------------------------------------------------------- /ssh_client/third_party/binaryen/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Build binaryen package.""" 7 | 8 | import os 9 | import sys 10 | 11 | FILESDIR = os.path.dirname(os.path.realpath(__file__)) 12 | sys.path.insert(0, os.path.join(FILESDIR, '..', '..', 'bin')) 13 | 14 | import ssh_client # pylint: disable=wrong-import-position 15 | 16 | 17 | ARCHIVES = ('%(PN)s-version_%(PV)s-x86_64-linux.tar.gz',) 18 | S = '%(workdir)s/%(PN)s-version_%(PV)s' 19 | 20 | 21 | def src_install(metadata): 22 | """Install the package.""" 23 | # For now we assume everything in here is a program. 24 | srcbindir = os.path.join(metadata['S'], 'bin') 25 | for prog in os.listdir(srcbindir): 26 | target = os.path.join(srcbindir, prog) 27 | path = os.path.join(ssh_client.BUILD_BINDIR, prog) 28 | ssh_client.symlink(target, path) 29 | 30 | 31 | ssh_client.build_package(sys.modules[__name__], 'build') 32 | -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/METADATA: -------------------------------------------------------------------------------- 1 | name: "glibc-compat" 2 | description: "Random C library compatibility headers" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://sourceware.org/newlib/" 8 | } 9 | version: "0.1" 10 | last_upgrade_date { year: 2012 month: 9 day: 5 } 11 | } 12 | -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2018 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Build glibc-compat package.""" 7 | 8 | import os 9 | import sys 10 | 11 | FILESDIR = os.path.dirname(os.path.realpath(__file__)) 12 | sys.path.insert(0, os.path.join(FILESDIR, '..', '..', 'bin')) 13 | 14 | import ssh_client # pylint: disable=wrong-import-position 15 | 16 | 17 | S = '%(workdir)s' 18 | 19 | 20 | def src_install(metadata): 21 | """Install the package.""" 22 | tc = metadata['toolchain'] 23 | srcdir = os.path.join(FILESDIR, 'include') 24 | for root, _, files in os.walk(srcdir): 25 | for header in files: 26 | relsrcdir = os.path.relpath(root, srcdir) 27 | targetdir = os.path.join(tc.incdir, 'glibc-compat', relsrcdir) 28 | os.makedirs(targetdir, exist_ok=True) 29 | ssh_client.copy(os.path.join(root, header), 30 | os.path.join(targetdir, header)) 31 | 32 | 33 | ssh_client.build_package(sys.modules[__name__], 'pnacl') 34 | -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/arpa/nameser.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/ssh_client/third_party/glibc-compat/include/arpa/nameser.h -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/net/if.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/ssh_client/third_party/glibc-compat/include/net/if.h -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/netdb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The Native Client Authors. All rights reserved. 3 | * Use of this source code is governed by a BSD-style license that can be 4 | * found in the LICENSE file. 5 | */ 6 | #ifndef GLIBCEMU_NETDB_H 7 | #define GLIBCEMU_NETDB_H 1 8 | 9 | /* Redirect incorrect declarations to an alternate name. */ 10 | #define getaddrinfo getaddrinfo_wrong 11 | #define getnameinfo getnameinfo_wrong 12 | 13 | #include_next 14 | 15 | /* Remove all the macros we added. */ 16 | #undef getaddrinfo 17 | #undef getnameinfo 18 | 19 | __BEGIN_DECLS 20 | 21 | /* Declare these two correctly. */ 22 | int getaddrinfo(const char *, const char *, 23 | const struct addrinfo *, struct addrinfo **); 24 | int getnameinfo(const struct sockaddr *, socklen_t, char *, 25 | socklen_t, char *, socklen_t, unsigned int); 26 | 27 | __END_DECLS 28 | 29 | #endif /* GLIBCEMU_NETDB_H */ 30 | -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/netinet/in_systm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/ssh_client/third_party/glibc-compat/include/netinet/in_systm.h -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/netinet/ip.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ish-app/libapps/b8cacae35e5b11d64bb736a053921c16ca7faf9e/ssh_client/third_party/glibc-compat/include/netinet/ip.h -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/readpassphrase.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // https://linux.die.net/man/3/readpassphrase 6 | 7 | #ifndef NASSH_READPASSPHRASE_H 8 | #define NASSH_READPASSPHRASE_H 9 | 10 | #include 11 | 12 | #define RPP_ECHO_OFF 0x00 13 | #define RPP_ECHO_ON 0x01 14 | #define RPP_REQUIRE_TTY 0x02 15 | 16 | __BEGIN_DECLS 17 | 18 | char* readpassphrase(const char* prompt, char* buf, size_t buf_len, int flags); 19 | 20 | __END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/resolv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The Native Client Authors. All rights reserved. 3 | * Use of this source code is governed by a BSD-style license that can be 4 | * found in the LICENSE file. 5 | */ 6 | #ifndef GLIBCEMU_RESOLV_H 7 | #define GLIBCEMU_RESOLV_H 1 8 | 9 | #include 10 | 11 | __BEGIN_DECLS 12 | 13 | int b64_ntop(unsigned char const *, size_t, char *, size_t); 14 | int b64_pton(char const *, unsigned char *, size_t); 15 | 16 | __END_DECLS 17 | 18 | #endif /* GLIBCEMU_RESOLV_H */ 19 | -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/sys/ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The Native Client Authors. All rights reserved. 3 | * Use of this source code is governed by a BSD-style license that can be 4 | * found in the LICENSE file. 5 | */ 6 | #ifndef GLIBCEMU_SYS_IOCTL_H 7 | #define GLIBCEMU_SYS_IOCTL_H 1 8 | 9 | #define TIOCGPGRP 0x540F 10 | 11 | #include_next 12 | 13 | #endif /* GLIBCEMU_SYS_IOCTL_H */ 14 | -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/sys/uio.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_UIO_H 2 | #define _SYS_UIO_H 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | struct iovec { 11 | void *iov_base; 12 | size_t iov_len; 13 | }; 14 | 15 | #ifdef __cplusplus 16 | }; 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/sys/un.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 The Native Client Authors. All rights reserved. 3 | * Use of this source code is governed by a BSD-style license that can be 4 | * found in the LICENSE file. 5 | */ 6 | #ifndef GLIBCEMU_SYS_UN_H 7 | #define GLIBCEMU_SYS_UN_H 1 8 | 9 | #include 10 | 11 | struct sockaddr_un { 12 | sa_family_t sun_family; /* address family */ 13 | char sun_path[108]; 14 | }; 15 | 16 | #endif /* GLIBCEMU_SYS_UN_H */ 17 | -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/sys/unistd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 The Native Client Authors. All rights reserved. 3 | * Use of this source code is governed by a BSD-style license that can be 4 | * found in the LICENSE file. 5 | */ 6 | #ifndef GLIBCEMU_SYS_UNISTD_H 7 | #define GLIBCEMU_SYS_UNISTD_H 8 | 9 | #include_next 10 | 11 | #define _SC_OPEN_MAX (-1) 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ssh_client/third_party/glibc-compat/include/syslog.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /ssh_client/third_party/gnuconfig/METADATA: -------------------------------------------------------------------------------- 1 | name: "gnuconfig" 2 | description: "config.guess and config.sub scripts" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://savannah.gnu.org/projects/config" 8 | } 9 | version: "20190804" 10 | last_upgrade_date { year: 2019 month: 8 day: 4 } 11 | } 12 | -------------------------------------------------------------------------------- /ssh_client/third_party/gnuconfig/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Build gnuconfig package.""" 7 | 8 | import os 9 | import sys 10 | 11 | FILESDIR = os.path.dirname(os.path.realpath(__file__)) 12 | sys.path.insert(0, os.path.join(FILESDIR, '..', '..', 'bin')) 13 | 14 | import ssh_client # pylint: disable=wrong-import-position 15 | 16 | 17 | ARCHIVES = ('%(P)s.tar.bz2',) 18 | S = '%(workdir)s' 19 | 20 | 21 | def src_install(metadata): 22 | """Install the package.""" 23 | for prog in ('config.guess', 'config.sub'): 24 | target = os.path.join(metadata['S'], prog) 25 | path = os.path.join(ssh_client.BUILD_BINDIR, prog) 26 | ssh_client.symlink(target, path) 27 | 28 | 29 | ssh_client.build_package(sys.modules[__name__], 'build') 30 | -------------------------------------------------------------------------------- /ssh_client/third_party/ldns/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005,2006, NLnetLabs 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of NLnetLabs nor the names of its 13 | contributors may be used to endorse or promote products derived from this 14 | software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /ssh_client/third_party/ldns/METADATA: -------------------------------------------------------------------------------- 1 | name: "ldns" 2 | description: "DNS library" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://nlnetlabs.nl/projects/ldns/" 8 | } 9 | version: "1.7.0" 10 | last_upgrade_date { year: 2016 month: 12 day: 20 } 11 | 12 | local_modifications: 13 | "See the patches in this directory for more details." 14 | } 15 | -------------------------------------------------------------------------------- /ssh_client/third_party/ldns/ldns-CVE-2017-1000231.patch: -------------------------------------------------------------------------------- 1 | From c8391790c96d4c8a2c10f9ab1460fda83b509fc2 Mon Sep 17 00:00:00 2001 2 | From: Willem Toorop 3 | Date: Thu, 27 Apr 2017 00:14:58 +0200 4 | Subject: [PATCH] Check parse limit before t increment 5 | 6 | Thanks Stephan Zeisberg 7 | --- 8 | Changelog | 2 ++ 9 | parse.c | 4 ++++ 10 | 2 files changed, 6 insertions(+) 11 | 12 | diff --git a/parse.c b/parse.c 13 | index e68627c25a72..947dbb8984f7 100644 14 | --- a/parse.c 15 | +++ b/parse.c 16 | @@ -118,6 +118,10 @@ ldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *li 17 | if (line_nr) { 18 | *line_nr = *line_nr + 1; 19 | } 20 | + if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) { 21 | + *t = '\0'; 22 | + return -1; 23 | + } 24 | *t++ = ' '; 25 | prev_c = c; 26 | continue; 27 | -- 28 | 2.19.1 29 | -------------------------------------------------------------------------------- /ssh_client/third_party/ldns/ldns-CVE-2017-1000232.patch: -------------------------------------------------------------------------------- 1 | From 3bdeed02505c9bbacb3b64a97ddcb1de967153b7 Mon Sep 17 00:00:00 2001 2 | From: Willem Toorop 3 | Date: Thu, 27 Apr 2017 00:25:20 +0200 4 | Subject: [PATCH] bugfix #1257: Free after reallocing to 0 size 5 | 6 | Thanks Stephan Zeisberg 7 | --- 8 | Changelog | 2 ++ 9 | str2host.c | 6 ++++-- 10 | 2 files changed, 6 insertions(+), 2 deletions(-) 11 | 12 | diff --git a/str2host.c b/str2host.c 13 | index b274b17a2bf9..f2a317beaf18 100644 14 | --- a/str2host.c 15 | +++ b/str2host.c 16 | @@ -1525,8 +1525,10 @@ ldns_str2rdf_long_str(ldns_rdf **rd, const char *str) 17 | if (! str) { 18 | return LDNS_STATUS_SYNTAX_BAD_ESCAPE; 19 | } 20 | - length = (size_t)(dp - data); 21 | - 22 | + if (!(length = (size_t)(dp - data))) { 23 | + LDNS_FREE(data); 24 | + return LDNS_STATUS_SYNTAX_EMPTY; 25 | + } 26 | /* Lose the overmeasure */ 27 | data = LDNS_XREALLOC(dp = data, uint8_t, length); 28 | if (! data) { 29 | -- 30 | 2.19.1 31 | -------------------------------------------------------------------------------- /ssh_client/third_party/ldns/ldns-no-getproto.patch: -------------------------------------------------------------------------------- 1 | We don't offer these two funcs in the C library, so disable them. The code 2 | already fallsback to treating things as numbers which works for everything 3 | we care about already. 4 | 5 | --- a/host2str.c 6 | +++ b/host2str.c 7 | @@ -808,7 +808,7 @@ ldns_rdf2buffer_str_wks(ldns_buffer *output, const ldns_rdf *rdf) 8 | return LDNS_STATUS_WIRE_RDATA_ERR; 9 | } 10 | protocol_nr = ldns_rdf_data(rdf)[0]; 11 | - protocol = getprotobynumber((int) protocol_nr); 12 | + protocol = NULL; 13 | if (protocol && (protocol->p_name != NULL)) { 14 | proto_name = protocol->p_name; 15 | ldns_buffer_printf(output, "%s ", protocol->p_name); 16 | --- a/str2host.c 17 | +++ b/str2host.c 18 | @@ -1155,7 +1155,7 @@ ldns_str2rdf_wks(ldns_rdf **rd, const char *str) 19 | return LDNS_STATUS_INVALID_STR; 20 | } 21 | if (proto_str) 22 | - proto = getprotobyname(proto_str); 23 | + proto = NULL; 24 | if (proto) { 25 | data[0] = (uint8_t) proto->p_proto; 26 | } else if (proto_str) { 27 | -------------------------------------------------------------------------------- /ssh_client/third_party/ldns/ldns-ssl-engine.patch: -------------------------------------------------------------------------------- 1 | From e342a344c87c4f60c731654d9899e9422ba96dd3 Mon Sep 17 00:00:00 2001 2 | From: Rosen Penev 3 | Date: Sat, 5 Jan 2019 21:05:55 -0800 4 | Subject: [PATCH] Make OpenSSL ENGINE support optional 5 | 6 | --- 7 | keys.c | 6 ++++-- 8 | 1 file changed, 4 insertions(+), 2 deletions(-) 9 | 10 | diff --git a/keys.c b/keys.c 11 | index bb7bd6cd7cae..2a8593dfb809 100644 12 | --- a/keys.c 13 | +++ b/keys.c 14 | @@ -16,8 +16,10 @@ 15 | 16 | #ifdef HAVE_SSL 17 | #include 18 | -#include 19 | #include 20 | +#ifndef OPENSSL_NO_ENGINE 21 | +#include 22 | +#endif 23 | #endif /* HAVE_SSL */ 24 | 25 | ldns_lookup_table ldns_signing_algorithms[] = { 26 | @@ -99,7 +101,7 @@ ldns_key_new_frm_fp(ldns_key **k, FILE *fp) 27 | return ldns_key_new_frm_fp_l(k, fp, NULL); 28 | } 29 | 30 | -#ifdef HAVE_SSL 31 | +#if defined(HAVE_SSL) && !defined(OPENSSL_NO_ENGINE) 32 | ldns_status 33 | ldns_key_new_frm_engine(ldns_key **key, ENGINE *e, char *key_id, ldns_algorithm alg) 34 | { 35 | -- 36 | 2.19.1 37 | -------------------------------------------------------------------------------- /ssh_client/third_party/ldns/ldns-ssl-headers.patch: -------------------------------------------------------------------------------- 1 | https://github.com/NLnetLabs/ldns/pull/15 2 | 3 | --- a/dnssec.c 4 | +++ b/dnssec.c 5 | @@ -23,6 +23,9 @@ 6 | #include 7 | #include 8 | #include 9 | +#include 10 | +#include 11 | +#include 12 | #endif 13 | 14 | ldns_rr * 15 | --- a/dnssec_sign.c 16 | +++ b/dnssec_sign.c 17 | @@ -17,6 +17,9 @@ 18 | #include 19 | #include 20 | #include 21 | +#include 22 | +#include 23 | +#include 24 | #endif /* HAVE_SSL */ 25 | 26 | ldns_rr * 27 | --- a/host2str.c 28 | +++ b/host2str.c 29 | @@ -28,6 +28,12 @@ 30 | #include 31 | #include 32 | 33 | +#ifdef HAVE_SSL 34 | +#include 35 | +#include 36 | +#include 37 | +#endif 38 | + 39 | #ifndef INET_ADDRSTRLEN 40 | #define INET_ADDRSTRLEN 16 41 | #endif 42 | --- a/keys.c 43 | +++ b/keys.c 44 | @@ -16,6 +16,9 @@ 45 | #ifdef HAVE_SSL 46 | #include 47 | #include 48 | +#include 49 | +#include 50 | +#include 51 | #ifndef OPENSSL_NO_ENGINE 52 | # include 53 | #endif 54 | -------------------------------------------------------------------------------- /ssh_client/third_party/mandoc/METADATA: -------------------------------------------------------------------------------- 1 | name: "mandoc" 2 | description: "Suite of tools to convert man pages into HTML" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://mandoc.bsd.lv/" 8 | } 9 | version: "1.14.5" 10 | last_upgrade_date { year: 2019 month: 3 day: 10 } 11 | } 12 | -------------------------------------------------------------------------------- /ssh_client/third_party/mandoc/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2018 The Chromium OS Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """Build mandoc package.""" 7 | 8 | import os 9 | import sys 10 | 11 | FILESDIR = os.path.dirname(os.path.realpath(__file__)) 12 | sys.path.insert(0, os.path.join(FILESDIR, '..', '..', 'bin')) 13 | 14 | import ssh_client # pylint: disable=wrong-import-position 15 | 16 | 17 | ARCHIVES = ('%(P)s.tar.gz',) 18 | PATCHES = ('%(P)s.patch',) 19 | 20 | 21 | def src_configure(_metadata): 22 | """Configure the source.""" 23 | for var in ('AR', 'CC', 'CFLAGS', 'CPPFLAGS', 'LDFLAGS'): 24 | os.environ.pop(var, None) 25 | if not os.path.exists('Makefile.local'): 26 | ssh_client.run(['./configure']) 27 | 28 | 29 | def src_compile(_metadata): 30 | """Compile the source.""" 31 | ssh_client.emake('mandoc') 32 | 33 | 34 | def src_install(metadata): 35 | """Install the package.""" 36 | target = os.path.join(metadata['S'], 'mandoc') 37 | path = os.path.join(ssh_client.BUILD_BINDIR, 'mandoc') 38 | ssh_client.symlink(target, path) 39 | 40 | 41 | ssh_client.build_package(sys.modules[__name__], 'build') 42 | -------------------------------------------------------------------------------- /ssh_client/third_party/mandoc/mandoc-1.14.5.patch: -------------------------------------------------------------------------------- 1 | Newer make is unable to find echo with `env -i`. We can simply hardcode the 2 | POSIX `cc` and not worry about it. 3 | 4 | --- a/configure 5 | +++ b/configure 6 | @@ -41,7 +41,7 @@ OSENUM= 7 | OSNAME= 8 | UTF8_LOCALE= 9 | 10 | -CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | env -i make -sf -` 11 | +CC=cc 12 | CFLAGS= 13 | LDADD= 14 | LDFLAGS= 15 | -------------------------------------------------------------------------------- /ssh_client/third_party/mosh-chrome/METADATA: -------------------------------------------------------------------------------- 1 | name: "mosh-chrome" 2 | description: "Mosh (mobile shell) for Chrome" 3 | 4 | third_party { 5 | url { 6 | type: HOMEPAGE 7 | value: "https://github.com/rpwoodbu/mosh-chrome" 8 | } 9 | version: "0.5.6" 10 | last_upgrade_date { year: 2020 month: 8 day: 5 } 11 | } 12 | -------------------------------------------------------------------------------- /ssh_client/third_party/mosh-chrome/mosh-chrome-0.5.6-misc.patch: -------------------------------------------------------------------------------- 1 | Random minor things: 2 | * Add missing UTF-8 encodings to the HTML files. 3 | https://github.com/rpwoodbu/mosh-chrome/pull/208 4 | * Make things dark-mode esque by default. 5 | We can improve when CrOS supports this properly. 6 | * Hide the Google DoH knob as it requires a manifest permission. 7 | 8 | --- a/mosh_app/mosh_client.html 9 | +++ b/mosh_app/mosh_client.html 10 | @@ -16,12 +16,17 @@ 11 | along with this program. If not, see . 12 | --> 13 | 14 | + 15 | Mosh Sessions 16 | 17 | 18 | 19 | 20 | 27 | 28 | 29 | 30 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /terminal/html/terminal_settings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /terminal/js/lit_element.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview exports lit element utilities. 7 | * 8 | * As nassh_deps.rollup.js is a compiled js file, it violates the linter in 9 | * numerous ways. As a consequnce, it must be suppressed and the types imported 10 | * from it in this file will be undefined, so must also be suppressed. 11 | * 12 | * @suppress {moduleLoad} 13 | */ 14 | import {litelement} from './nassh_deps.rollup.js'; 15 | 16 | /** @suppress {undefinedVars} */ 17 | const {LitElement, render, html, css, unsafeCSS, live} = litelement; 18 | 19 | export {LitElement, render, html, css, unsafeCSS, live}; 20 | -------------------------------------------------------------------------------- /terminal/js/terminal_knob.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | 6 | /** 7 | * @fileoverview Exports an element: terminal-knob 8 | * 9 | * @suppress {moduleLoad} 10 | */ 11 | import {LitElement, css} from './lit_element.js'; 12 | 13 | export class TerminalKnob extends LitElement { 14 | /** @override */ 15 | static get styles() { 16 | return css` 17 | :host { 18 | cursor: pointer; 19 | display: block; 20 | border-radius: 100%; 21 | border: 3px solid white; 22 | box-shadow: 0 0 0 1px #5F6368; 23 | box-sizing: border-box; 24 | height: 32px; 25 | outline: none; 26 | transform: translate(-50%, -50%); 27 | width: 32px; 28 | } 29 | 30 | :host(:focus-visible), :host-context(terminal-slider[focusVisible]) { 31 | box-shadow: 0 0 0 3px var(--focus-shadow-color), 0 0 0 1px #5F6368; 32 | } 33 | `; 34 | } 35 | } 36 | 37 | customElements.define('terminal-knob', TerminalKnob); 38 | -------------------------------------------------------------------------------- /terminal/js/terminal_main.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Initializes global state used in terminal. 7 | */ 8 | 9 | import {terminal} from './terminal.js'; 10 | import {TerminalActiveTracker} from './terminal_active_tracker.js'; 11 | import {setUpTitleHandler} from './terminal_common.js'; 12 | 13 | // This must be called before we initialize the terminal to ensure capturing the 14 | // first title that hterm sets. 15 | setUpTitleHandler(); 16 | 17 | window.addEventListener('DOMContentLoaded', () => { 18 | // TODO(crbug.com/999028): Make sure system web apps are not discarded as 19 | // part of the lifecycle API. This fix used by crosh and nassh is not 20 | // guaranteed to be a long term solution. 21 | TerminalActiveTracker.get().then( 22 | (tracker) => { 23 | chrome.tabs.update(tracker.tab.id, {autoDiscardable: false}); 24 | }); 25 | 26 | lib.registerInit('terminal-private-storage', () => { 27 | hterm.defaultStorage = new lib.Storage.TerminalPrivate(); 28 | }); 29 | 30 | // Load i18n messages. 31 | lib.registerInit('messages', async () => { 32 | // Load hterm.messageManager from /_locales//messages.json. 33 | hterm.messageManager.useCrlf = true; 34 | const url = lib.f.getURL('/_locales/$1/messages.json'); 35 | await hterm.messageManager.findAndLoadMessages(url); 36 | }); 37 | 38 | lib.init().then(() => { 39 | window.term_ = terminal.init( 40 | lib.notNull(document.querySelector('#terminal'))); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /terminal/js/terminal_settings_app_tests.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Terminal Settings App Element unit tests. 7 | */ 8 | 9 | import {BELL_SOUND_CONVERTER} from './terminal_settings_app.js'; 10 | 11 | describe('terminal_settings_app_tests.js', () => { 12 | it('converts-bell-sound', () => { 13 | const toChecked = BELL_SOUND_CONVERTER.toChecked; 14 | assert.isTrue(toChecked('lib-resource:hterm/audio/bell')); 15 | assert.isTrue(toChecked('foo')); 16 | assert.isFalse(toChecked(null)); 17 | assert.isFalse(toChecked('')); 18 | 19 | const fromChecked = BELL_SOUND_CONVERTER.fromChecked; 20 | assert.equal(fromChecked(true), 'lib-resource:hterm/audio/bell'); 21 | assert.equal(fromChecked(false), ''); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /terminal/js/terminal_settings_element.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Exports the base class for terminal settings elements. 7 | * This element automatically handles data binding between the managed 8 | * preferences and the preferences being displayed in the ui. 9 | * 10 | * @suppress {moduleLoad} 11 | */ 12 | import {LitElement} from './lit_element.js'; 13 | 14 | export class TerminalSettingsElement extends LitElement { 15 | constructor() { 16 | super(); 17 | 18 | /** @type {string} */ 19 | this.preference; 20 | /** @protected {*} */ 21 | this.value; 22 | this.boundPreferenceChanged_ = this.preferenceChanged_.bind(this); 23 | } 24 | 25 | /** @override */ 26 | connectedCallback() { 27 | super.connectedCallback(); 28 | 29 | this.preferenceChanged_( 30 | window.preferenceManager.get(this.preference)); 31 | window.preferenceManager.addObserver( 32 | this.preference, 33 | this.boundPreferenceChanged_); 34 | } 35 | 36 | /** @override */ 37 | disconnectedCallback() { 38 | super.disconnectedCallback(); 39 | 40 | window.preferenceManager.removeObserver( 41 | this.preference, 42 | this.boundPreferenceChanged_); 43 | } 44 | 45 | /** 46 | * @param {*} value 47 | * @protected 48 | */ 49 | uiChanged_(value) { 50 | this.value = value; 51 | window.preferenceManager.set(this.preference, value); 52 | } 53 | 54 | /** 55 | * @param {*} value 56 | * @protected 57 | */ 58 | preferenceChanged_(value) { 59 | this.value = value; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /terminal/js/terminal_settings_styles.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Common code for terminal and it settings page. 7 | * 8 | * @suppress {moduleLoad} 9 | */ 10 | 11 | import {css} from './lit_element.js'; 12 | 13 | export const stylesVars = css` 14 | :host { 15 | --active-bg: rgb(232, 240, 254); 16 | --google-blue-600: rgb(26, 115, 232); 17 | --google-blue-600-rgb: 26, 115, 232; 18 | --google-blue-refresh-500-rgb: 66, 133, 244; 19 | --google-grey-300: rgb(218, 220, 224); 20 | --cr-primary-text-color: rgb(32, 33, 36); 21 | --cr-secondary-text-color: rgb(95, 99, 104); 22 | --focus-shadow-color: rgba(26, 115, 232, .4); 23 | --font: 'Roboto'; 24 | } 25 | `; 26 | 27 | export const stylesDialog = css` 28 | dialog { 29 | border: 0; 30 | border-radius: 8px; 31 | box-shadow: 0 0 16px rgba(0, 0, 0, 0.12), 32 | 0 16px 16px rgba(0, 0, 0, 0.24); 33 | color: var(--cr-secondary-text-color); 34 | padding: 20px 20px 16px 20px; 35 | } 36 | 37 | .dialog-title { 38 | color: var(--cr-primary-text-color); 39 | font-size: calc(15 / 13 * 100%); 40 | padding-bottom: 16px; 41 | } 42 | 43 | .dialog-button-container { 44 | display: flex; 45 | justify-content: flex-end; 46 | padding-top: 24px; 47 | } 48 | `; 49 | -------------------------------------------------------------------------------- /wasi-js-bindings/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019-2020 The Chromium OS Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. Neither the name of Google Inc. nor the names of its 12 | contributors may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /wasi-js-bindings/js/util.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Random utility functions with no real home. 7 | */ 8 | 9 | import * as ERRNO from './wasi/errno.js'; 10 | 11 | /** 12 | * Generator to return all properties on an object. 13 | * 14 | * @param {!Object} obj The object whose names to enumerate. 15 | * @yield {string} The property names. 16 | */ 17 | export function* getAllPropertyNames(obj) { 18 | while (obj) { 19 | const keys = Object.getOwnPropertyNames(obj); 20 | for (let i = 0; i < keys.length; ++i) { 21 | yield keys[i]; 22 | } 23 | obj = Object.getPrototypeOf(obj); 24 | } 25 | } 26 | 27 | /** 28 | * Status of an exited process. 29 | */ 30 | export class CompletedProcessError extends Error { 31 | constructor({status, signal}) { 32 | super(); 33 | this.status = status; 34 | this.signal = signal; 35 | this.message = this.toString(); 36 | } 37 | 38 | /** 39 | * Convert object to a human readable string. 40 | */ 41 | toString() { 42 | if (this.status !== undefined) { 43 | return `Process called exit(${this.status})`; 44 | } else if (this.signal !== undefined) { 45 | return `Process exited due to signal ${this.signal}`; 46 | } else { 47 | return 'Process exited for unknown reasons'; 48 | } 49 | } 50 | } 51 | 52 | export function strerror(errno) { 53 | for (const [key, val] of Object.entries(ERRNO)) { 54 | if (key[0] == 'E' && val == errno) { 55 | return key; 56 | } 57 | } 58 | return `E???[${errno}]`; 59 | } 60 | -------------------------------------------------------------------------------- /wasi-js-bindings/js/wasi.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview WASI API constants. 7 | */ 8 | 9 | export * as advice from './wasi/advice.js'; 10 | export * as clock from './wasi/clock.js'; 11 | export * as errno from './wasi/errno.js'; 12 | export * as eventtype from './wasi/eventtype.js'; 13 | export * as filetype from './wasi/filetype.js'; 14 | export * as signal from './wasi/signal.js'; 15 | export * as whence from './wasi/whence.js'; 16 | -------------------------------------------------------------------------------- /wasi-js-bindings/js/wasi/advice.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview WASI advice API constants from wasi/api.h. 7 | */ 8 | 9 | export const NORMAL = 0; 10 | export const SEQUENTIAL = 1; 11 | export const RANDOM = 2; 12 | export const WILLNEED = 3; 13 | export const DONTNEED = 4; 14 | export const NOREUSE = 5; 15 | -------------------------------------------------------------------------------- /wasi-js-bindings/js/wasi/clock.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview WASI clockid API constants from wasi/api.h. 7 | */ 8 | 9 | export const REALTIME = 0; 10 | export const MONOTONIC = 1; 11 | export const PROCESS_CPUTIME_ID = 2; 12 | export const THREAD_CPUTIME_ID = 3; 13 | -------------------------------------------------------------------------------- /wasi-js-bindings/js/wasi/eventtype.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview WASI eventtype API constants from wasi/api.h. 7 | */ 8 | 9 | export const CLOCK = 0; 10 | export const FD_READ = 1; 11 | export const FD_WRITE = 2; 12 | -------------------------------------------------------------------------------- /wasi-js-bindings/js/wasi/filetype.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview WASI filetype API constants from wasi/api.h. 7 | */ 8 | 9 | export const UNKNOWN = 0; 10 | export const BLOCK_DEVICE = 1; 11 | export const CHARACTER_DEVICE = 2; 12 | export const DIRECTORY = 3; 13 | export const REGULAR_FILE = 4; 14 | export const SOCKET_DGRAM = 5; 15 | export const SOCKET_STREAM = 6; 16 | export const SYMBOLIC_LINK = 7; 17 | -------------------------------------------------------------------------------- /wasi-js-bindings/js/wasi/signal.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview WASI signal API constants from wasi/api.h. 7 | */ 8 | 9 | export const NONE = 0; 10 | export const HUP = 1; 11 | export const INT = 2; 12 | export const QUIT = 3; 13 | export const ILL = 4; 14 | export const TRAP = 5; 15 | export const ABRT = 6; 16 | export const BUS = 7; 17 | export const FPE = 8; 18 | export const KILL = 9; 19 | export const USR1 = 10; 20 | export const SEGV = 11; 21 | export const USR2 = 12; 22 | export const PIPE = 13; 23 | export const ALRM = 14; 24 | export const TERM = 15; 25 | export const CHLD = 16; 26 | export const CONT = 17; 27 | export const STOP = 18; 28 | export const TSTP = 19; 29 | export const TTIN = 20; 30 | export const TTOU = 21; 31 | export const URG = 22; 32 | export const XCPU = 23; 33 | export const XFSZ = 24; 34 | export const VTALRM = 25; 35 | export const PROF = 26; 36 | export const WINCH = 27; 37 | export const POLL = 28; 38 | export const PWR = 29; 39 | export const SYS = 30; 40 | -------------------------------------------------------------------------------- /wasi-js-bindings/js/wasi/whence.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview WASI whence API constants from wasi/api.h. 7 | */ 8 | 9 | export const CUR = 0; 10 | export const END = 1; 11 | export const SET = 2; 12 | -------------------------------------------------------------------------------- /wassh/.gitignore: -------------------------------------------------------------------------------- 1 | *.i 2 | *.wasm 3 | -------------------------------------------------------------------------------- /wassh/README.md: -------------------------------------------------------------------------------- 1 | # WASSH PoC 2 | 3 | To experiment with this: 4 | 5 | 1. Run `./build.sh` in this dir. 6 | 2. Run `npm start` in the nassh/ dir to create a web server. 7 | 3. Visit http://127.0.0.1:8080/wassh/test.html 8 | -------------------------------------------------------------------------------- /wassh/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | cd "$(dirname "$(realpath "$0")")" 4 | OUT="${PWD}/../ssh_client/output" 5 | export PATH="${OUT}/bin:${OUT}/wasi-sdk/bin:${PATH}" 6 | doit() { 7 | clang \ 8 | -Wall \ 9 | --sysroot="${OUT}/wasi-sdk/share/wasi-sysroot" \ 10 | -I"${OUT}/wasi-sdk/share/wasi-sysroot/include/wassh-libc-sup" \ 11 | -O3 test.c "$@" 12 | } 13 | 14 | doit \ 15 | -o test.wasm.dbg \ 16 | -s \ 17 | -Wl,--allow-undefined-file="${OUT}/wasi-sdk/share/wasi-sysroot/lib/wassh-libc-sup.imports" \ 18 | -L"${OUT}/wasi-sdk/share/wasi-sysroot/lib" \ 19 | -lwassh-libc-sup 20 | 21 | doit -E -dD -o test.i 22 | 23 | # Only use single core here due to known bug in 89 release: 24 | # https://github.com/WebAssembly/binaryen/issues/2273 25 | export BINARYEN_CORES=1 26 | wasm-opt -O2 \ 27 | test.wasm.dbg -o test.wasm 28 | -------------------------------------------------------------------------------- /wassh/js/syscall_entry.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview Handlers for the custom wassh syscalls. 7 | */ 8 | 9 | import * as SyscallEntry from '../../wasi-js-bindings/js/syscall_entry.js'; 10 | import * as WASI from '../../wasi-js-bindings/js/wasi.js'; 11 | 12 | /** 13 | * WASSH syscall extensions. 14 | */ 15 | export class WasshExperimental extends SyscallEntry.Base { 16 | constructor(runtime) { 17 | super(runtime); 18 | this.namespace = 'wassh_experimental'; 19 | } 20 | 21 | sys_sock_create(sock, domain, type) { 22 | return WASI.errno.ENOSYS; 23 | } 24 | 25 | sys_sock_connect(sock, domain, addr, port) { 26 | return WASI.errno.ENOSYS; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /wassh/js/worker.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * @fileoverview 7 | */ 8 | 9 | import * as BackgroundWorker from '../../wasi-js-bindings/js/worker.js'; 10 | import * as Process from '../../wasi-js-bindings/js/process.js'; 11 | import * as SyscallEntry from '../../wasi-js-bindings/js/syscall_entry.js'; 12 | import * as SyscallHandler from '../../wasi-js-bindings/js/syscall_handler.js'; 13 | import * as WasshSyscallEntry from './syscall_entry.js'; 14 | import * as WasshSyscallHandler from './syscall_handler.js'; 15 | 16 | class WasshWorker extends BackgroundWorker.Base { 17 | newProcess(executable, argv, environ, sab, handler_ids) { 18 | const sys_handlers = [ 19 | new SyscallHandler.ProxyWasiUnstable(this, sab, handler_ids), 20 | new WasshSyscallHandler.DirectWasiUnstable(), 21 | ]; 22 | const sys_entries = [ 23 | new SyscallEntry.WasiUnstable({sys_handlers, trace: true}), 24 | new WasshSyscallEntry.WasshExperimental({}), 25 | ]; 26 | return new Process.Foreground({executable, argv, environ, sys_handlers, sys_entries}); 27 | } 28 | } 29 | 30 | const wassh_worker = new WasshWorker(globalThis); 31 | wassh_worker.bind(); 32 | -------------------------------------------------------------------------------- /wassh/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

 9 |   
10 | 
11 | 


--------------------------------------------------------------------------------