@make-u-free/migi 0.2.9 → 0.3.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/tls.js +10 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@make-u-free/migi",
3
- "version": "0.2.9",
3
+ "version": "0.3.1",
4
4
  "description": "Your AI right-hand agent. Works anywhere, with any LLM API.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/tls.js CHANGED
@@ -17,11 +17,13 @@ function scanDir(dir) {
17
17
  }
18
18
 
19
19
  function findCA() {
20
- // 優先順: 環境変数 → カレント.migi/ → ホーム.migi/
20
+ // 優先順: 環境変数 → カレント.migi/ → カレント直下 → ホーム.migi/ → ホーム直下
21
21
  const candidates = [
22
22
  process.env.NODE_EXTRA_CA_CERTS,
23
23
  ...scanDir(join(process.cwd(), '.migi')),
24
+ ...scanDir(process.cwd()),
24
25
  ...scanDir(join(homedir(), '.migi')),
26
+ ...scanDir(homedir()),
25
27
  ].filter(Boolean)
26
28
 
27
29
  for (const p of candidates) {
@@ -39,13 +41,13 @@ if (caPath) {
39
41
 
40
42
  // ① tls.createSecureContext パッチ
41
43
  // Node 18+ built-in fetch (undici) を含む全TLS接続に効く
44
+ // デフォルトのCA(tls.rootCertificates)に追加する形にする
42
45
  const _origCreate = tls.createSecureContext
43
46
  tls.createSecureContext = (options = {}) => {
44
- const extra = [caCert]
45
- const existing = options.ca
47
+ const base = options.ca
46
48
  ? (Array.isArray(options.ca) ? options.ca : [options.ca])
47
- : []
48
- return _origCreate({ ...options, ca: [...existing, ...extra] })
49
+ : tls.rootCertificates // デフォルトCAを引き継ぐ
50
+ return _origCreate({ ...options, ca: [...base, caCert] })
49
51
  }
50
52
 
51
53
  // ② NODE_EXTRA_CA_CERTS(環境変数で起動する場合のフォールバック)
@@ -53,12 +55,12 @@ if (caPath) {
53
55
  process.env.NODE_EXTRA_CA_CERTS = caPath
54
56
  }
55
57
 
56
- // ③ https.Agent(node-fetch 系フォールバック)
57
- _httpsAgent = new https.Agent({ ca: caCert })
58
+ // ③ https.Agent: デフォルトCA + Zscaler CA を合わせて渡す
59
+ _httpsAgent = new https.Agent({ ca: [...tls.rootCertificates, caCert] })
58
60
 
59
61
  console.log(` [TLS] CA loaded: ${caPath}`)
60
62
  } else {
61
- console.log(' [TLS] CA未設定 (社内エラー時は .migi/ に .crt/.pem を配置)')
63
+ console.log(' [TLS] CA未設定 (社内エラー時は ~/.migi/ か ~/ に .crt/.pem を配置)')
62
64
  }
63
65
 
64
66
  export const httpsAgent = _httpsAgent