@make-u-free/migi 0.2.5 → 0.2.6

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 +22 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@make-u-free/migi",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
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
@@ -1,19 +1,30 @@
1
- import { existsSync, readFileSync } from 'fs'
2
- import { join } from 'path'
1
+ import { existsSync, readFileSync, readdirSync } from 'fs'
2
+ import { join, extname } from 'path'
3
3
  import { homedir } from 'os'
4
4
  import https from 'https'
5
5
  import tls from 'tls'
6
6
 
7
- // CA ファイルの検索順(単体 .crt / bundle.pem どちらでも可)
8
- const CA_CANDIDATES = [
9
- process.env.NODE_EXTRA_CA_CERTS,
10
- join(homedir(), '.migi', 'zscaler-ca.pem'),
11
- join(homedir(), '.migi', 'zscaler-ca.crt'),
12
- join(homedir(), '.migi', 'ca-bundle.pem'),
13
- ].filter(Boolean)
7
+ // .migi/ ディレクトリ内の .crt / .pem を名前不問でスキャン
8
+ function scanDir(dir) {
9
+ if (!existsSync(dir)) return []
10
+ try {
11
+ return readdirSync(dir)
12
+ .filter(f => ['.crt', '.pem'].includes(extname(f).toLowerCase()))
13
+ .map(f => join(dir, f))
14
+ } catch {
15
+ return []
16
+ }
17
+ }
14
18
 
15
19
  function findCA() {
16
- for (const p of CA_CANDIDATES) {
20
+ // 優先順: 環境変数 カレント.migi/ → ホーム.migi/
21
+ const candidates = [
22
+ process.env.NODE_EXTRA_CA_CERTS,
23
+ ...scanDir(join(process.cwd(), '.migi')),
24
+ ...scanDir(join(homedir(), '.migi')),
25
+ ].filter(Boolean)
26
+
27
+ for (const p of candidates) {
17
28
  if (existsSync(p)) return p
18
29
  }
19
30
  return null
@@ -47,7 +58,7 @@ if (caPath) {
47
58
 
48
59
  console.log(` [TLS] CA loaded: ${caPath}`)
49
60
  } else {
50
- console.log(' [TLS] CA未設定 (社内エラー時は ~/.migi/zscaler-ca.pem を配置)')
61
+ console.log(' [TLS] CA未設定 (社内エラー時は .migi/.crt/.pem を配置)')
51
62
  }
52
63
 
53
64
  export const httpsAgent = _httpsAgent