nodelistparser 0.2.0 → 0.3.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.
@@ -57,8 +57,14 @@ interface TuicConfig extends SharedConfigBase {
57
57
  sni: string;
58
58
  uuid: string;
59
59
  alpn: string;
60
+ token: string;
61
+ }
62
+ interface TuicV5Config extends SharedConfigBase, TlsSharedConfig {
63
+ type: 'tuic-v5';
64
+ sni: string;
65
+ uuid: string;
66
+ alpn: string;
60
67
  password: string;
61
- version: number;
62
68
  }
63
69
  interface Socks5Config extends SharedConfigBase {
64
70
  type: 'socks5';
@@ -87,7 +93,7 @@ interface Hysteria2Config extends SharedConfigBase, Omit<TlsSharedConfig, 'sni'>
87
93
  /** port hopping interval */
88
94
  portHoppingInterval?: number;
89
95
  }
90
- type SupportedConfig = HttpProxyConfig | SnellConfig | TrojanConfig | ShadowSocksConfig | TuicConfig | Socks5Config | VmessConfig | Hysteria2Config;
96
+ type SupportedConfig = HttpProxyConfig | SnellConfig | TrojanConfig | ShadowSocksConfig | TuicConfig | TuicV5Config | Socks5Config | VmessConfig | Hysteria2Config;
91
97
 
92
98
  declare function decode$1(raw: string): SupportedConfig;
93
99
  declare function encode$1(config: SupportedConfig): string;
@@ -146,6 +152,8 @@ declare function encode(config: SupportedConfig): {
146
152
  down?: undefined;
147
153
  } | {
148
154
  tfo: boolean | undefined;
155
+ udp: boolean;
156
+ token: string;
149
157
  name: string;
150
158
  type: string;
151
159
  server: string;
@@ -153,9 +161,6 @@ declare function encode(config: SupportedConfig): {
153
161
  sni: string;
154
162
  uuid: string;
155
163
  alpn: string[];
156
- token: string;
157
- version: number;
158
- udp: boolean;
159
164
  alterId?: undefined;
160
165
  tls?: undefined;
161
166
  servername?: undefined;
@@ -168,6 +173,28 @@ declare function encode(config: SupportedConfig): {
168
173
  password?: undefined;
169
174
  down?: undefined;
170
175
  'skip-cert-verify'?: undefined;
176
+ } | {
177
+ tfo: boolean | undefined;
178
+ udp: boolean;
179
+ password: string;
180
+ name: string;
181
+ type: string;
182
+ server: string;
183
+ port: number;
184
+ sni: string;
185
+ uuid: string;
186
+ alpn: string[];
187
+ alterId?: undefined;
188
+ tls?: undefined;
189
+ servername?: undefined;
190
+ 'ws-path'?: undefined;
191
+ 'ws-headers'?: undefined;
192
+ cipher?: undefined;
193
+ 'ws-opts'?: undefined;
194
+ network?: undefined;
195
+ ports?: undefined;
196
+ down?: undefined;
197
+ 'skip-cert-verify'?: undefined;
171
198
  } | {
172
199
  tfo: boolean | undefined;
173
200
  name: string;
@@ -277,4 +304,4 @@ declare namespace index {
277
304
  export { index_parse as parse };
278
305
  }
279
306
 
280
- export { type HttpProxyConfig, type Hysteria2Config, type ShadowSocksConfig, type SharedConfigBase, type SnellConfig, type Socks5Config, type SupportedConfig, type TrojanBasicConfig, type TrojanConfig, type TuicConfig, type VmessConfig, index$2 as clash, index$1 as ss, index$3 as surge, index as trojan };
307
+ export { type HttpProxyConfig, type Hysteria2Config, type ShadowSocksConfig, type SharedConfigBase, type SnellConfig, type Socks5Config, type SupportedConfig, type TrojanBasicConfig, type TrojanConfig, type TuicConfig, type TuicV5Config, type VmessConfig, index$2 as clash, index$1 as ss, index$3 as surge, index as trojan };
package/dist/cjs/index.js CHANGED
@@ -46,7 +46,8 @@ const strKeys = new Set([
46
46
  'block-quic',
47
47
  'ws-path',
48
48
  'ws-headers',
49
- 'port-hopping'
49
+ 'port-hopping',
50
+ 'token'
50
51
  ]);
51
52
  const isProxyStrKey = (key)=>strKeys.has(key);
52
53
  const UNSUPPORTED_VALUE = Symbol('unsupported');
@@ -143,8 +144,19 @@ function decode$1(raw) {
143
144
  sni: restDetails.sni,
144
145
  uuid: restDetails.uuid,
145
146
  alpn: restDetails.alpn,
147
+ token: restDetails.token,
148
+ ...shared
149
+ };
150
+ }
151
+ case 'tuic-v5':
152
+ {
153
+ return {
154
+ type: 'tuic-v5',
155
+ uuid: restDetails.uuid,
156
+ alpn: restDetails.alpn,
146
157
  password: restDetails.password,
147
- version: restDetails.version,
158
+ sni: restDetails.sni,
159
+ skipCertVerify: restDetails['skip-cert-verify'],
148
160
  ...shared
149
161
  };
150
162
  }
@@ -232,7 +244,7 @@ function encode$1(config) {
232
244
  ]);
233
245
  case 'tuic':
234
246
  return joinString([
235
- `${config.name} = tuic, ${config.server}, ${config.port}, sni=${config.sni}, uuid=${config.uuid}, alpn=${config.alpn}, password=${config.password}, version=${config.version}`,
247
+ `${config.name} = tuic, ${config.server}, ${config.port}, sni=${config.sni}, uuid=${config.uuid}, alpn=${config.alpn}, token=${config.token}`,
236
248
  ...shared
237
249
  ]);
238
250
  case 'socks5':
@@ -270,6 +282,16 @@ function encode$1(config) {
270
282
  `skip-cert-verify=${config.skipCertVerify}`,
271
283
  ...shared
272
284
  ]);
285
+ case 'tuic-v5':
286
+ return joinString([
287
+ `${config.name} = tuic-v5, ${config.server}, ${config.port}`,
288
+ `password=${config.password}`,
289
+ `uuid=${config.uuid}`,
290
+ `alpn=${config.alpn}`,
291
+ `skip-cert-verify=${config.skipCertVerify}`,
292
+ `sni=${config.sni}`,
293
+ ...shared
294
+ ]);
273
295
  default:
274
296
  guard.never(config, 'type (clash encode)');
275
297
  }
@@ -390,6 +412,7 @@ function encode(config) {
390
412
  ...shared
391
413
  };
392
414
  case 'tuic':
415
+ case 'tuic-v5':
393
416
  return {
394
417
  name: config.name,
395
418
  type: 'tuic',
@@ -398,8 +421,11 @@ function encode(config) {
398
421
  sni: config.sni,
399
422
  uuid: config.uuid,
400
423
  alpn: config.alpn.split(',').map((x)=>x.trim()),
401
- token: config.password,
402
- version: config.version,
424
+ ...config.type === 'tuic' ? {
425
+ token: config.token
426
+ } : {
427
+ password: config.password
428
+ },
403
429
  udp: true,
404
430
  ...shared
405
431
  };
@@ -57,8 +57,14 @@ interface TuicConfig extends SharedConfigBase {
57
57
  sni: string;
58
58
  uuid: string;
59
59
  alpn: string;
60
+ token: string;
61
+ }
62
+ interface TuicV5Config extends SharedConfigBase, TlsSharedConfig {
63
+ type: 'tuic-v5';
64
+ sni: string;
65
+ uuid: string;
66
+ alpn: string;
60
67
  password: string;
61
- version: number;
62
68
  }
63
69
  interface Socks5Config extends SharedConfigBase {
64
70
  type: 'socks5';
@@ -87,7 +93,7 @@ interface Hysteria2Config extends SharedConfigBase, Omit<TlsSharedConfig, 'sni'>
87
93
  /** port hopping interval */
88
94
  portHoppingInterval?: number;
89
95
  }
90
- type SupportedConfig = HttpProxyConfig | SnellConfig | TrojanConfig | ShadowSocksConfig | TuicConfig | Socks5Config | VmessConfig | Hysteria2Config;
96
+ type SupportedConfig = HttpProxyConfig | SnellConfig | TrojanConfig | ShadowSocksConfig | TuicConfig | TuicV5Config | Socks5Config | VmessConfig | Hysteria2Config;
91
97
 
92
98
  declare function decode$1(raw: string): SupportedConfig;
93
99
  declare function encode$1(config: SupportedConfig): string;
@@ -146,6 +152,8 @@ declare function encode(config: SupportedConfig): {
146
152
  down?: undefined;
147
153
  } | {
148
154
  tfo: boolean | undefined;
155
+ udp: boolean;
156
+ token: string;
149
157
  name: string;
150
158
  type: string;
151
159
  server: string;
@@ -153,9 +161,6 @@ declare function encode(config: SupportedConfig): {
153
161
  sni: string;
154
162
  uuid: string;
155
163
  alpn: string[];
156
- token: string;
157
- version: number;
158
- udp: boolean;
159
164
  alterId?: undefined;
160
165
  tls?: undefined;
161
166
  servername?: undefined;
@@ -168,6 +173,28 @@ declare function encode(config: SupportedConfig): {
168
173
  password?: undefined;
169
174
  down?: undefined;
170
175
  'skip-cert-verify'?: undefined;
176
+ } | {
177
+ tfo: boolean | undefined;
178
+ udp: boolean;
179
+ password: string;
180
+ name: string;
181
+ type: string;
182
+ server: string;
183
+ port: number;
184
+ sni: string;
185
+ uuid: string;
186
+ alpn: string[];
187
+ alterId?: undefined;
188
+ tls?: undefined;
189
+ servername?: undefined;
190
+ 'ws-path'?: undefined;
191
+ 'ws-headers'?: undefined;
192
+ cipher?: undefined;
193
+ 'ws-opts'?: undefined;
194
+ network?: undefined;
195
+ ports?: undefined;
196
+ down?: undefined;
197
+ 'skip-cert-verify'?: undefined;
171
198
  } | {
172
199
  tfo: boolean | undefined;
173
200
  name: string;
@@ -277,4 +304,4 @@ declare namespace index {
277
304
  export { index_parse as parse };
278
305
  }
279
306
 
280
- export { type HttpProxyConfig, type Hysteria2Config, type ShadowSocksConfig, type SharedConfigBase, type SnellConfig, type Socks5Config, type SupportedConfig, type TrojanBasicConfig, type TrojanConfig, type TuicConfig, type VmessConfig, index$2 as clash, index$1 as ss, index$3 as surge, index as trojan };
307
+ export { type HttpProxyConfig, type Hysteria2Config, type ShadowSocksConfig, type SharedConfigBase, type SnellConfig, type Socks5Config, type SupportedConfig, type TrojanBasicConfig, type TrojanConfig, type TuicConfig, type TuicV5Config, type VmessConfig, index$2 as clash, index$1 as ss, index$3 as surge, index as trojan };
package/dist/es/index.mjs CHANGED
@@ -46,7 +46,8 @@ const strKeys = new Set([
46
46
  'block-quic',
47
47
  'ws-path',
48
48
  'ws-headers',
49
- 'port-hopping'
49
+ 'port-hopping',
50
+ 'token'
50
51
  ]);
51
52
  const isProxyStrKey = (key)=>strKeys.has(key);
52
53
  const UNSUPPORTED_VALUE = Symbol('unsupported');
@@ -143,8 +144,19 @@ function decode$1(raw) {
143
144
  sni: restDetails.sni,
144
145
  uuid: restDetails.uuid,
145
146
  alpn: restDetails.alpn,
147
+ token: restDetails.token,
148
+ ...shared
149
+ };
150
+ }
151
+ case 'tuic-v5':
152
+ {
153
+ return {
154
+ type: 'tuic-v5',
155
+ uuid: restDetails.uuid,
156
+ alpn: restDetails.alpn,
146
157
  password: restDetails.password,
147
- version: restDetails.version,
158
+ sni: restDetails.sni,
159
+ skipCertVerify: restDetails['skip-cert-verify'],
148
160
  ...shared
149
161
  };
150
162
  }
@@ -232,7 +244,7 @@ function encode$1(config) {
232
244
  ]);
233
245
  case 'tuic':
234
246
  return joinString([
235
- `${config.name} = tuic, ${config.server}, ${config.port}, sni=${config.sni}, uuid=${config.uuid}, alpn=${config.alpn}, password=${config.password}, version=${config.version}`,
247
+ `${config.name} = tuic, ${config.server}, ${config.port}, sni=${config.sni}, uuid=${config.uuid}, alpn=${config.alpn}, token=${config.token}`,
236
248
  ...shared
237
249
  ]);
238
250
  case 'socks5':
@@ -270,6 +282,16 @@ function encode$1(config) {
270
282
  `skip-cert-verify=${config.skipCertVerify}`,
271
283
  ...shared
272
284
  ]);
285
+ case 'tuic-v5':
286
+ return joinString([
287
+ `${config.name} = tuic-v5, ${config.server}, ${config.port}`,
288
+ `password=${config.password}`,
289
+ `uuid=${config.uuid}`,
290
+ `alpn=${config.alpn}`,
291
+ `skip-cert-verify=${config.skipCertVerify}`,
292
+ `sni=${config.sni}`,
293
+ ...shared
294
+ ]);
273
295
  default:
274
296
  never(config, 'type (clash encode)');
275
297
  }
@@ -390,6 +412,7 @@ function encode(config) {
390
412
  ...shared
391
413
  };
392
414
  case 'tuic':
415
+ case 'tuic-v5':
393
416
  return {
394
417
  name: config.name,
395
418
  type: 'tuic',
@@ -398,8 +421,11 @@ function encode(config) {
398
421
  sni: config.sni,
399
422
  uuid: config.uuid,
400
423
  alpn: config.alpn.split(',').map((x)=>x.trim()),
401
- token: config.password,
402
- version: config.version,
424
+ ...config.type === 'tuic' ? {
425
+ token: config.token
426
+ } : {
427
+ password: config.password
428
+ },
403
429
  udp: true,
404
430
  ...shared
405
431
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodelistparser",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Surge / Mihomo (Clash.Meta) nodelist / proxy provider parser and generator.",
5
5
  "repository": {
6
6
  "type": "git",