@andy.ian/dsh-homing 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -2
  3. package/bin/auth.mjs +159 -0
  4. package/bin/backup.mjs +118 -0
  5. package/bin/bootstrap-server.mjs +436 -0
  6. package/bin/entry-link.mjs +69 -0
  7. package/bin/nginx-dsh.template.conf +91 -0
  8. package/bin/nginx-gate.conf +9 -0
  9. package/bin/nginx-ws-map.conf +5 -0
  10. package/bin/renew-cert.mjs +127 -0
  11. package/bin/watchdog.mjs +158 -0
  12. package/cordis.patch.yml +30 -0
  13. package/icon.svg +9 -0
  14. package/index.js +3339 -0
  15. package/lib/csrf.mjs +60 -0
  16. package/lib/devices.mjs +221 -0
  17. package/lib/files-page.mjs +391 -0
  18. package/lib/files.mjs +464 -0
  19. package/lib/git.mjs +154 -0
  20. package/lib/limits.mjs +135 -0
  21. package/lib/pty.mjs +354 -0
  22. package/lib/session.mjs +216 -0
  23. package/lib/shell-page.mjs +430 -0
  24. package/lib/shell.mjs +274 -0
  25. package/lib/term-app.js +318 -0
  26. package/lib/term-page.mjs +117 -0
  27. package/lib/vendor/fonts/JetBrainsMono-Regular.ttf +0 -0
  28. package/lib/vendor/fonts/jetbrains-mono-400.woff2 +0 -0
  29. package/lib/vendor/fonts/jetbrains-mono-700.woff2 +0 -0
  30. package/lib/vendor/node_modules/@xterm/addon-fit/LICENSE +19 -0
  31. package/lib/vendor/node_modules/@xterm/addon-fit/README.md +24 -0
  32. package/lib/vendor/node_modules/@xterm/addon-fit/lib/addon-fit.js +2 -0
  33. package/lib/vendor/node_modules/@xterm/addon-fit/lib/addon-fit.js.map +1 -0
  34. package/lib/vendor/node_modules/@xterm/addon-fit/package.json +26 -0
  35. package/lib/vendor/node_modules/@xterm/addon-fit/src/FitAddon.ts +90 -0
  36. package/lib/vendor/node_modules/@xterm/addon-fit/typings/addon-fit.d.ts +55 -0
  37. package/lib/vendor/node_modules/asn1/Jenkinsfile +65 -0
  38. package/lib/vendor/node_modules/asn1/LICENSE +19 -0
  39. package/lib/vendor/node_modules/asn1/README.md +50 -0
  40. package/lib/vendor/node_modules/asn1/lib/ber/errors.js +13 -0
  41. package/lib/vendor/node_modules/asn1/lib/ber/index.js +27 -0
  42. package/lib/vendor/node_modules/asn1/lib/ber/reader.js +262 -0
  43. package/lib/vendor/node_modules/asn1/lib/ber/types.js +36 -0
  44. package/lib/vendor/node_modules/asn1/lib/ber/writer.js +317 -0
  45. package/lib/vendor/node_modules/asn1/lib/index.js +20 -0
  46. package/lib/vendor/node_modules/asn1/package.json +31 -0
  47. package/lib/vendor/node_modules/bcrypt-pbkdf/CONTRIBUTING.md +13 -0
  48. package/lib/vendor/node_modules/bcrypt-pbkdf/LICENSE +66 -0
  49. package/lib/vendor/node_modules/bcrypt-pbkdf/README.md +45 -0
  50. package/lib/vendor/node_modules/bcrypt-pbkdf/index.js +556 -0
  51. package/lib/vendor/node_modules/bcrypt-pbkdf/package.json +15 -0
  52. package/lib/vendor/node_modules/safer-buffer/LICENSE +21 -0
  53. package/lib/vendor/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  54. package/lib/vendor/node_modules/safer-buffer/Readme.md +156 -0
  55. package/lib/vendor/node_modules/safer-buffer/dangerous.js +58 -0
  56. package/lib/vendor/node_modules/safer-buffer/package.json +34 -0
  57. package/lib/vendor/node_modules/safer-buffer/safer.js +77 -0
  58. package/lib/vendor/node_modules/safer-buffer/tests.js +406 -0
  59. package/lib/vendor/node_modules/ssh2/.eslintignore +4 -0
  60. package/lib/vendor/node_modules/ssh2/.eslintrc.js +5 -0
  61. package/lib/vendor/node_modules/ssh2/.github/workflows/ci.yml +110 -0
  62. package/lib/vendor/node_modules/ssh2/.github/workflows/lint.yml +27 -0
  63. package/lib/vendor/node_modules/ssh2/LICENSE +19 -0
  64. package/lib/vendor/node_modules/ssh2/README.md +1529 -0
  65. package/lib/vendor/node_modules/ssh2/SFTP.md +413 -0
  66. package/lib/vendor/node_modules/ssh2/examples/server-chat.js +238 -0
  67. package/lib/vendor/node_modules/ssh2/examples/sftp-server-download-only.js +134 -0
  68. package/lib/vendor/node_modules/ssh2/install.js +27 -0
  69. package/lib/vendor/node_modules/ssh2/lib/Channel.js +295 -0
  70. package/lib/vendor/node_modules/ssh2/lib/agent.js +1123 -0
  71. package/lib/vendor/node_modules/ssh2/lib/client.js +2176 -0
  72. package/lib/vendor/node_modules/ssh2/lib/http-agents.js +84 -0
  73. package/lib/vendor/node_modules/ssh2/lib/index.js +44 -0
  74. package/lib/vendor/node_modules/ssh2/lib/keygen.js +582 -0
  75. package/lib/vendor/node_modules/ssh2/lib/protocol/Protocol.js +2136 -0
  76. package/lib/vendor/node_modules/ssh2/lib/protocol/SFTP.js +4052 -0
  77. package/lib/vendor/node_modules/ssh2/lib/protocol/constants.js +356 -0
  78. package/lib/vendor/node_modules/ssh2/lib/protocol/crypto/binding.gyp +23 -0
  79. package/lib/vendor/node_modules/ssh2/lib/protocol/crypto/poly1305.js +43 -0
  80. package/lib/vendor/node_modules/ssh2/lib/protocol/crypto/src/binding.cc +2300 -0
  81. package/lib/vendor/node_modules/ssh2/lib/protocol/crypto.js +1602 -0
  82. package/lib/vendor/node_modules/ssh2/lib/protocol/handlers.js +16 -0
  83. package/lib/vendor/node_modules/ssh2/lib/protocol/handlers.misc.js +1285 -0
  84. package/lib/vendor/node_modules/ssh2/lib/protocol/kex.js +1908 -0
  85. package/lib/vendor/node_modules/ssh2/lib/protocol/keyParser.js +1484 -0
  86. package/lib/vendor/node_modules/ssh2/lib/protocol/node-fs-compat.js +115 -0
  87. package/lib/vendor/node_modules/ssh2/lib/protocol/utils.js +356 -0
  88. package/lib/vendor/node_modules/ssh2/lib/protocol/zlib.js +255 -0
  89. package/lib/vendor/node_modules/ssh2/lib/server.js +1380 -0
  90. package/lib/vendor/node_modules/ssh2/lib/utils.js +336 -0
  91. package/lib/vendor/node_modules/ssh2/package.json +49 -0
  92. package/lib/vendor/node_modules/ssh2/test/common.js +316 -0
  93. package/lib/vendor/node_modules/ssh2/test/fixtures/bad_rsa_private_key +26 -0
  94. package/lib/vendor/node_modules/ssh2/test/fixtures/https_cert.pem +33 -0
  95. package/lib/vendor/node_modules/ssh2/test/fixtures/https_key.pem +52 -0
  96. package/lib/vendor/node_modules/ssh2/test/fixtures/id_dsa +12 -0
  97. package/lib/vendor/node_modules/ssh2/test/fixtures/id_ecdsa +5 -0
  98. package/lib/vendor/node_modules/ssh2/test/fixtures/id_rsa +15 -0
  99. package/lib/vendor/node_modules/ssh2/test/fixtures/id_rsa.ppk +26 -0
  100. package/lib/vendor/node_modules/ssh2/test/fixtures/id_rsa_enc +30 -0
  101. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa +21 -0
  102. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.pub +1 -0
  103. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.pub.result +7 -0
  104. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.result +7 -0
  105. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc +22 -0
  106. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.pub +1 -0
  107. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.pub.result +7 -0
  108. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.result +7 -0
  109. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm +23 -0
  110. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.pub +1 -0
  111. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.pub.result +7 -0
  112. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.result +7 -0
  113. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa +9 -0
  114. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.pub +1 -0
  115. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.pub.result +7 -0
  116. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.result +7 -0
  117. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc +10 -0
  118. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.pub +1 -0
  119. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.pub.result +8 -0
  120. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.result +7 -0
  121. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm +10 -0
  122. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.pub +1 -0
  123. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.pub.result +8 -0
  124. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.result +7 -0
  125. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519 +7 -0
  126. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.pub +1 -0
  127. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.pub.result +7 -0
  128. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.result +7 -0
  129. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa +27 -0
  130. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.pub +1 -0
  131. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.pub.result +7 -0
  132. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.result +7 -0
  133. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc +28 -0
  134. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.pub +1 -0
  135. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.pub.result +8 -0
  136. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.result +7 -0
  137. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm +29 -0
  138. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.pub +1 -0
  139. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.pub.result +8 -0
  140. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.result +7 -0
  141. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa +12 -0
  142. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.pub +1 -0
  143. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.pub.result +7 -0
  144. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.result +7 -0
  145. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc +15 -0
  146. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.pub +1 -0
  147. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.pub.result +8 -0
  148. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.result +7 -0
  149. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa +5 -0
  150. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.pub +1 -0
  151. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.pub.result +7 -0
  152. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.result +7 -0
  153. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc +8 -0
  154. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.pub +1 -0
  155. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.pub.result +8 -0
  156. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.result +7 -0
  157. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa +27 -0
  158. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.pub +1 -0
  159. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.pub.result +7 -0
  160. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.result +7 -0
  161. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc +30 -0
  162. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.pub +1 -0
  163. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.pub.result +8 -0
  164. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.result +7 -0
  165. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256 +54 -0
  166. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.pub +1 -0
  167. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.pub.result +6 -0
  168. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.result +6 -0
  169. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/ppk_dsa_enc +17 -0
  170. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/ppk_dsa_enc.result +7 -0
  171. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa +26 -0
  172. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa.result +7 -0
  173. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa_enc +18 -0
  174. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa_enc.result +7 -0
  175. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa.pub +9 -0
  176. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa.pub.result +7 -0
  177. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa2.pub +10 -0
  178. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa2.pub.result +7 -0
  179. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa3.pub +11 -0
  180. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa3.pub.result +7 -0
  181. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa4.pub +11 -0
  182. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa4.pub.result +7 -0
  183. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa5.pub +8 -0
  184. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa5.pub.result +7 -0
  185. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa6.pub +13 -0
  186. package/lib/vendor/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa6.pub.result +7 -0
  187. package/lib/vendor/node_modules/ssh2/test/fixtures/openssh_new_rsa +27 -0
  188. package/lib/vendor/node_modules/ssh2/test/fixtures/ssh_host_dsa_key +12 -0
  189. package/lib/vendor/node_modules/ssh2/test/fixtures/ssh_host_ecdsa_key +5 -0
  190. package/lib/vendor/node_modules/ssh2/test/fixtures/ssh_host_rsa_key +15 -0
  191. package/lib/vendor/node_modules/ssh2/test/test-exec.js +578 -0
  192. package/lib/vendor/node_modules/ssh2/test/test-integration-openssh.js +486 -0
  193. package/lib/vendor/node_modules/ssh2/test/test-keygen.js +60 -0
  194. package/lib/vendor/node_modules/ssh2/test/test-misc-client-server.js +1460 -0
  195. package/lib/vendor/node_modules/ssh2/test/test-openssh.js +261 -0
  196. package/lib/vendor/node_modules/ssh2/test/test-protocol-crypto.js +631 -0
  197. package/lib/vendor/node_modules/ssh2/test/test-protocol-keyparser.js +177 -0
  198. package/lib/vendor/node_modules/ssh2/test/test-server-hostkeys.js +138 -0
  199. package/lib/vendor/node_modules/ssh2/test/test-sftp.js +842 -0
  200. package/lib/vendor/node_modules/ssh2/test/test-shell.js +109 -0
  201. package/lib/vendor/node_modules/ssh2/test/test-userauth-agent-openssh.js +110 -0
  202. package/lib/vendor/node_modules/ssh2/test/test-userauth-agent.js +171 -0
  203. package/lib/vendor/node_modules/ssh2/test/test-userauth.js +611 -0
  204. package/lib/vendor/node_modules/ssh2/test/test-worker-imports.js +25 -0
  205. package/lib/vendor/node_modules/ssh2/test/test.js +20 -0
  206. package/lib/vendor/node_modules/ssh2/util/build_pagent.bat +2 -0
  207. package/lib/vendor/node_modules/ssh2/util/pagent.c +88 -0
  208. package/lib/vendor/node_modules/ssh2/util/pagent.exe +0 -0
  209. package/lib/vendor/node_modules/tweetnacl/AUTHORS.md +27 -0
  210. package/lib/vendor/node_modules/tweetnacl/CHANGELOG.md +283 -0
  211. package/lib/vendor/node_modules/tweetnacl/LICENSE +24 -0
  212. package/lib/vendor/node_modules/tweetnacl/PULL_REQUEST_TEMPLATE.md +20 -0
  213. package/lib/vendor/node_modules/tweetnacl/README.md +494 -0
  214. package/lib/vendor/node_modules/tweetnacl/nacl-fast.js +2391 -0
  215. package/lib/vendor/node_modules/tweetnacl/nacl-fast.min.js +1 -0
  216. package/lib/vendor/node_modules/tweetnacl/nacl.d.ts +98 -0
  217. package/lib/vendor/node_modules/tweetnacl/nacl.js +1178 -0
  218. package/lib/vendor/node_modules/tweetnacl/nacl.min.js +1 -0
  219. package/lib/vendor/node_modules/tweetnacl/package.json +56 -0
  220. package/lib/vendor/xterm.css +218 -0
  221. package/lib/vendor/xterm.js +2 -0
  222. package/locale/en.json +6 -0
  223. package/locale/zh.json +6 -0
  224. package/ops/watchdog/dsh-watchdog.ps1 +105 -0
  225. package/ops/watchdog/restart-now.ps1 +247 -0
  226. package/package.json +69 -4
@@ -0,0 +1,117 @@
1
+ /**
2
+ * /term 页面:真终端(xterm.js + SSH PTY)。
3
+ *
4
+ * 和 /shell 的区别:
5
+ * - /shell 是"管道执行",只有纯文本输出,vim/top/REPL 不可用
6
+ * - /term 通过 ssh -tt 连本机 sshd,远端 bash 拿到真 ConPTY,ANSI 由 xterm.js 渲染
7
+ *
8
+ * 为了满足 CSP(不引外网脚本),xterm.js / xterm.css 都从本地 /term/vendor/ 提供,
9
+ * 页面自身的脚本也从 /term/app.js 单独加载(不在 HTML 里内联)。
10
+ */
11
+ const escapeHtml = (value) => String(value ?? '')
12
+ .replaceAll('&', '&')
13
+ .replaceAll('<', '&lt;')
14
+ .replaceAll('>', '&gt;')
15
+ .replaceAll('"', '&quot;')
16
+
17
+ const STYLE = `
18
+ /* 等宽字体:JetBrains Mono(woff2,两档各 21KB,随页面加载,手机不用装) */
19
+ @font-face {
20
+ font-family: 'DSH Mono';
21
+ font-style: normal;
22
+ font-weight: 400;
23
+ font-display: swap;
24
+ src: url('/term/vendor/fonts/jetbrains-mono-400.woff2') format('woff2');
25
+ }
26
+ @font-face {
27
+ font-family: 'DSH Mono';
28
+ font-style: normal;
29
+ font-weight: 700;
30
+ font-display: swap;
31
+ src: url('/term/vendor/fonts/jetbrains-mono-700.woff2') format('woff2');
32
+ }
33
+ :root { color-scheme: dark; }
34
+ * { box-sizing: border-box; }
35
+ html, body { height: 100%; margin: 0; }
36
+ body {
37
+ background: #0c0c0c; color: #cccccc; display: flex; flex-direction: column;
38
+ font-family: 'DSH Mono', ui-monospace, monospace; font-size: 13px;
39
+ overflow: hidden;
40
+ }
41
+ .bar {
42
+ flex: 0 0 auto; display: flex; gap: 10px; align-items: center;
43
+ padding: 5px 8px; background: #1c1c1c; border-bottom: 1px solid #2a2a2a;
44
+ font-size: 11px; color: #9a9a9a; white-space: nowrap; overflow: hidden;
45
+ }
46
+ .bar a { color: #6cb6ff; text-decoration: none; }
47
+ .bar .spacer { flex: 1; }
48
+ #status { color: #7a7a7a; }
49
+ #mode { padding: 1px 6px; border-radius: 4px; background: #2a2a2a; color: #bdbdbd; }
50
+ #mode.mode-insert { background: #1f4d2b; color: #8ff0a4; }
51
+ #mode.mode-underline { background: #3a3a1f; color: #f0e68c; }
52
+ #mode.mode-normal { background: #2a2a2a; color: #bdbdbd; }
53
+ #status.bad { color: #ff8f8f; }
54
+ #t { flex: 1 1 auto; overflow: hidden; padding: 6px; }
55
+ #t .xterm { height: 100%; }
56
+ #t .xterm-viewport { background: #0c0c0c !important; }
57
+ /* 功能键:按用途分三排,每排 4 个(4 列网格,永不溢出)
58
+ 第 1 排 输入辅助:Ctrl / Esc / Tab / Ins
59
+ 第 2 排 光标移动:← ↑ ↓ →
60
+ 第 3 排 视图会话:A- / A+ / 清屏 / 重启 */
61
+ .keys {
62
+ flex: 0 0 auto; display: grid; grid-template-columns: repeat(4, 1fr);
63
+ gap: 6px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
64
+ background: #161616; border-top: 1px solid #2a2a2a;
65
+ }
66
+ .keys button {
67
+ width: 100%; min-width: 0; padding: 9px 4px; border-radius: 6px;
68
+ border: 1px solid #333; background: #232323; color: #cfcfcf; font: inherit; font-size: 12px;
69
+ }
70
+ /* 方向键单独一点的分隔感:给第二排加一条极淡的上边框 */
71
+ .keys button.arrow { background: #1d1d1d; }
72
+ .keys button.pressed { background: #2d5bd7; border-color: #2d5bd7; color: #fff; }
73
+ .keys button.warn { border-color: #5a2a2a; color: #f0b6bf; }
74
+ `
75
+
76
+ export function renderTermPage({ cwd = '', host = '', user = '', connected = true } = {}) {
77
+ return `<!doctype html>
78
+ <html lang="zh-CN"><head>
79
+ <meta charset="utf-8">
80
+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
81
+ <title>终端 · DSH</title>
82
+ <link rel="stylesheet" href="/term/vendor/xterm.css">
83
+ <style>${STYLE}</style>
84
+ </head>
85
+ <body>
86
+ <div class="bar">
87
+ <a href="/">DSH</a>
88
+ <a href="/files?path=${encodeURIComponent(cwd)}">文件</a>
89
+ <a href="/git?path=${encodeURIComponent(cwd)}">Git</a>
90
+ <span class="spacer"></span>
91
+ <span style="overflow:hidden;text-overflow:ellipsis">${escapeHtml(user)}@${escapeHtml(host)}</span>
92
+ <span id="mode" title="光标模式" hidden>普通</span>
93
+ <span id="status">${connected ? '连接中…' : '未连接'}</span>
94
+ </div>
95
+ <div id="t"></div>
96
+ <div class="keys">
97
+ <!-- 第 1 排:输入辅助 -->
98
+ <button type="button" id="ctrl" aria-pressed="false">Ctrl</button>
99
+ <button type="button" id="esc">Esc</button>
100
+ <button type="button" id="tab">Tab</button>
101
+ <button type="button" id="ins">Ins</button>
102
+ <!-- 第 2 排:光标移动(按 ← ↑ ↓ → 的自然顺序) -->
103
+ <button type="button" id="left" class="arrow">←</button>
104
+ <button type="button" id="up" class="arrow">↑</button>
105
+ <button type="button" id="down" class="arrow">↓</button>
106
+ <button type="button" id="right" class="arrow">→</button>
107
+ <!-- 第 3 排:视图与会话 -->
108
+ <button type="button" id="zoomOut">A-</button>
109
+ <button type="button" id="zoomIn">A+</button>
110
+ <button type="button" id="clear">清屏</button>
111
+ <button type="button" id="reset" class="warn">重启</button>
112
+ </div>
113
+ <script src="/term/vendor/xterm.js"></script>
114
+ <script src="/term/vendor/addon-fit.js"></script>
115
+ <script src="/term/app.js"></script>
116
+ </body></html>`
117
+ }
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
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
11
+ all 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
19
+ THE SOFTWARE.
@@ -0,0 +1,24 @@
1
+ ## @xterm/addon-fit
2
+
3
+ An addon for [xterm.js](https://github.com/xtermjs/xterm.js) that enables fitting the terminal's dimensions to a containing element. This addon requires xterm.js v4+.
4
+
5
+ ### Install
6
+
7
+ ```bash
8
+ npm install --save @xterm/addon-fit
9
+ ```
10
+
11
+ ### Usage
12
+
13
+ ```ts
14
+ import { Terminal } from '@xterm/xterm';
15
+ import { FitAddon } from '@xterm/addon-fit';
16
+
17
+ const terminal = new Terminal();
18
+ const fitAddon = new FitAddon();
19
+ terminal.loadAddon(fitAddon);
20
+ terminal.open(containerElement);
21
+ fitAddon.fit();
22
+ ```
23
+
24
+ See the full [API](https://github.com/xtermjs/xterm.js/blob/master/addons/addon-fit/typings/addon-fit.d.ts) for more advanced usage.
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(self,(()=>(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const r=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,i=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),l=o-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),a=s-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-r;return{cols:Math.max(2,Math.floor(a/t.css.cell.width)),rows:Math.max(1,Math.floor(l/t.css.cell.height))}}}})(),e})()));
2
+ //# sourceMappingURL=addon-fit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addon-fit.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAkB,SAAID,IAEtBD,EAAe,SAAIC,GACpB,CATD,CASGK,MAAM,I,mHCeT,iBAGS,QAAAC,CAASC,GACdC,KAAKC,UAAYF,CACnB,CAEO,OAAAG,GAAiB,CAEjB,GAAAC,GACL,MAAMC,EAAOJ,KAAKK,oBAClB,IAAKD,IAASJ,KAAKC,WAAaK,MAAMF,EAAKG,OAASD,MAAMF,EAAKI,MAC7D,OAIF,MAAMC,EAAQT,KAAKC,UAAkBS,MAGjCV,KAAKC,UAAUO,OAASJ,EAAKI,MAAQR,KAAKC,UAAUM,OAASH,EAAKG,OACpEE,EAAKE,eAAeC,QACpBZ,KAAKC,UAAUY,OAAOT,EAAKG,KAAMH,EAAKI,MAE1C,CAEO,iBAAAH,GACL,IAAKL,KAAKC,UACR,OAGF,IAAKD,KAAKC,UAAUa,UAAYd,KAAKC,UAAUa,QAAQC,cACrD,OAIF,MAAMN,EAAQT,KAAKC,UAAkBS,MAC/BN,EAA0BK,EAAKE,eAAeK,WAEpD,GAA4B,IAAxBZ,EAAKa,IAAIC,KAAKC,OAAwC,IAAzBf,EAAKa,IAAIC,KAAKE,OAC7C,OAGF,MAAMC,EAAuD,IAAtCrB,KAAKC,UAAUqB,QAAQC,WAC5C,EAAId,EAAKe,SAASC,eAEdC,EAAqBC,OAAOC,iBAAiB5B,KAAKC,UAAUa,QAAQC,eACpEc,EAAsBC,SAASJ,EAAmBK,iBAAiB,WACnEC,EAAqBC,KAAKC,IAAI,EAAGJ,SAASJ,EAAmBK,iBAAiB,WAC9EI,EAAeR,OAAOC,iBAAiB5B,KAAKC,UAAUa,SAStDsB,EAAkBP,GAPjBC,SAASK,EAAaJ,iBAAiB,gBACpCD,SAASK,EAAaJ,iBAAiB,oBAO3CM,EAAiBL,GANdF,SAASK,EAAaJ,iBAAiB,kBACxCD,SAASK,EAAaJ,iBAAiB,kBAKiBV,EAKhE,MAJiB,CACfd,KAAM0B,KAAKC,IA/DI,EA+DcD,KAAKK,MAAMD,EAAiBjC,EAAKa,IAAIC,KAAKC,QACvEX,KAAMyB,KAAKC,IA/DI,EA+DcD,KAAKK,MAAMF,EAAkBhC,EAAKa,IAAIC,KAAKE,SAG5E,E","sources":["webpack://FitAddon/webpack/universalModuleDefinition","webpack://FitAddon/./src/FitAddon.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FitAddon\"] = factory();\n\telse\n\t\troot[\"FitAddon\"] = factory();\n})(self, () => {\nreturn ","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport type { Terminal, ITerminalAddon } from '@xterm/xterm';\nimport type { FitAddon as IFitApi } from '@xterm/addon-fit';\nimport { IRenderDimensions } from 'browser/renderer/shared/Types';\n\ninterface ITerminalDimensions {\n /**\n * The number of rows in the terminal.\n */\n rows: number;\n\n /**\n * The number of columns in the terminal.\n */\n cols: number;\n}\n\nconst MINIMUM_COLS = 2;\nconst MINIMUM_ROWS = 1;\n\nexport class FitAddon implements ITerminalAddon , IFitApi {\n private _terminal: Terminal | undefined;\n\n public activate(terminal: Terminal): void {\n this._terminal = terminal;\n }\n\n public dispose(): void {}\n\n public fit(): void {\n const dims = this.proposeDimensions();\n if (!dims || !this._terminal || isNaN(dims.cols) || isNaN(dims.rows)) {\n return;\n }\n\n // TODO: Remove reliance on private API\n const core = (this._terminal as any)._core;\n\n // Force a full render\n if (this._terminal.rows !== dims.rows || this._terminal.cols !== dims.cols) {\n core._renderService.clear();\n this._terminal.resize(dims.cols, dims.rows);\n }\n }\n\n public proposeDimensions(): ITerminalDimensions | undefined {\n if (!this._terminal) {\n return undefined;\n }\n\n if (!this._terminal.element || !this._terminal.element.parentElement) {\n return undefined;\n }\n\n // TODO: Remove reliance on private API\n const core = (this._terminal as any)._core;\n const dims: IRenderDimensions = core._renderService.dimensions;\n\n if (dims.css.cell.width === 0 || dims.css.cell.height === 0) {\n return undefined;\n }\n\n const scrollbarWidth = this._terminal.options.scrollback === 0 ?\n 0 : core.viewport.scrollBarWidth;\n\n const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);\n const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));\n const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));\n const elementStyle = window.getComputedStyle(this._terminal.element);\n const elementPadding = {\n top: parseInt(elementStyle.getPropertyValue('padding-top')),\n bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),\n right: parseInt(elementStyle.getPropertyValue('padding-right')),\n left: parseInt(elementStyle.getPropertyValue('padding-left'))\n };\n const elementPaddingVer = elementPadding.top + elementPadding.bottom;\n const elementPaddingHor = elementPadding.right + elementPadding.left;\n const availableHeight = parentElementHeight - elementPaddingVer;\n const availableWidth = parentElementWidth - elementPaddingHor - scrollbarWidth;\n const geometry = {\n cols: Math.max(MINIMUM_COLS, Math.floor(availableWidth / dims.css.cell.width)),\n rows: Math.max(MINIMUM_ROWS, Math.floor(availableHeight / dims.css.cell.height))\n };\n return geometry;\n }\n}\n"],"names":["root","factory","exports","module","define","amd","self","activate","terminal","this","_terminal","dispose","fit","dims","proposeDimensions","isNaN","cols","rows","core","_core","_renderService","clear","resize","element","parentElement","dimensions","css","cell","width","height","scrollbarWidth","options","scrollback","viewport","scrollBarWidth","parentElementStyle","window","getComputedStyle","parentElementHeight","parseInt","getPropertyValue","parentElementWidth","Math","max","elementStyle","availableHeight","availableWidth","floor"],"sourceRoot":""}
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@xterm/addon-fit",
3
+ "version": "0.10.0",
4
+ "author": {
5
+ "name": "The xterm.js authors",
6
+ "url": "https://xtermjs.org/"
7
+ },
8
+ "main": "lib/addon-fit.js",
9
+ "types": "typings/addon-fit.d.ts",
10
+ "repository": "https://github.com/xtermjs/xterm.js/tree/master/addons/addon-fit",
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "terminal",
14
+ "xterm",
15
+ "xterm.js"
16
+ ],
17
+ "scripts": {
18
+ "build": "../../node_modules/.bin/tsc -p .",
19
+ "prepackage": "npm run build",
20
+ "package": "../../node_modules/.bin/webpack",
21
+ "prepublishOnly": "npm run package"
22
+ },
23
+ "peerDependencies": {
24
+ "@xterm/xterm": "^5.0.0"
25
+ }
26
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Copyright (c) 2017 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import type { Terminal, ITerminalAddon } from '@xterm/xterm';
7
+ import type { FitAddon as IFitApi } from '@xterm/addon-fit';
8
+ import { IRenderDimensions } from 'browser/renderer/shared/Types';
9
+
10
+ interface ITerminalDimensions {
11
+ /**
12
+ * The number of rows in the terminal.
13
+ */
14
+ rows: number;
15
+
16
+ /**
17
+ * The number of columns in the terminal.
18
+ */
19
+ cols: number;
20
+ }
21
+
22
+ const MINIMUM_COLS = 2;
23
+ const MINIMUM_ROWS = 1;
24
+
25
+ export class FitAddon implements ITerminalAddon , IFitApi {
26
+ private _terminal: Terminal | undefined;
27
+
28
+ public activate(terminal: Terminal): void {
29
+ this._terminal = terminal;
30
+ }
31
+
32
+ public dispose(): void {}
33
+
34
+ public fit(): void {
35
+ const dims = this.proposeDimensions();
36
+ if (!dims || !this._terminal || isNaN(dims.cols) || isNaN(dims.rows)) {
37
+ return;
38
+ }
39
+
40
+ // TODO: Remove reliance on private API
41
+ const core = (this._terminal as any)._core;
42
+
43
+ // Force a full render
44
+ if (this._terminal.rows !== dims.rows || this._terminal.cols !== dims.cols) {
45
+ core._renderService.clear();
46
+ this._terminal.resize(dims.cols, dims.rows);
47
+ }
48
+ }
49
+
50
+ public proposeDimensions(): ITerminalDimensions | undefined {
51
+ if (!this._terminal) {
52
+ return undefined;
53
+ }
54
+
55
+ if (!this._terminal.element || !this._terminal.element.parentElement) {
56
+ return undefined;
57
+ }
58
+
59
+ // TODO: Remove reliance on private API
60
+ const core = (this._terminal as any)._core;
61
+ const dims: IRenderDimensions = core._renderService.dimensions;
62
+
63
+ if (dims.css.cell.width === 0 || dims.css.cell.height === 0) {
64
+ return undefined;
65
+ }
66
+
67
+ const scrollbarWidth = this._terminal.options.scrollback === 0 ?
68
+ 0 : core.viewport.scrollBarWidth;
69
+
70
+ const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);
71
+ const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
72
+ const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
73
+ const elementStyle = window.getComputedStyle(this._terminal.element);
74
+ const elementPadding = {
75
+ top: parseInt(elementStyle.getPropertyValue('padding-top')),
76
+ bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
77
+ right: parseInt(elementStyle.getPropertyValue('padding-right')),
78
+ left: parseInt(elementStyle.getPropertyValue('padding-left'))
79
+ };
80
+ const elementPaddingVer = elementPadding.top + elementPadding.bottom;
81
+ const elementPaddingHor = elementPadding.right + elementPadding.left;
82
+ const availableHeight = parentElementHeight - elementPaddingVer;
83
+ const availableWidth = parentElementWidth - elementPaddingHor - scrollbarWidth;
84
+ const geometry = {
85
+ cols: Math.max(MINIMUM_COLS, Math.floor(availableWidth / dims.css.cell.width)),
86
+ rows: Math.max(MINIMUM_ROWS, Math.floor(availableHeight / dims.css.cell.height))
87
+ };
88
+ return geometry;
89
+ }
90
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import { Terminal, ITerminalAddon } from '@xterm/xterm';
7
+
8
+ declare module '@xterm/addon-fit' {
9
+ /**
10
+ * An xterm.js addon that enables resizing the terminal to the dimensions of
11
+ * its containing element.
12
+ */
13
+ export class FitAddon implements ITerminalAddon {
14
+ /**
15
+ * Creates a new fit addon.
16
+ */
17
+ constructor();
18
+
19
+ /**
20
+ * Activates the addon
21
+ * @param terminal The terminal the addon is being loaded in.
22
+ */
23
+ public activate(terminal: Terminal): void;
24
+
25
+ /**
26
+ * Disposes the addon.
27
+ */
28
+ public dispose(): void;
29
+
30
+ /**
31
+ * Resizes the terminal to the dimensions of its containing element.
32
+ */
33
+ public fit(): void;
34
+
35
+ /**
36
+ * Gets the proposed dimensions that will be used for a fit.
37
+ */
38
+ public proposeDimensions(): ITerminalDimensions | undefined;
39
+ }
40
+
41
+ /**
42
+ * Reprepresents the dimensions of a terminal.
43
+ */
44
+ export interface ITerminalDimensions {
45
+ /**
46
+ * The number of rows in the terminal.
47
+ */
48
+ rows: number;
49
+
50
+ /**
51
+ * The number of columns in the terminal.
52
+ */
53
+ cols: number;
54
+ }
55
+ }
@@ -0,0 +1,65 @@
1
+ @Library('jenkins-joylib@v1.0.8') _
2
+
3
+ pipeline {
4
+
5
+ agent none
6
+
7
+ options {
8
+ buildDiscarder(logRotator(numToKeepStr: '45'))
9
+ timestamps()
10
+ }
11
+
12
+ stages {
13
+ stage('top') {
14
+ parallel {
15
+ stage('v4-zone') {
16
+ agent {
17
+ label joyCommonLabels(image_ver: '15.4.1')
18
+ }
19
+ tools {
20
+ nodejs 'sdcnode-v4-zone'
21
+ }
22
+ stages {
23
+ stage('check') {
24
+ steps{
25
+ sh('make check')
26
+ }
27
+ }
28
+ stage('test') {
29
+ steps{
30
+ sh('make test')
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ stage('v6-zone64') {
37
+ agent {
38
+ label joyCommonLabels(image_ver: '18.4.0')
39
+ }
40
+ tools {
41
+ nodejs 'sdcnode-v6-zone64'
42
+ }
43
+ stages {
44
+ stage('check') {
45
+ steps{
46
+ sh('make check')
47
+ }
48
+ }
49
+ stage('test') {
50
+ steps{
51
+ sh('make test')
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ post {
61
+ always {
62
+ joySlackNotifications()
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2011 Mark Cavage, All rights reserved.
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
11
+ all 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
19
+ THE SOFTWARE
@@ -0,0 +1,50 @@
1
+ node-asn1 is a library for encoding and decoding ASN.1 datatypes in pure JS.
2
+ Currently BER encoding is supported; at some point I'll likely have to do DER.
3
+
4
+ ## Usage
5
+
6
+ Mostly, if you're *actually* needing to read and write ASN.1, you probably don't
7
+ need this readme to explain what and why. If you have no idea what ASN.1 is,
8
+ see this: ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
9
+
10
+ The source is pretty much self-explanatory, and has read/write methods for the
11
+ common types out there.
12
+
13
+ ### Decoding
14
+
15
+ The following reads an ASN.1 sequence with a boolean.
16
+
17
+ var Ber = require('asn1').Ber;
18
+
19
+ var reader = new Ber.Reader(Buffer.from([0x30, 0x03, 0x01, 0x01, 0xff]));
20
+
21
+ reader.readSequence();
22
+ console.log('Sequence len: ' + reader.length);
23
+ if (reader.peek() === Ber.Boolean)
24
+ console.log(reader.readBoolean());
25
+
26
+ ### Encoding
27
+
28
+ The following generates the same payload as above.
29
+
30
+ var Ber = require('asn1').Ber;
31
+
32
+ var writer = new Ber.Writer();
33
+
34
+ writer.startSequence();
35
+ writer.writeBoolean(true);
36
+ writer.endSequence();
37
+
38
+ console.log(writer.buffer);
39
+
40
+ ## Installation
41
+
42
+ npm install asn1
43
+
44
+ ## License
45
+
46
+ MIT.
47
+
48
+ ## Bugs
49
+
50
+ See <https://github.com/joyent/node-asn1/issues>.
@@ -0,0 +1,13 @@
1
+ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2
+
3
+
4
+ module.exports = {
5
+
6
+ newInvalidAsn1Error: function (msg) {
7
+ var e = new Error();
8
+ e.name = 'InvalidAsn1Error';
9
+ e.message = msg || '';
10
+ return e;
11
+ }
12
+
13
+ };
@@ -0,0 +1,27 @@
1
+ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2
+
3
+ var errors = require('./errors');
4
+ var types = require('./types');
5
+
6
+ var Reader = require('./reader');
7
+ var Writer = require('./writer');
8
+
9
+
10
+ // --- Exports
11
+
12
+ module.exports = {
13
+
14
+ Reader: Reader,
15
+
16
+ Writer: Writer
17
+
18
+ };
19
+
20
+ for (var t in types) {
21
+ if (types.hasOwnProperty(t))
22
+ module.exports[t] = types[t];
23
+ }
24
+ for (var e in errors) {
25
+ if (errors.hasOwnProperty(e))
26
+ module.exports[e] = errors[e];
27
+ }