nodelistparser 0.1.4 → 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,16 +93,16 @@ 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;
94
100
 
95
- declare namespace index$2 {
101
+ declare namespace index$3 {
96
102
  export { decode$1 as decode, encode$1 as encode };
97
103
  }
98
104
 
99
- declare function decode(config: any): SupportedConfig;
105
+ declare function decode(config: Record<string, any>): SupportedConfig;
100
106
  declare function encode(config: SupportedConfig): {
101
107
  tfo: boolean | undefined;
102
108
  plugin?: string | undefined;
@@ -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;
@@ -253,21 +280,28 @@ declare function encode(config: SupportedConfig): {
253
280
  network?: undefined;
254
281
  };
255
282
 
256
- declare const index$1_decode: typeof decode;
257
- declare const index$1_encode: typeof encode;
258
- declare namespace index$1 {
259
- export { index$1_decode as decode, index$1_encode as encode };
283
+ declare const index$2_decode: typeof decode;
284
+ declare const index$2_encode: typeof encode;
285
+ declare namespace index$2 {
286
+ export { index$2_decode as decode, index$2_encode as encode };
260
287
  }
261
288
 
262
289
  declare function decodeOne(sip002: string): ShadowSocksConfig;
263
290
  declare function decodeBase64Multiline(text: string): string[];
264
291
  declare function decodeMultiline(text: string): ShadowSocksConfig[];
265
292
 
266
- declare const index_decodeBase64Multiline: typeof decodeBase64Multiline;
267
- declare const index_decodeMultiline: typeof decodeMultiline;
268
- declare const index_decodeOne: typeof decodeOne;
293
+ declare const index$1_decodeBase64Multiline: typeof decodeBase64Multiline;
294
+ declare const index$1_decodeMultiline: typeof decodeMultiline;
295
+ declare const index$1_decodeOne: typeof decodeOne;
296
+ declare namespace index$1 {
297
+ export { index$1_decodeBase64Multiline as decodeBase64Multiline, index$1_decodeMultiline as decodeMultiline, index$1_decodeOne as decodeOne };
298
+ }
299
+
300
+ declare function parse(line: string): TrojanConfig;
301
+
302
+ declare const index_parse: typeof parse;
269
303
  declare namespace index {
270
- export { index_decodeBase64Multiline as decodeBase64Multiline, index_decodeMultiline as decodeMultiline, index_decodeOne as decodeOne };
304
+ export { index_parse as parse };
271
305
  }
272
306
 
273
- export { type HttpProxyConfig, type Hysteria2Config, type ShadowSocksConfig, type SharedConfigBase, type SnellConfig, type Socks5Config, type SupportedConfig, type TrojanBasicConfig, type TrojanConfig, type TuicConfig, type VmessConfig, index$1 as clash, index as ss, index$2 as surge };
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,12 +282,22 @@ 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
  }
276
298
  }
277
299
 
278
- var index$2 = {
300
+ var index$3 = {
279
301
  __proto__: null,
280
302
  decode: decode$1,
281
303
  encode: encode$1
@@ -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
  };
@@ -467,7 +493,7 @@ function parseStringToObject(input) {
467
493
  }, {});
468
494
  }
469
495
 
470
- var index$1 = {
496
+ var index$2 = {
471
497
  __proto__: null,
472
498
  decode: decode,
473
499
  encode: encode
@@ -488,8 +514,22 @@ function decodeOne(sip002) {
488
514
  }
489
515
  const [serverName, _1] = server.split(':');
490
516
  const [_2, encodedName] = _1.split('#');
491
- const [port, _plugins] = _2.split('/');
492
- // TODO: implement plugin parsing
517
+ const [port, pluginsStr] = _2.split('/');
518
+ let plugin = null;
519
+ if (pluginsStr) {
520
+ try {
521
+ plugin = new URLSearchParams(pluginsStr).get('plugin');
522
+ } catch (e) {
523
+ const err = new Error(`[ss.decodeOne] Invalid plugins: ${pluginsStr}`);
524
+ err.cause = e;
525
+ throw err;
526
+ }
527
+ }
528
+ const pluginArgs = (plugin?.split(';') ?? []).reduce((acc, cur)=>{
529
+ const [key, value] = cur.split('=');
530
+ acc[key] = value;
531
+ return acc;
532
+ }, {});
493
533
  return {
494
534
  raw: sip002,
495
535
  type: 'ss',
@@ -498,7 +538,9 @@ function decodeOne(sip002) {
498
538
  port: number(port),
499
539
  cipher,
500
540
  password,
501
- udp: true
541
+ udp: true,
542
+ obfs: 'obfs-local' in pluginArgs && 'obfs' in pluginArgs && (pluginArgs.obfs === 'http' || pluginArgs.obfs === 'tls') ? pluginArgs.obfs : undefined,
543
+ obfsHost: 'obfs-host' in pluginArgs ? pluginArgs['obfs-host'] : undefined
502
544
  };
503
545
  }
504
546
  function decodeBase64Multiline(text) {
@@ -508,13 +550,42 @@ function decodeMultiline(text) {
508
550
  return decodeBase64Multiline(text).map((line)=>decodeOne(line));
509
551
  }
510
552
 
511
- var index = {
553
+ var index$1 = {
512
554
  __proto__: null,
513
555
  decodeBase64Multiline: decodeBase64Multiline,
514
556
  decodeMultiline: decodeMultiline,
515
557
  decodeOne: decodeOne
516
558
  };
517
559
 
518
- exports.clash = index$1;
519
- exports.ss = index;
520
- exports.surge = index$2;
560
+ function parse(line) {
561
+ const url = new URL(line);
562
+ // trojan://password@remote_host:remote_port
563
+ const password = url.username;
564
+ const server = url.hostname;
565
+ const port = Number.parseInt(url.port, 10);
566
+ if (Number.isNaN(port)) {
567
+ throw new TypeError('invalid port: ' + url.port);
568
+ }
569
+ const name = decodeURIComponent(url.hash.slice(1));
570
+ return {
571
+ raw: line,
572
+ name,
573
+ type: 'trojan',
574
+ server,
575
+ port,
576
+ password,
577
+ udp: true,
578
+ sni: url.searchParams.get('sni') ?? server,
579
+ skipCertVerify: true
580
+ };
581
+ }
582
+
583
+ var index = {
584
+ __proto__: null,
585
+ parse: parse
586
+ };
587
+
588
+ exports.clash = index$2;
589
+ exports.ss = index$1;
590
+ exports.surge = index$3;
591
+ exports.trojan = index;
@@ -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,16 +93,16 @@ 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;
94
100
 
95
- declare namespace index$2 {
101
+ declare namespace index$3 {
96
102
  export { decode$1 as decode, encode$1 as encode };
97
103
  }
98
104
 
99
- declare function decode(config: any): SupportedConfig;
105
+ declare function decode(config: Record<string, any>): SupportedConfig;
100
106
  declare function encode(config: SupportedConfig): {
101
107
  tfo: boolean | undefined;
102
108
  plugin?: string | undefined;
@@ -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;
@@ -253,21 +280,28 @@ declare function encode(config: SupportedConfig): {
253
280
  network?: undefined;
254
281
  };
255
282
 
256
- declare const index$1_decode: typeof decode;
257
- declare const index$1_encode: typeof encode;
258
- declare namespace index$1 {
259
- export { index$1_decode as decode, index$1_encode as encode };
283
+ declare const index$2_decode: typeof decode;
284
+ declare const index$2_encode: typeof encode;
285
+ declare namespace index$2 {
286
+ export { index$2_decode as decode, index$2_encode as encode };
260
287
  }
261
288
 
262
289
  declare function decodeOne(sip002: string): ShadowSocksConfig;
263
290
  declare function decodeBase64Multiline(text: string): string[];
264
291
  declare function decodeMultiline(text: string): ShadowSocksConfig[];
265
292
 
266
- declare const index_decodeBase64Multiline: typeof decodeBase64Multiline;
267
- declare const index_decodeMultiline: typeof decodeMultiline;
268
- declare const index_decodeOne: typeof decodeOne;
293
+ declare const index$1_decodeBase64Multiline: typeof decodeBase64Multiline;
294
+ declare const index$1_decodeMultiline: typeof decodeMultiline;
295
+ declare const index$1_decodeOne: typeof decodeOne;
296
+ declare namespace index$1 {
297
+ export { index$1_decodeBase64Multiline as decodeBase64Multiline, index$1_decodeMultiline as decodeMultiline, index$1_decodeOne as decodeOne };
298
+ }
299
+
300
+ declare function parse(line: string): TrojanConfig;
301
+
302
+ declare const index_parse: typeof parse;
269
303
  declare namespace index {
270
- export { index_decodeBase64Multiline as decodeBase64Multiline, index_decodeMultiline as decodeMultiline, index_decodeOne as decodeOne };
304
+ export { index_parse as parse };
271
305
  }
272
306
 
273
- export { type HttpProxyConfig, type Hysteria2Config, type ShadowSocksConfig, type SharedConfigBase, type SnellConfig, type Socks5Config, type SupportedConfig, type TrojanBasicConfig, type TrojanConfig, type TuicConfig, type VmessConfig, index$1 as clash, index as ss, index$2 as surge };
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,12 +282,22 @@ 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
  }
276
298
  }
277
299
 
278
- var index$2 = {
300
+ var index$3 = {
279
301
  __proto__: null,
280
302
  decode: decode$1,
281
303
  encode: encode$1
@@ -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
  };
@@ -467,7 +493,7 @@ function parseStringToObject(input) {
467
493
  }, {});
468
494
  }
469
495
 
470
- var index$1 = {
496
+ var index$2 = {
471
497
  __proto__: null,
472
498
  decode: decode,
473
499
  encode: encode
@@ -488,8 +514,22 @@ function decodeOne(sip002) {
488
514
  }
489
515
  const [serverName, _1] = server.split(':');
490
516
  const [_2, encodedName] = _1.split('#');
491
- const [port, _plugins] = _2.split('/');
492
- // TODO: implement plugin parsing
517
+ const [port, pluginsStr] = _2.split('/');
518
+ let plugin = null;
519
+ if (pluginsStr) {
520
+ try {
521
+ plugin = new URLSearchParams(pluginsStr).get('plugin');
522
+ } catch (e) {
523
+ const err = new Error(`[ss.decodeOne] Invalid plugins: ${pluginsStr}`);
524
+ err.cause = e;
525
+ throw err;
526
+ }
527
+ }
528
+ const pluginArgs = (plugin?.split(';') ?? []).reduce((acc, cur)=>{
529
+ const [key, value] = cur.split('=');
530
+ acc[key] = value;
531
+ return acc;
532
+ }, {});
493
533
  return {
494
534
  raw: sip002,
495
535
  type: 'ss',
@@ -498,7 +538,9 @@ function decodeOne(sip002) {
498
538
  port: number(port),
499
539
  cipher,
500
540
  password,
501
- udp: true
541
+ udp: true,
542
+ obfs: 'obfs-local' in pluginArgs && 'obfs' in pluginArgs && (pluginArgs.obfs === 'http' || pluginArgs.obfs === 'tls') ? pluginArgs.obfs : undefined,
543
+ obfsHost: 'obfs-host' in pluginArgs ? pluginArgs['obfs-host'] : undefined
502
544
  };
503
545
  }
504
546
  function decodeBase64Multiline(text) {
@@ -508,11 +550,39 @@ function decodeMultiline(text) {
508
550
  return decodeBase64Multiline(text).map((line)=>decodeOne(line));
509
551
  }
510
552
 
511
- var index = {
553
+ var index$1 = {
512
554
  __proto__: null,
513
555
  decodeBase64Multiline: decodeBase64Multiline,
514
556
  decodeMultiline: decodeMultiline,
515
557
  decodeOne: decodeOne
516
558
  };
517
559
 
518
- export { index$1 as clash, index as ss, index$2 as surge };
560
+ function parse(line) {
561
+ const url = new URL(line);
562
+ // trojan://password@remote_host:remote_port
563
+ const password = url.username;
564
+ const server = url.hostname;
565
+ const port = Number.parseInt(url.port, 10);
566
+ if (Number.isNaN(port)) {
567
+ throw new TypeError('invalid port: ' + url.port);
568
+ }
569
+ const name = decodeURIComponent(url.hash.slice(1));
570
+ return {
571
+ raw: line,
572
+ name,
573
+ type: 'trojan',
574
+ server,
575
+ port,
576
+ password,
577
+ udp: true,
578
+ sni: url.searchParams.get('sni') ?? server,
579
+ skipCertVerify: true
580
+ };
581
+ }
582
+
583
+ var index = {
584
+ __proto__: null,
585
+ parse: parse
586
+ };
587
+
588
+ export { index$2 as clash, index$1 as ss, index$3 as surge, index as trojan };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodelistparser",
3
- "version": "0.1.4",
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",
@@ -37,19 +37,19 @@
37
37
  "foxts": "^1.5.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@eslint-sukka/node": "^6.14.0",
40
+ "@eslint-sukka/node": "^6.16.1",
41
41
  "@swc-node/register": "^1.10.9",
42
- "@swc/core": "^1.10.16",
42
+ "@swc/core": "^1.11.8",
43
43
  "@types/mocha": "^10.0.10",
44
- "@types/node": "^22.13.4",
44
+ "@types/node": "^22.13.10",
45
45
  "bumpp": "^10.0.3",
46
- "bunchee": "^6.3.4",
47
- "eslint": "^9.20.1",
48
- "eslint-config-sukka": "^6.14.0",
49
- "eslint-formatter-sukka": "^6.14.0",
46
+ "bunchee": "^6.4.0",
47
+ "eslint": "^9.22.0",
48
+ "eslint-config-sukka": "^6.16.1",
49
+ "eslint-formatter-sukka": "^6.16.1",
50
50
  "expect": "^29.7.0",
51
51
  "mocha": "^11.1.0",
52
- "typescript": "^5.7.3"
52
+ "typescript": "^5.8.2"
53
53
  },
54
54
  "scripts": {
55
55
  "lint": "eslint --format=sukka .",