Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot]
718439841e chore(deps): bump fs-extra from 10.1.0 to 11.1.0
Bumps [fs-extra](https://github.com/jprichardson/node-fs-extra) from 10.1.0 to 11.1.0.
- [Release notes](https://github.com/jprichardson/node-fs-extra/releases)
- [Changelog](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jprichardson/node-fs-extra/compare/10.1.0...11.1.0)

---
updated-dependencies:
- dependency-name: fs-extra
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-01 19:03:14 +00:00
5 changed files with 8 additions and 52 deletions

View File

@@ -54,7 +54,7 @@
}, },
"optionalDependencies": { "optionalDependencies": {
"archiver": "^5.3.1", "archiver": "^5.3.1",
"fs-extra": "^10.1.0", "fs-extra": "^11.1.0",
"unzipper": "^0.10.11" "unzipper": "^0.10.11"
} }
} }

View File

@@ -6,7 +6,6 @@ const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
const Util = require('./util/Util'); const Util = require('./util/Util');
const InterfaceController = require('./util/InterfaceController'); const InterfaceController = require('./util/InterfaceController');
const { getIndexForVersion } = require('./util/VersionResolver');
const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constants'); const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constants');
const { ExposeStore, LoadUtils } = require('./util/Injected'); const { ExposeStore, LoadUtils } = require('./util/Injected');
const ChatFactory = require('./factories/ChatFactory'); const ChatFactory = require('./factories/ChatFactory');
@@ -109,7 +108,6 @@ class Client extends EventEmitter {
this.pupPage = page; this.pupPage = page;
await this.authStrategy.afterBrowserInitialized(); await this.authStrategy.afterBrowserInitialized();
await this.initVersionOverride();
await page.goto(WhatsWebURL, { await page.goto(WhatsWebURL, {
waitUntil: 'load', waitUntil: 'load',
@@ -564,22 +562,6 @@ class Client extends EventEmitter {
}); });
} }
async initVersionOverride() {
const version = this.options.webVersion;
await this.pupPage.setRequestInterception(true);
this.pupPage.on('request', async (req) => {
if(req.url() === WhatsWebURL) {
req.respond({
status: 200,
contentType: 'text/html',
body: await getIndexForVersion(version)
});
} else {
req.continue();
}
});
}
/** /**
* Closes the client * Closes the client
*/ */

View File

@@ -7,7 +7,6 @@ exports.DefaultOptions = {
headless: true, headless: true,
defaultViewport: null defaultViewport: null
}, },
webVersion: '2.2244.6',
authTimeoutMs: 0, authTimeoutMs: 0,
qrMaxRetries: 0, qrMaxRetries: 0,
takeoverOnConflict: false, takeoverOnConflict: false,

View File

@@ -1,16 +0,0 @@
const fetch = require('node-fetch');
const VERSION_ARCHIVE_URL = 'https://archive.wwebjs.dev/web-index';
class VersionResolveError extends Error { }
const getIndexForVersion = async (version) => {
const cachedRes = await fetch(`${VERSION_ARCHIVE_URL}/${version}`);
if(!cachedRes.ok) throw new VersionResolveError(`Couldn't load app for version ${version} from the archive`);
return cachedRes.text();
};
module.exports = {
VersionResolveError,
getIndexForVersion
};

View File

@@ -18,24 +18,15 @@ const getCurrentVersion = () => {
} }
}; };
const updateInFile = (filePath, oldVersion, newVersion) => {
const originalFile = fs.readFileSync(filePath);
const newFile = originalFile.toString().replaceAll(oldVersion, newVersion);
fs.writeFileSync(filePath, newFile);
};
const updateVersion = async (oldVersion, newVersion) => { const updateVersion = async (oldVersion, newVersion) => {
const filesToUpdate = [ const readmePath = '../../README.md';
'../../src/util/Constants.js',
'../../README.md', const readme = fs.readFileSync(readmePath);
]; const newReadme = readme.toString().replaceAll(oldVersion, newVersion);
for (const file of filesToUpdate) { fs.writeFileSync(readmePath, newReadme);
updateInFile(file, oldVersion, newVersion); fs.writeFileSync('./.version', newVersion);
}
fs.writeFileSync('./.version', newVersion);
}; };
(async () => { (async () => {