Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm i input is deprecated, could cause a slowdown up to 100x even if nothing is polyfilled #657

Open
cxinu opened this issue Mar 31, 2024 · 0 comments

Comments

@cxinu
Copy link
Contributor

cxinu commented Mar 31, 2024

πŸ“¦ v1.0.0 via  v20.12.0 
❯ npm i input
npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.

added 32 packages, and audited 134 packages in 8s

13 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Use alternative package of input or in-build readline input library
Input package is instructed to install in README.md

Edit: Neither importing this library works

src/main.ts:3:19 - error TS7016: Could not find a declaration file for module 'input'. '/home/cxinu/dev/bot-dev/tg-premium/node_modules/input/dist/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/input` if it exists or add a new declaration (.d.ts) file containing `declare module 'input';`

3 import input from "input";
                    ~~~~~~~


Found 1 error in src/main.ts:3

Here's an implementation using inbuild readline

import { TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";
import readline from "readline";

const apiId = 123456;
const apiHash = "123456abcdfg";
const stringSession = new StringSession(""); // fill this later with the value from session.save()

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

(async () => {
  console.log("Loading interactive example...");
  const client = new TelegramClient(stringSession, apiId, apiHash, {
    connectionRetries: 5,
  });
  await client.start({
    phoneNumber: async () =>
      await new Promise<string>((resolve) =>
        rl.question("Please enter your number: ", resolve)
      ),
    password: async () =>
      await new Promise<string>((resolve) =>
        rl.question("Please enter your password: ", resolve)
      ),
    phoneCode: async () =>
      await new Promise<string>((resolve) =>
        rl.question("Please enter the code you received: ", resolve)
      ),
    onError: (err) => console.log(err),
  });
  console.log("You should now be connected.");
  console.log(client.session.save()); // Save this string to avoid logging in again
  await client.sendMessage("me", { message: "Hello!" });
})();
painor pushed a commit that referenced this issue Apr 12, 2024
input library is deprecated and doesn't work for input anymore.
#657
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant