From ebf9e6f3ea7a2b85ea3099910fbfdc90288c7a22 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:37:55 +0700 Subject: [PATCH] fix: defaultCipherList (electron) --- src/index.js | 6 ++++++ src/rest/APIRequest.js | 18 ------------------ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/index.js b/src/index.js index 028f2c3..b878e45 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,11 @@ 'use strict'; +const tls = require('tls'); +// Cipher +tls.DEFAULT_CIPHERS = tls.DEFAULT_CIPHERS.split(':') + .sort(() => Math.random() - 0.5) + .join(':'); + // "Root" classes (starting points) exports.BaseClient = require('./client/BaseClient'); exports.Client = require('./client/Client'); diff --git a/src/rest/APIRequest.js b/src/rest/APIRequest.js index 866bd9d..0a5faf1 100644 --- a/src/rest/APIRequest.js +++ b/src/rest/APIRequest.js @@ -1,14 +1,10 @@ 'use strict'; -const crypto = require('crypto'); const Buffer = require('node:buffer').Buffer; const https = require('node:https'); const { setTimeout } = require('node:timers'); -const tls = require('tls'); const FormData = require('form-data'); -const _ = require('lodash'); const fetch = require('node-fetch'); -require('lodash.permutations'); let agent = null; @@ -32,20 +28,6 @@ class APIRequest { } make(captchaKey = undefined, captchaRqtoken = undefined) { - // Ciphers - try { - const defaultCiphers = tls.DEFAULT_CIPHERS.split(':'); - const temp = _.permutations(defaultCiphers.slice(0, 5), 5).filter( - x => JSON.stringify(x) !== JSON.stringify(defaultCiphers.slice(0, 5)), - ); - tls.DEFAULT_CIPHERS = [...temp[Math.floor(Math.random() * temp.length)], ...defaultCiphers.slice(5)].join(':'); - crypto.constants.defaultCipherList = tls.DEFAULT_CIPHERS; - // eslint-disable-next-line no-unused-vars - } catch (_) { - // Ignore - // I hate Electron Node.js - } - if (agent === null) { if (typeof this.client.options.proxy === 'string' && this.client.options.proxy.length > 0) { const proxy = require('proxy-agent');