@codua/codeoutline-win32-x64 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/DISTRIBUTION.md CHANGED
@@ -97,3 +97,56 @@ workflow does not mean its remote runs have passed. Windows npm launchers forwar
97
97
  console signals; forcefully killing the Node process alone cannot forward a
98
98
  signal. For supervised HTTP services on Windows, use the native launcher or stop
99
99
  the process tree. Closing MCP stdin causes the native stdio service to exit.
100
+
101
+ ## Signed self-updates
102
+
103
+ Starting with 0.1.3, npm and native launchers can run signed versions stored in
104
+ `~/.codeoutline/updates` (the user profile on Windows). npm remains the initial
105
+ installation and recovery version. An older npm installation needs one npm upgrade
106
+ to acquire this updater. Updating does not change npm's recorded package version;
107
+ `codeoutline --version` reports the version actually running.
108
+
109
+ ```sh
110
+ codeoutline update --check
111
+ codeoutline update
112
+ codeoutline update --rollback
113
+ ```
114
+
115
+ `serve` checks for updates before starting. A verified update applies to that new
116
+ process; existing services keep running. Failed checks retain the local version.
117
+ Other commands select a verified installed version without requesting the network.
118
+ Set `CODEOUTLINE_AUTO_UPDATE=0` to disable automatic checks. Manual update still works.
119
+ Rollback switches between the two installed versions; after the first update it
120
+ returns to the initial installation. Accepted sequence numbers are retained, so a
121
+ rolled-back release is not immediately reinstalled by automatic checks.
122
+
123
+ The default endpoint is `https://43.133.255.193:51215`, project `codeoutline`,
124
+ channel `stable`. Packages pin the signing public key and the server's TLS CA in
125
+ `keys/`. Private signing keys stay outside the repository and update server.
126
+ `CODEOUTLINE_UPDATE_URL`, `CODEOUTLINE_UPDATE_PROJECT`,
127
+ `CODEOUTLINE_UPDATE_CHANNEL`, `CODEOUTLINE_UPDATE_DIR`,
128
+ `CODEOUTLINE_UPDATE_PUBLIC_KEY`, `CODEOUTLINE_UPDATE_CA`, and
129
+ `CODEOUTLINE_UPDATE_TARGET` override these settings for testing or private deployments.
130
+ Treat these overrides and the initial installation as trusted configuration.
131
+
132
+ To publish, stage a fresh native package for each target with
133
+ `UPDATE_SEQUENCE=N`; N must increase for every release (the 0.1.3 baseline is 3).
134
+ Use XUpgate's `tools/release.py` with the same version and sequence,
135
+ `--entry scripts/codeoutline/command.lua`, and
136
+ `--runtime bin/xnet.exe` for Windows or `--runtime bin/xnet` otherwise.
137
+ Sign the native directory with the project's offline private key, upload the signed
138
+ artifact in XUpgate, then publish its version to the desired channel. The updater
139
+ checks signatures, file hashes, platform, version, sequence and runtime health
140
+ before activating the directory. CI must produce each platform runtime; a Windows
141
+ package cannot update a Linux or macOS installation.
142
+
143
+ The opt-in deployed integration test needs Python, OpenSSL, a staged Windows
144
+ package, and the sibling XUpgate release builder:
145
+
146
+ ```powershell
147
+ python tests/update-deployed.py --stage .update-test/final --credential-file C:/private/xupgate-admin.env
148
+ ```
149
+
150
+ The credential file contains `ADMIN_TOKEN=...`. The test creates a separate project,
151
+ exercises manual and automatic updates, rollback and tamper rejection, and disables
152
+ the project on exit. It never publishes to the production CodeOutline channel.
package/bin/xnet.exe CHANGED
Binary file
package/build-info.json CHANGED
@@ -1 +1 @@
1
- {"runtimeCommit":"f2c3ddfcbd3f04d7dd71543d0878d06e033519a0","lua":"LuaJIT 2.1.1774896198","sourceCommit":"130ebb1f85ca78c52119407f04a45fcb51a51ba6","sourceDirty":false,"releaseReady":true,"note":"Release build from a clean checkout","version":"0.1.2","target":"win32-x64","sha256":{"README.zh-CN.md":"4c2ff0fe0b73b3052f067926e45f9f9792571d9d529c731567b2c0d3b1d2c844","scripts/codeoutline/lang/python.lua":"f7219c04914673ee6bae387c222b09acd433596c746237bdd6650a4f4087b17c","DISTRIBUTION.md":"0de1a4699845a93c811a60bbb1dd3f7c1c4f39916c26e912fed5e621bcaf8b91","scripts/codeoutline/index_worker.lua":"47f80807a458d5c706b1a54f60fb2200ae51f022b21d9039df44611035e9ac40","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/codeoutline/lang/rust.lua":"f7c21751b1ab08512a406f45bd53546dddfa98ff680b1374d29a4152ae110023","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675","scripts/codeoutline/main.lua":"287c48d3006bf94fcf84e5e14b9a0a7379857c450f05bd850e3cb29119615d90","scripts/codeoutline/cli.lua":"ba996c3c3def65aab08ba60141a7a98a19dfcc1bbe004ab5d8ea14a7f9f9a08b","scripts/codeoutline/version.lua":"76d6123c414a5d03314de604c292f44e63e51ea3246f2702fca7ab93083b8dae","scripts/codeoutline/lang/c.lua":"1251352bcfac6b6d3704460e00b06cf4f41232144748b41b89db04a5ab594073","scripts/codeoutline/mcp.lua":"f14a2d0b9625544ad32309358121a5ff304839780f52d5c1c8ec548d56c5e901","scripts/codeoutline/command.lua":"e0fabf964487972eee3440f9b4b5e4b85bc713dd0266d7a429a53a96249150a6","scripts/codeoutline/xscan.lua":"508d1fdccee4e856e0f198992bec45d7c8a9a3c191e0a5f71717741db9e00325","scripts/codeoutline/parse.lua":"ccda7a087dc90109fce7a1e64ebe1de0d7c7036990b81b3423ff14b4299bf38f","scripts/codeoutline/common.lua":"ee775ed5b2f7ada7a02851f44b51bd4008bceacbf9700576a474e6732e3c03c2","scripts/codeoutline/lang/csharp.lua":"36ac648b8691c85b8c75d5bcb146fcdfc87992a278e4798f3eb194124e3df2bb","scripts/codeoutline/control.lua":"1dfbea9f1397d9fb3c321c48a8d8ee7fc7928e864588226e55247bd548255bb4","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/explore.lua":"d9e4e0d0179d00205df96ad0e7442e7bbc87e27481e6d27eb772ca302b5f35d3","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","THIRD_PARTY.md":"a70238f26ec05b7be4b813fa49c337cfb4d3cd64c36fcd27401d121e0e6e38df","README.md":"a1757e831f9d60d14cf318bd47cf8d9481a3e65b7bf99922064445d5d4913c89","scripts/codeoutline/graph.lua":"1ef35f2e92e9db3bbe9b612bb0cb336a9b57b440c9a066e7ba3ef81574326834","licenses/rpmalloc.txt":"f6c10eb9ec349900767c3dcb8bc71fe4fba2aefea329f05e2608827188016c0f","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/codeoutline/lang/js.lua":"7a25a195356deeef7da3fdaf6e8a483b2a3a230cae3064e5dde2a3556fdcbda9","scripts/codeoutline/lang/go.lua":"f5717cbeabe6d30dad72c473fa445480d7fb6b5546bb262e5f4c46185f0959da","scripts/codeoutline/lang/cpp.lua":"96aebcd8972d5272c11446257f37fe90c10f4130c3c1b5bb71c793d7c25456f4","scripts/codeoutline/http.lua":"33802130445b348ce607e9891d4a9789d34b18338bf5d296f56e0b3c7b0c5493","bin/xnet.exe":"8c04f418e6784ff77405ba6ae50301cea0022af585269a4b57564854723cc442","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","scripts/codeoutline/lang/lua.lua":"33b038192425e4db29251674e30c73b7a1af849789c49ff6430ee409c062f812","scripts/codeoutline/service.lua":"597c435309abc0d8149b5e88095896c3bba6516146fd587d53b4b6fbf23a553c","scripts/codeoutline/lang/java.lua":"435b6ddcd231679db9e705a604344a3fb6c00b84cc20b2ecd210423ee0b376a6","scripts/codeoutline/index.lua":"08c585a7cb264962ac04beb3bf5bc8a9dd22b4f85644b6fdd6a4e527843fbee9"}}
1
+ {"sourceDirty":false,"releaseReady":true,"version":"0.1.3","sha256":{"scripts/codeoutline/lang/c.lua":"1251352bcfac6b6d3704460e00b06cf4f41232144748b41b89db04a5ab594073","scripts/codeoutline/version.lua":"635bc8cc8a89fcfedfe2a3eaafaa6a061f84f72f832b0e39f98f302ba997ffda","scripts/codeoutline/parse.lua":"ccda7a087dc90109fce7a1e64ebe1de0d7c7036990b81b3423ff14b4299bf38f","scripts/codeoutline/command.lua":"a2e6f938897407f99573779b71948968cd743e331ca2cd0076cc1a9170559c30","scripts/codeoutline/lang/cpp.lua":"96aebcd8972d5272c11446257f37fe90c10f4130c3c1b5bb71c793d7c25456f4","scripts/codeoutline/common.lua":"ee775ed5b2f7ada7a02851f44b51bd4008bceacbf9700576a474e6732e3c03c2","scripts/codeoutline/lang/csharp.lua":"36ac648b8691c85b8c75d5bcb146fcdfc87992a278e4798f3eb194124e3df2bb","codeoutline":"8d00b52027511d56136c8bd345666d2a14ad49591313c80a016d6032f708c02b","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","scripts/codeoutline/control.lua":"1dfbea9f1397d9fb3c321c48a8d8ee7fc7928e864588226e55247bd548255bb4","keys/update-ca.crt":"d9b5ec3d4628de9c5559871f39841a5f84d47c53ded4d58d6e3bba2b4c669a02","scripts/codeoutline/lang/go.lua":"f5717cbeabe6d30dad72c473fa445480d7fb6b5546bb262e5f4c46185f0959da","scripts/xupgate/client.lua":"4bcefd14802f5d44c7c7e5b5aeda25247957212605f426da8c9dfb84ed7f9758","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","scripts/codeoutline/explore.lua":"d9e4e0d0179d00205df96ad0e7442e7bbc87e27481e6d27eb772ca302b5f35d3","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/lang/java.lua":"435b6ddcd231679db9e705a604344a3fb6c00b84cc20b2ecd210423ee0b376a6","scripts/xupgate/common.lua":"7eb979277887dfae16b325ffdab493673f01b96d00b9c1de11d8aca297368752","scripts/codeoutline/graph.lua":"1ef35f2e92e9db3bbe9b612bb0cb336a9b57b440c9a066e7ba3ef81574326834","scripts/codeoutline/lang/js.lua":"7a25a195356deeef7da3fdaf6e8a483b2a3a230cae3064e5dde2a3556fdcbda9","scripts/xupgate/http_client.lua":"a189506c3d0fcc454f5e001fdeecdd6349a1019ea0970d11ce2fbfdf035166d6","scripts/codeoutline/http.lua":"33802130445b348ce607e9891d4a9789d34b18338bf5d296f56e0b3c7b0c5493","codeoutline.cmd":"6414f7fac4c7e384d5b8e9e5e8a89731f7950b48dbe08bcbe149c1a70dbc4407","scripts/codeoutline/lang/lua.lua":"33b038192425e4db29251674e30c73b7a1af849789c49ff6430ee409c062f812","DISTRIBUTION.md":"da25de66601fe22f19ee35a61b5880a1bc65c4ca81bafefb9c46fdbbfb3436da","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/index.lua":"08c585a7cb264962ac04beb3bf5bc8a9dd22b4f85644b6fdd6a4e527843fbee9","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","README.md":"a1757e831f9d60d14cf318bd47cf8d9481a3e65b7bf99922064445d5d4913c89","scripts/codeoutline/lang/python.lua":"f7219c04914673ee6bae387c222b09acd433596c746237bdd6650a4f4087b17c","README.zh-CN.md":"4c2ff0fe0b73b3052f067926e45f9f9792571d9d529c731567b2c0d3b1d2c844","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","scripts/codeoutline/index_worker.lua":"47f80807a458d5c706b1a54f60fb2200ae51f022b21d9039df44611035e9ac40","scripts/codeoutline/service.lua":"597c435309abc0d8149b5e88095896c3bba6516146fd587d53b4b6fbf23a553c","THIRD_PARTY.md":"a70238f26ec05b7be4b813fa49c337cfb4d3cd64c36fcd27401d121e0e6e38df","scripts/codeoutline/lang/rust.lua":"f7c21751b1ab08512a406f45bd53546dddfa98ff680b1374d29a4152ae110023","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","licenses/rpmalloc.txt":"f6c10eb9ec349900767c3dcb8bc71fe4fba2aefea329f05e2608827188016c0f","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/codeoutline/main.lua":"287c48d3006bf94fcf84e5e14b9a0a7379857c450f05bd850e3cb29119615d90","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/updater.lua":"772b097af670f2d61fb92e51b9862c2964f90cd911b7720c6b1ae6906082b7f0","scripts/codeoutline/cli.lua":"ba996c3c3def65aab08ba60141a7a98a19dfcc1bbe004ab5d8ea14a7f9f9a08b","scripts/codeoutline/mcp.lua":"f14a2d0b9625544ad32309358121a5ff304839780f52d5c1c8ec548d56c5e901","bin/xnet.exe":"33ecdb8cd80d3df1bf610dd3d0ba89c0010f408626860645c82620eb5db2e3fd","scripts/codeoutline/xscan.lua":"508d1fdccee4e856e0f198992bec45d7c8a9a3c191e0a5f71717741db9e00325"},"updateSequence":3,"note":"Release build from a clean checkout","target":"win32-x64","lua":"LuaJIT 2.1.1774896198","sourceCommit":"9a786639b6cfb46257bec1ff45fe038063270ed3","runtimeCommit":"f2c3ddfcbd3f04d7dd71543d0878d06e033519a0"}
package/codeoutline CHANGED
@@ -2,4 +2,12 @@
2
2
  set -eu
3
3
  base=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
4
4
  if [ -n "${CODEOUTLINE_LOG_DIR:-}" ]; then log_out="LOG_DIR=$CODEOUTLINE_LOG_DIR"; else log_out=LOG_FILE=0; fi
5
+ if [ "${1:-}" != "update" ]; then
6
+ if [ "${CODEOUTLINE_AUTO_UPDATE:-}" = "" ]; then
7
+ if [ "${1:-}" = "serve" ]; then CODEOUTLINE_AUTO_UPDATE=1; else CODEOUTLINE_AUTO_UPDATE=0; fi
8
+ export CODEOUTLINE_AUTO_UPDATE
9
+ fi
10
+ selected=$("$base/bin/xnet" "$base/scripts/codeoutline/updater.lua" LOG_STDERR=1 LOG_FILE=0 LOG_LEVEL=ERROR ACTION=select) || selected="$base"
11
+ base="$selected"
12
+ fi
5
13
  exec "$base/bin/xnet" "$base/scripts/codeoutline/command.lua" LOG_STDERR=1 "LOG_LEVEL=${CODEOUTLINE_LOG_LEVEL:-WARN}" "$log_out" "$@"
package/codeoutline.cmd CHANGED
@@ -1,7 +1,14 @@
1
- @echo off
2
- setlocal
3
- if not defined CODEOUTLINE_LOG_LEVEL set "CODEOUTLINE_LOG_LEVEL=WARN"
4
- set "CODEOUTLINE_LOG_OUT=LOG_FILE=0"
5
- if defined CODEOUTLINE_LOG_DIR set "CODEOUTLINE_LOG_OUT=LOG_DIR=%CODEOUTLINE_LOG_DIR%"
6
- "%~dp0bin\xnet.exe" "%~dp0scripts\codeoutline\command.lua" LOG_STDERR=1 "LOG_LEVEL=%CODEOUTLINE_LOG_LEVEL%" "%CODEOUTLINE_LOG_OUT%" %*
7
- exit /b %errorlevel%
1
+ @echo off
2
+ setlocal
3
+ if not defined CODEOUTLINE_LOG_LEVEL set "CODEOUTLINE_LOG_LEVEL=WARN"
4
+ set "CODEOUTLINE_LOG_OUT=LOG_FILE=0"
5
+ if defined CODEOUTLINE_LOG_DIR set "CODEOUTLINE_LOG_OUT=LOG_DIR=%CODEOUTLINE_LOG_DIR%"
6
+ set "CODEOUTLINE_BASE=%~dp0"
7
+ if "%~1"=="update" goto run
8
+ if not defined CODEOUTLINE_AUTO_UPDATE (
9
+ if "%~1"=="serve" (set "CODEOUTLINE_AUTO_UPDATE=1") else (set "CODEOUTLINE_AUTO_UPDATE=0")
10
+ )
11
+ for /f "usebackq delims=" %%R in (`""%~dp0bin\xnet.exe" "%~dp0scripts\codeoutline\updater.lua" LOG_STDERR=1 LOG_FILE=0 LOG_LEVEL=ERROR ACTION=select"`) do set "CODEOUTLINE_BASE=%%R\"
12
+ :run
13
+ "%CODEOUTLINE_BASE%bin\xnet.exe" "%CODEOUTLINE_BASE%scripts\codeoutline\command.lua" LOG_STDERR=1 "LOG_LEVEL=%CODEOUTLINE_LOG_LEVEL%" "%CODEOUTLINE_LOG_OUT%" %*
14
+ exit /b %errorlevel%
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDTDCCAjSgAwIBAgIUGk0p4hd1nhA01S7DyxwhvrKrcBYwDQYJKoZIhvcNAQEL
3
+ BQAwGTEXMBUGA1UEAwwONDMuMTMzLjI1NS4xOTMwHhcNMjYxMDAyMDk1MTM1WhcN
4
+ MjcxMDAyMDk1MTM1WjAZMRcwFQYDVQQDDA40My4xMzMuMjU1LjE5MzCCASIwDQYJ
5
+ KoZIhvcNAQEBBQADggEPADCCAQoCggEBAPog84zcjJT+Vv2UKbU9h/GIwZzBMQP4
6
+ p+vgubALn2s7DAbvS0vlKx0IG3QwP4bD3nlyzreGRisnYclV318/TWGtGUv+XH3U
7
+ xTSl5UXn3ReIm7qSylN2rDOqKjRzLozUk1an4UoQ/JWq8tNJzdyvGN9M+Cg+WvFK
8
+ 1LkiTOjjKno7Q6lPixigcIlkWf714sV0M9wYBYD7zYISiiYOSav3Dp2YjPROluZh
9
+ jc5mQovHAAkZUrs3Sm8u+K74H3TwFb/IMpMmLFcTgsXupPdKnn3be42w4wrAQu4x
10
+ 3Hi2tl4xRJhF61XsGx3gaXXAM2+rfjH7InpaSY+XUf45G3+7UJQ1cw8CAwEAAaOB
11
+ izCBiDAdBgNVHQ4EFgQUOzjvn3TnsLqiYNy97yCk+FFC9OQwHwYDVR0jBBgwFoAU
12
+ Ozjvn3TnsLqiYNy97yCk+FFC9OQwDwYDVR0TAQH/BAUwAwEB/zAgBgNVHREEGTAX
13
+ hwQrhf/BhwR/AAABgglsb2NhbGhvc3QwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDQYJ
14
+ KoZIhvcNAQELBQADggEBAE2iU6xmda3INrREUbvnJvY4UiBK1OfenvObO8avJ8VX
15
+ XeHvW3a4m7bGee90qm2+dTXL/elxPoWn04ph0CxjWTdI4pX9UhnS3SnYvRhALdOZ
16
+ hzDKY1oZkA0nXt3lXXCLfAN/mLi2xaMCVby2M6WX67MZBbdnWp+lpl037gHmRRcm
17
+ /aQtUJRnlQV1wwoxQWluhIJit6UP2Bx+DJgcQ/FlJjZnSdgb+ZpJ3SMrqyewmcnT
18
+ o+b/WKVWwUXFySrSuNmQ7bbbpCXOQTelE+iUM6PnuX5vX8CN2bQwuAV5T+9eSq6P
19
+ d/Ag5Bgs1g1VUkIeftzkQxZutroCk1PLVwEBZ8mtXaM=
20
+ -----END CERTIFICATE-----
@@ -0,0 +1,9 @@
1
+ -----BEGIN PUBLIC KEY-----
2
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArD2e8eaxNcdHZORDjU3E
3
+ +hfcn5zMuxEQdIr7EYVXOMlLg0nPaZ0OH97ZvoGRlDlr+inYJjLTAfGx5//GBt6d
4
+ ErCsa8D2brCFa65Wdj/hW+i2wDgDjovin1+rozNdD2mizucZNTiDjcYWOrbkiW0j
5
+ zp2lE+jDI2zJ8zJGFbMJ2u2Sxq8Ri3HbwqAsSHvBEzH/dg1UUldJZvN3ikyLHgae
6
+ P4IY6qlUrU09ZzzSEfcQSvSOHOay4Fx+GYpsQv7FswhS5t3153U6Nml47vbSoQDx
7
+ 9zeCIBVfhdE2KMGQn+HXb9wbgdVzmvkzB8/98CR9tj08zy/ETlU35TshziSd4Ade
8
+ awIDAQAB
9
+ -----END PUBLIC KEY-----
package/package.json CHANGED
@@ -1 +1 @@
1
- {"repository":{"url":"git+https://github.com/1dao/codeoutline.git","type":"git"},"cpu":["x64","arm64"],"license":"BSD-2-Clause","name":"@codua/codeoutline-win32-x64","description":"CodeOutline native runtime and Lua implementation for win32-x64","os":["win32"],"version":"0.1.2","files":["bin/","lib/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"],"publishConfig":{"access":"public"}}
1
+ {"name":"@codua/codeoutline-win32-x64","publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64","cpu":["x64","arm64"],"license":"BSD-2-Clause","repository":{"type":"git","url":"git+https://github.com/1dao/codeoutline.git"},"files":["bin/","lib/","keys/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"],"version":"0.1.3","os":["win32"]}
@@ -12,6 +12,7 @@ Usage:
12
12
  codeoutline status [--project PATH]
13
13
  codeoutline rebuild [--project PATH]
14
14
  codeoutline doctor [--project PATH]
15
+ codeoutline update [--check | --rollback] [--channel CHANNEL]
15
16
  codeoutline --version
16
17
 
17
18
  HTTP options: --allow-host HOST, --allow-origin ORIGIN (repeatable).
@@ -38,6 +39,7 @@ local function parse(args)
38
39
  serve = { stdio = true, http = true, project = true, host = true, port = true,
39
40
  ['allow-root'] = true, ['allow-host'] = true, ['allow-origin'] = true },
40
41
  explore = { project = true, query = true, budget = true },
42
+ update = { check = true, rollback = true, channel = true },
41
43
  status = { project = true }, rebuild = { project = true }, doctor = { project = true },
42
44
  }
43
45
  assert(allowed[command], 'unknown command: ' .. command)
@@ -46,7 +48,7 @@ local function parse(args)
46
48
  local name, value = clean[i]:match('^%-%-([%w-]+)=(.*)$')
47
49
  if not name then name = clean[i]:match('^%-%-([%w-]+)$') end
48
50
  assert(name and (allowed[command][name] or name == 'help'), 'unknown option: ' .. clean[i])
49
- local flag = name == 'stdio' or name == 'http' or name == 'help'
51
+ local flag = name == 'check' or name == 'rollback' or name == 'stdio' or name == 'http' or name == 'help'
50
52
  if flag then
51
53
  assert(value == nil, '--' .. name .. ' does not take a value')
52
54
  value = true
@@ -124,6 +126,10 @@ local function run()
124
126
  local command, options = parse(arg or {})
125
127
  if command == '--help' or command == '-h' or options.help then io.write(help); return 0 end
126
128
  if command == '--version' then io.write(version, '\n'); return 0 end
129
+ if command == 'update' then
130
+ assert(not (options.check and options.rollback), '--check and --rollback are mutually exclusive')
131
+ return require('codeoutline.updater').run(options.check and 'check' or options.rollback and 'rollback' or 'update', options)
132
+ end
127
133
  if command == 'serve' then
128
134
  assert(not not options.stdio ~= not not options.http, 'serve requires exactly one of --stdio or --http')
129
135
  arg = { options.stdio and 'STDIO=1' or 'HTTP=1' }
@@ -0,0 +1,72 @@
1
+ -- Update commands and bootstrap selection. Installation stays in Lua.
2
+ local source=assert(xutils.realpath(debug.getinfo(1,'S').source:sub(2))):gsub('\\','/')
3
+ local install=assert(source:match('^(.*)/scripts/codeoutline/[^/]+$'))
4
+ package.path=install .. '/scripts/?.lua;' .. package.path
5
+ local c,u=require('xupgate.common'),require('xutils')
6
+ local M={}
7
+ local function config(options)
8
+ options=options or {}
9
+ local build=c.decode_json(c.read(install .. '/build-info.json')) or {}
10
+ local home=os.getenv('USERPROFILE') or os.getenv('HOME')
11
+ local target=os.getenv('CODEOUTLINE_UPDATE_TARGET') or build.target
12
+ if not target then target=package.config:sub(1,1)=='\\' and 'win32-x64' or 'linux-x64' end
13
+ local cfg={
14
+ project=os.getenv('CODEOUTLINE_UPDATE_PROJECT') or 'codeoutline',
15
+ platform=target,url=os.getenv('CODEOUTLINE_UPDATE_URL') or 'https://43.133.255.193:51215',
16
+ channel=options.channel or os.getenv('CODEOUTLINE_UPDATE_CHANNEL') or 'stable',
17
+ publicKey=assert(c.read(os.getenv('CODEOUTLINE_UPDATE_PUBLIC_KEY') or install .. '/keys/update-public.pem'),'update public key missing'),
18
+ caFile=os.getenv('CODEOUTLINE_UPDATE_CA') or install .. '/keys/update-ca.crt',
19
+ directory=os.getenv('CODEOUTLINE_UPDATE_DIR') or assert(home,'set CODEOUTLINE_UPDATE_DIR') .. '/.codeoutline/updates',
20
+ minimumSequence=tonumber(os.getenv('CODEOUTLINE_UPDATE_MIN_SEQUENCE')) or build.updateSequence or 0,
21
+ http=require('xupgate.http_client'),
22
+ }
23
+ cfg.validate=function(root,m)
24
+ local info=c.decode_json(c.read(root .. '/build-info.json'))
25
+ assert(info and info.target==cfg.platform and info.version==m.version and info.updateSequence==m.sequence,'package platform/version/sequence mismatch')
26
+ assert(m.entry=='scripts/codeoutline/command.lua','invalid CodeOutline entry')
27
+ local expected=cfg.platform=='win32-x64' and 'bin/xnet.exe' or 'bin/xnet'
28
+ assert(m.runtime==expected,'package runtime missing')
29
+ local function quote(s)
30
+ assert(not s:find('[\r\n"%!&|<>^$;()]') and not s:find(string.char(96),1,true),'unsafe install path')
31
+ if package.config:sub(1,1)=='\\' then return '"' .. s .. '"' end
32
+ assert(not s:find("'",1,true),'unsafe install path');return "'" .. s .. "'"
33
+ end
34
+ local command=quote(root .. '/' .. m.runtime) .. ' ' .. quote(root .. '/' .. m.entry) .. ' LOG_STDERR=1 LOG_FILE=0 LOG_LEVEL=ERROR --version'
35
+ if package.config:sub(1,1)=='\\' then command='"' .. command .. '"' end
36
+ local pipe=assert(io.popen(command));local output=pipe:read('a');local ok=pipe:close()
37
+ assert(ok and output:match('^%s*(.-)%s*$')==m.version,'updated runtime health check failed')
38
+ return true
39
+ end
40
+ return cfg
41
+ end
42
+ function M.run(action,options)
43
+ local api=require('xupgate.client').open(config(options))
44
+ local function selected()
45
+ local ok,current=pcall(api.current)
46
+ if not ok then io.stderr:write('codeoutline: installed update invalid; using initial version\n')end
47
+ return ok and current and current.root or install
48
+ end
49
+ local function finish(err,result)
50
+ if action=='select' then
51
+ if err then io.stderr:write('codeoutline: update unavailable; using local version\n')end
52
+ io.write(selected(),'\n');io.stdout:flush();xthread.stop(0)
53
+ else
54
+ io.write(assert(u.json_pack({ok=not err,error=err,result=result})),'\n');io.stdout:flush();xthread.stop(err and 1 or 0)
55
+ end
56
+ end
57
+ return {__init=function()
58
+ assert(xnet.init());xtimer.init(16)
59
+ if action=='select' and os.getenv('CODEOUTLINE_AUTO_UPDATE')~='1' then finish(nil)
60
+ elseif action=='rollback' then
61
+ local ok,result=pcall(api.rollback)
62
+ if not ok and tostring(result):find('no previous version',1,true)then ok,result=pcall(api.use_initial)end
63
+ finish(not ok and tostring(result) or nil,ok and result or nil)
64
+ elseif action=='current' then local ok,result=pcall(api.current);finish(not ok and tostring(result) or nil,ok and result or nil)
65
+ elseif action=='check' then api.check(finish)
66
+ else api.update(finish)end
67
+ end,__uninit=function()xnet.uninit()end,__thread_handle=function()end}
68
+ end
69
+ if ...=='codeoutline.updater' then return M end
70
+ local action='select'
71
+ for _,arg in ipairs(arg or {})do local v=arg:match('^ACTION=(.+)$');if v then action=v end end
72
+ return M.run(action)
@@ -1 +1 @@
1
- return '0.1.2'
1
+ return '0.1.3'
@@ -0,0 +1,135 @@
1
+ -- Async calls must originate from a network-active MAIN state.
2
+ -- Public key is pinned by the application, never fetched from the update server.
3
+ local c,u=require('xupgate.common'),require('xutils')
4
+ local M={}
5
+ local function shell_path(path)
6
+ assert(not path:find('[\r\n"%!&|<>^$;()]') and not path:find(string.char(96),1,true),'installation path contains shell metacharacters')
7
+ if package.config:sub(1,1)=='\\' then return '"' .. path .. '"' end
8
+ assert(not path:find("'",1,true),'unsupported installation path')
9
+ return "'" .. path .. "'"
10
+ end
11
+ local function command_ok(command)
12
+ local ok=os.execute(command);return ok==true or ok==0
13
+ end
14
+ function M.open(config)
15
+ assert(c.id(config.project) and c.id(config.platform),'invalid project/platform')
16
+ assert(type(config.publicKey)=='string','pinned publicKey required')
17
+ assert(config.minimumSequence==nil or (type(config.minimumSequence)=='number' and config.minimumSequence>=0 and config.minimumSequence%1==0),'invalid minimumSequence')
18
+ local base=assert(config.url):gsub('/+$','')
19
+ assert(base:match('^https://') or (config.allowLocalHttp and (base:match('^http://127%.0%.0%.1:%d+$') or base:match('^http://localhost:%d+$'))),'HTTPS required outside explicit loopback development')
20
+ assert(c.id(config.channel or 'stable'),'invalid channel')
21
+ assert(u.mkdir_p(config.directory))
22
+ local root=assert(u.realpath(config.directory)):gsub('\\','/') .. '/' .. config.project
23
+ assert(u.mkdir_p(root .. '/versions'))
24
+ local api={}
25
+ local function state()
26
+ local data=c.read(root .. '/current.json',1048576)
27
+ if not data then
28
+ assert(not u.stat(root .. '/current.json').exists,'local state unreadable')
29
+ return {schema=1,highSequence=config.minimumSequence or 0}
30
+ end
31
+ local value=assert(c.decode_json(data),'corrupt local state')
32
+ assert(value.schema==1 and type(value.highSequence)=='number' and value.highSequence>=0 and value.highSequence%1==0,'invalid local state')
33
+ value.highSequence=math.max(value.highSequence,config.minimumSequence or 0)
34
+ assert(not value.current or (type(value.current)=='string' and #value.current==64 and value.current:match('^[0-9a-f]+$')),'invalid current')
35
+ assert(not value.previous or (type(value.previous)=='string' and #value.previous==64 and value.previous:match('^[0-9a-f]+$')),'invalid previous')
36
+ return value
37
+ end
38
+ local function save(value)c.atomic(root .. '/current.json',assert(u.json_pack(value)))end
39
+ local function locked(fn)
40
+ local lock=root .. '/update.lock'
41
+ local command='mkdir ' .. shell_path(lock)
42
+ command=command .. (package.config:sub(1,1)=='\\' and ' 2>nul' or ' 2>/dev/null')
43
+ assert(command_ok(command),'another update is running; inspect stale update.lock after a crashed updater')
44
+ local ok,result=pcall(fn)
45
+ assert(u.rmtree(lock))
46
+ if not ok then error(result) end
47
+ return result
48
+ end
49
+ local function verified(envelope)
50
+ local m=c.manifest(envelope,config.publicKey)
51
+ assert(m.project==config.project and m.platform==config.platform,'manifest target mismatch')
52
+ return m
53
+ end
54
+ function api.current()
55
+ local s=state();if not s.current then return nil end
56
+ local dir=root .. '/versions/' .. s.current
57
+ local envelope=c.decode_json(assert(c.read(dir .. '/manifest.json',1048576)))
58
+ local m=verified(envelope)
59
+ assert(u.stat(dir .. '/complete').exists,'installation incomplete')
60
+ assert(u.sha256_hex(envelope.payload)==s.current,'invalid active identity')
61
+ local files=c.bundle(assert(c.read(dir .. '/bundle.json')),m)
62
+ for _,f in ipairs(files)do assert(c.read(dir .. '/files/' .. f.path)==f.data,'installed file changed')end
63
+ return {version=m.version,sequence=m.sequence,root=dir .. '/files',entry=m.entry,runtime=m.runtime,sha256=m.sha256}
64
+ end
65
+ function api.install(envelope,data)
66
+ local m=verified(envelope);local files=c.bundle(data,m)
67
+ local identity=u.sha256_hex(envelope.payload)
68
+ return locked(function()
69
+ local s=state()
70
+ assert(m.sequence>=s.highSequence,'downgrade/replay rejected; use explicit local rollback')
71
+ if s.current==identity then return api.current()end
72
+ if m.sequence==s.highSequence and s.current then assert(s.previous==identity,'different content at previously accepted sequence')end
73
+ local dir=root .. '/versions/' .. identity
74
+ if not u.stat(dir .. '/complete').exists then
75
+ assert(u.mkdir_p(dir .. '/files'))
76
+ for _,f in ipairs(files)do
77
+ c.write(dir .. '/files/' .. f.path,f.data)
78
+ if f.executable and package.config:sub(1,1)~='\\' then assert(command_ok('chmod 755 ' .. shell_path(dir .. '/files/' .. f.path)),'chmod failed')end
79
+ end
80
+ c.write(dir .. '/bundle.json',data)
81
+ c.write(dir .. '/manifest.json',assert(u.json_pack(envelope)))
82
+ c.atomic(dir .. '/complete','1\n')
83
+ end
84
+ if config.validate then assert(config.validate(dir .. '/files',m),'project health validation failed')end
85
+ save({schema=1,highSequence=math.max(s.highSequence,m.sequence),previous=s.current,current=identity})
86
+ local ok,result=pcall(api.current)
87
+ if not ok then save(s);error(result)end
88
+ return result
89
+ end)
90
+ end
91
+ function api.use_initial()
92
+ return locked(function()
93
+ local s=state()
94
+ save({schema=1,highSequence=s.highSequence,previous=s.current})
95
+ return {initial=true}
96
+ end)
97
+ end
98
+ function api.rollback()
99
+ return locked(function()
100
+ local s=state();assert(s.previous,'no previous version')
101
+ save({schema=1,highSequence=s.highSequence,current=s.previous,previous=s.current})
102
+ local ok,result=pcall(api.current)
103
+ if not ok then save(s);error(result)end
104
+ return result
105
+ end)
106
+ end
107
+ function api.check(callback)
108
+ local http=config.http or dofile('scripts/core/share/xhttp_client.lua')
109
+ http.request({url=base .. '/api/v1/projects/' .. config.project .. '/channels/' .. (config.channel or 'stable') .. '/' .. config.platform,timeout_ms=15000,max_redirects=0,verify=true,ca_file=config.caFile},function(err,resp)
110
+ if err then callback(err);return end
111
+ if resp.status==404 then callback(nil,nil);return end
112
+ if resp.status~=200 then callback('update check HTTP ' .. resp.status);return end
113
+ local ok,m=pcall(function()return verified(assert(c.decode_json(resp.body)))end)
114
+ if not ok then callback(tostring(m));return end
115
+ local loaded,s=pcall(state)
116
+ if not loaded then callback(tostring(s));return end
117
+ if m.sequence<=s.highSequence then callback(nil,nil);return end
118
+ callback(nil,{manifest=m,envelope=c.decode_json(resp.body)})
119
+ end)
120
+ end
121
+ function api.update(callback)
122
+ api.check(function(err,update)
123
+ if err or not update then callback(err,update);return end
124
+ local http=config.http or dofile('scripts/core/share/xhttp_client.lua')
125
+ http.request({url=base .. '/packages/' .. update.manifest.sha256 .. '.json',timeout_ms=120000,max_redirects=0,verify=true,ca_file=config.caFile,decompress=false},function(download_error,resp)
126
+ if download_error then callback(download_error);return end
127
+ if resp.status~=200 then callback('package HTTP ' .. resp.status);return end
128
+ local ok,result=pcall(api.install,update.envelope,resp.body)
129
+ callback(not ok and tostring(result) or nil,ok and result or nil)
130
+ end)
131
+ end)
132
+ end
133
+ return api
134
+ end
135
+ return M
@@ -0,0 +1,76 @@
1
+ local M = {}
2
+ local u = require('xutils')
3
+ function M.id(s)
4
+ return type(s) == 'string' and #s <= 64 and s:match('^[a-z][a-z0-9_-]*$') ~= nil
5
+ end
6
+ function M.version(s)
7
+ return type(s) == 'string' and #s <= 64 and s:match('^%d+%.%d+%.%d+$') ~= nil
8
+ end
9
+ function M.read(path, limit)
10
+ local f = io.open(path, 'rb'); if not f then return nil end
11
+ local data, err = f:read((limit or 67108864) + 1); f:close()
12
+ if err then return nil end
13
+ data = data or ''
14
+ if #data > (limit or 67108864) then return nil end
15
+ return data
16
+ end
17
+ function M.write(path, data)
18
+ assert(u.mkdir_p(assert(path:match('^(.*)/[^/]+$'))))
19
+ local f = assert(io.open(path, 'wb')); assert(f:write(data)); assert(f:close())
20
+ end
21
+ function M.atomic(path, data)
22
+ local temp = assert(u.temp_file(assert(path:match('^(.*)/[^/]+$'))))
23
+ local ok, err = pcall(function() M.write(temp, data); assert(u.replace_file(temp, path)) end)
24
+ if not ok then os.remove(temp); error(err) end
25
+ end
26
+ function M.path(s)
27
+ if type(s) ~= 'string' or #s == 0 or #s > 240 or s:find('[^%w_./-]') or s:sub(1,1) == '/' then return false end
28
+ for part in s:gmatch('[^/]+') do
29
+ if part == '.' or part == '..' or part:sub(-1) == '.' then return false end
30
+ local stem = part:match('^([^.]*)'):upper()
31
+ if stem == 'CON' or stem == 'PRN' or stem == 'AUX' or stem == 'NUL' or stem:match('^COM[1-9]$') or stem:match('^LPT[1-9]$') then return false end
32
+ end
33
+ return not s:find('//',1,true) and s:sub(-1) ~= '/'
34
+ end
35
+ function M.decode_json(s)
36
+ local ok, v = pcall(u.json_unpack, s or '')
37
+ if ok and type(v) == 'table' then return v end
38
+ end
39
+ function M.manifest(envelope, public_key)
40
+ assert(type(envelope) == 'table' and type(envelope.payload) == 'string' and #envelope.payload <= 1048576, 'invalid signed envelope')
41
+ assert(type(envelope.signature) == 'string' and #envelope.signature <= 1024, 'invalid signature')
42
+ local sig = u.base64_decode(envelope.signature)
43
+ assert(require('xupgate.signature').verify(public_key, envelope.payload, sig), 'manifest signature invalid')
44
+ local m = assert(M.decode_json(envelope.payload), 'invalid manifest JSON')
45
+ assert(m.schema == 1 and M.id(m.project) and M.version(m.version) and M.id(m.platform), 'invalid manifest identity')
46
+ assert(m.minUpdater == 1, 'unsupported updater version')
47
+ assert(type(m.sha256) == 'string' and #m.sha256 == 64 and m.sha256:match('^[0-9a-f]+$'), 'invalid package hash')
48
+ assert(type(m.size) == 'number' and m.size > 0 and m.size <= 50331648 and m.size % 1 == 0, 'invalid package size')
49
+ assert(type(m.sequence) == 'number' and m.sequence >= 1 and m.sequence % 1 == 0, 'invalid release sequence')
50
+ assert(type(m.entry) == 'string' and M.path(m.entry), 'invalid entry')
51
+ assert(m.notes==nil or (type(m.notes)=='string' and #m.notes<=16384),'invalid notes')
52
+ assert(m.runtime==nil or M.path(m.runtime),'invalid runtime')
53
+ return m
54
+ end
55
+ function M.bundle(data, manifest)
56
+ assert(#data == manifest.size and u.sha256_hex(data) == manifest.sha256, 'package checksum mismatch')
57
+ local b = assert(M.decode_json(data), 'invalid bundle')
58
+ assert(b.schema == 1 and type(b.files) == 'table' and #b.files > 0 and #b.files <= 10000, 'invalid files')
59
+ local seen, decoded, total, entry = {}, {}, 0, false
60
+ for _, f in ipairs(b.files) do
61
+ assert(type(f) == 'table' and M.path(f.path) and type(f.data) == 'string', 'unsafe file')
62
+ local key = f.path:lower(); assert(not seen[key], 'duplicate file'); seen[key] = true
63
+ local bytes = assert(u.base64_decode(f.data), 'bad base64')
64
+ total = total + #bytes; assert(total <= 50331648, 'expanded package too large')
65
+ decoded[#decoded+1] = { path = f.path, data = bytes, executable = f.executable == true }
66
+ if f.path == manifest.entry then entry = true end
67
+ end
68
+ for key in pairs(seen) do
69
+ local prefix = key:match('^(.*)/[^/]+$')
70
+ while prefix do assert(not seen[prefix], 'file/directory collision'); prefix = prefix:match('^(.*)/[^/]+$') end
71
+ end
72
+ assert(entry, 'entry missing from bundle')
73
+ assert(not manifest.runtime or seen[manifest.runtime:lower()], 'runtime missing from bundle')
74
+ return decoded
75
+ end
76
+ return M