nodelistparser 0.1.1 → 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.
@@ -31,6 +31,8 @@ interface ShadowSocksConfig extends SharedConfigBase {
31
31
  obfsHost?: string;
32
32
  /** obfs-uri */
33
33
  obfsUri?: string;
34
+ /** udp-port */
35
+ udpPort?: number;
34
36
  }
35
37
  interface TrojanConfig extends SharedConfigBase, TlsSharedConfig {
36
38
  type: 'trojan';
@@ -258,12 +260,14 @@ declare namespace index$1 {
258
260
  }
259
261
 
260
262
  declare function decodeOne(sip002: string): ShadowSocksConfig;
263
+ declare function decodeBase64Multiline(text: string): string[];
261
264
  declare function decodeMultiline(text: string): ShadowSocksConfig[];
262
265
 
266
+ declare const index_decodeBase64Multiline: typeof decodeBase64Multiline;
263
267
  declare const index_decodeMultiline: typeof decodeMultiline;
264
268
  declare const index_decodeOne: typeof decodeOne;
265
269
  declare namespace index {
266
- export { index_decodeMultiline as decodeMultiline, index_decodeOne as decodeOne };
270
+ export { index_decodeBase64Multiline as decodeBase64Multiline, index_decodeMultiline as decodeMultiline, index_decodeOne as decodeOne };
267
271
  }
268
272
 
269
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 };
package/dist/cjs/index.js CHANGED
@@ -25,7 +25,8 @@ const isProxyBoolKey = (key)=>boolKeys.has(key);
25
25
  const numKeys = new Set([
26
26
  'version',
27
27
  'download-bandwidth',
28
- 'port-hopping-interval'
28
+ 'port-hopping-interval',
29
+ 'udp-port'
29
30
  ]);
30
31
  const isProxyNumKey = (key)=>numKeys.has(key);
31
32
  const arrKeys = new Set([]);
@@ -118,6 +119,7 @@ function decode$1(raw) {
118
119
  obfs: restDetails.obfs,
119
120
  obfsHost: restDetails['obfs-host'],
120
121
  obfsUri: restDetails['obfs-uri'],
122
+ udpPort: restDetails['udp-port'],
121
123
  ...shared
122
124
  };
123
125
  }
@@ -215,6 +217,7 @@ function encode$1(config) {
215
217
  return joinString([
216
218
  `${config.name} = ss, ${config.server}, ${config.port}, encrypt-method=${config.cipher}, password=${config.password}`,
217
219
  config.udp && 'udp-relay=true',
220
+ config.udpPort && `udp-port=${config.udpPort}`,
218
221
  config.obfs && `obfs=${config.obfs}`,
219
222
  config.obfsHost && `obfs-host=${config.obfsHost}`,
220
223
  config.obfsUri && `obfs-uri=${config.obfsUri}`,
@@ -473,7 +476,10 @@ var index$1 = {
473
476
 
474
477
  function decodeOne(sip002) {
475
478
  // ss://YWVzLTEyOC1nY206YzMxNWFhOGMtNGU1NC00MGRjLWJkYzctYzFjMjEwZjIxYTNi@ss1.meslink.xyz:10009#%F0%9F%87%AD%F0%9F%87%B0%20HK1%20HKT
476
- const [_type, payload] = sip002.split('://');
479
+ const [type, payload] = sip002.split('://');
480
+ if (type !== 'ss') {
481
+ throw new Error(`[ss.decodeOne] Unsupported type: ${type}`);
482
+ }
477
483
  const [userInfo, server] = payload.split('@');
478
484
  let cipher, password;
479
485
  if (userInfo.includes(':')) {
@@ -496,13 +502,16 @@ function decodeOne(sip002) {
496
502
  udp: true
497
503
  };
498
504
  }
505
+ function decodeBase64Multiline(text) {
506
+ return atob(text).replaceAll('\r\n', '\n').split('\n').filter(Boolean);
507
+ }
499
508
  function decodeMultiline(text) {
500
- const lines = atob(text).replaceAll('\r\n', '\n').split('\n');
501
- return lines.filter(Boolean).map((line)=>decodeOne(line));
509
+ return decodeBase64Multiline(text).map((line)=>decodeOne(line));
502
510
  }
503
511
 
504
512
  var index = {
505
513
  __proto__: null,
514
+ decodeBase64Multiline: decodeBase64Multiline,
506
515
  decodeMultiline: decodeMultiline,
507
516
  decodeOne: decodeOne
508
517
  };
@@ -31,6 +31,8 @@ interface ShadowSocksConfig extends SharedConfigBase {
31
31
  obfsHost?: string;
32
32
  /** obfs-uri */
33
33
  obfsUri?: string;
34
+ /** udp-port */
35
+ udpPort?: number;
34
36
  }
35
37
  interface TrojanConfig extends SharedConfigBase, TlsSharedConfig {
36
38
  type: 'trojan';
@@ -258,12 +260,14 @@ declare namespace index$1 {
258
260
  }
259
261
 
260
262
  declare function decodeOne(sip002: string): ShadowSocksConfig;
263
+ declare function decodeBase64Multiline(text: string): string[];
261
264
  declare function decodeMultiline(text: string): ShadowSocksConfig[];
262
265
 
266
+ declare const index_decodeBase64Multiline: typeof decodeBase64Multiline;
263
267
  declare const index_decodeMultiline: typeof decodeMultiline;
264
268
  declare const index_decodeOne: typeof decodeOne;
265
269
  declare namespace index {
266
- export { index_decodeMultiline as decodeMultiline, index_decodeOne as decodeOne };
270
+ export { index_decodeBase64Multiline as decodeBase64Multiline, index_decodeMultiline as decodeMultiline, index_decodeOne as decodeOne };
267
271
  }
268
272
 
269
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 };
package/dist/es/index.mjs CHANGED
@@ -25,7 +25,8 @@ const isProxyBoolKey = (key)=>boolKeys.has(key);
25
25
  const numKeys = new Set([
26
26
  'version',
27
27
  'download-bandwidth',
28
- 'port-hopping-interval'
28
+ 'port-hopping-interval',
29
+ 'udp-port'
29
30
  ]);
30
31
  const isProxyNumKey = (key)=>numKeys.has(key);
31
32
  const arrKeys = new Set([]);
@@ -118,6 +119,7 @@ function decode$1(raw) {
118
119
  obfs: restDetails.obfs,
119
120
  obfsHost: restDetails['obfs-host'],
120
121
  obfsUri: restDetails['obfs-uri'],
122
+ udpPort: restDetails['udp-port'],
121
123
  ...shared
122
124
  };
123
125
  }
@@ -215,6 +217,7 @@ function encode$1(config) {
215
217
  return joinString([
216
218
  `${config.name} = ss, ${config.server}, ${config.port}, encrypt-method=${config.cipher}, password=${config.password}`,
217
219
  config.udp && 'udp-relay=true',
220
+ config.udpPort && `udp-port=${config.udpPort}`,
218
221
  config.obfs && `obfs=${config.obfs}`,
219
222
  config.obfsHost && `obfs-host=${config.obfsHost}`,
220
223
  config.obfsUri && `obfs-uri=${config.obfsUri}`,
@@ -473,7 +476,10 @@ var index$1 = {
473
476
 
474
477
  function decodeOne(sip002) {
475
478
  // ss://YWVzLTEyOC1nY206YzMxNWFhOGMtNGU1NC00MGRjLWJkYzctYzFjMjEwZjIxYTNi@ss1.meslink.xyz:10009#%F0%9F%87%AD%F0%9F%87%B0%20HK1%20HKT
476
- const [_type, payload] = sip002.split('://');
479
+ const [type, payload] = sip002.split('://');
480
+ if (type !== 'ss') {
481
+ throw new Error(`[ss.decodeOne] Unsupported type: ${type}`);
482
+ }
477
483
  const [userInfo, server] = payload.split('@');
478
484
  let cipher, password;
479
485
  if (userInfo.includes(':')) {
@@ -496,13 +502,16 @@ function decodeOne(sip002) {
496
502
  udp: true
497
503
  };
498
504
  }
505
+ function decodeBase64Multiline(text) {
506
+ return atob(text).replaceAll('\r\n', '\n').split('\n').filter(Boolean);
507
+ }
499
508
  function decodeMultiline(text) {
500
- const lines = atob(text).replaceAll('\r\n', '\n').split('\n');
501
- return lines.filter(Boolean).map((line)=>decodeOne(line));
509
+ return decodeBase64Multiline(text).map((line)=>decodeOne(line));
502
510
  }
503
511
 
504
512
  var index = {
505
513
  __proto__: null,
514
+ decodeBase64Multiline: decodeBase64Multiline,
506
515
  decodeMultiline: decodeMultiline,
507
516
  decodeOne: decodeOne
508
517
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodelistparser",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Surge / Mihomo (Clash.Meta) nodelist / proxy provider parser and generator.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,15 +34,15 @@
34
34
  "author": "Sukka <https://skk.moe>",
35
35
  "license": "MIT",
36
36
  "devDependencies": {
37
- "@eslint-sukka/node": "^6.7.0",
37
+ "@eslint-sukka/node": "^6.8.1",
38
38
  "@swc-node/register": "^1.10.9",
39
39
  "@types/mocha": "^10.0.9",
40
- "@types/node": "^22.7.6",
40
+ "@types/node": "^22.8.1",
41
41
  "bumpp": "^9.7.1",
42
42
  "bunchee": "^5.5.1",
43
- "eslint": "^9.12.0",
44
- "eslint-config-sukka": "^6.7.0",
45
- "eslint-formatter-sukka": "^6.7.0",
43
+ "eslint": "^9.13.0",
44
+ "eslint-config-sukka": "^6.8.1",
45
+ "eslint-formatter-sukka": "^6.8.1",
46
46
  "expect": "^29.7.0",
47
47
  "mocha": "^10.7.3",
48
48
  "typescript": "^5.6.3"