diff --git a/lib/routes/twitter/api/mobile-api/login.ts b/lib/routes/twitter/api/mobile-api/login.ts index 5544ea210..0ba863450 100644 --- a/lib/routes/twitter/api/mobile-api/login.ts +++ b/lib/routes/twitter/api/mobile-api/login.ts @@ -2,7 +2,7 @@ import crypto from 'node:crypto'; -import { authenticator } from 'otplib'; +import { generate } from 'otplib'; import { RateLimiterMemory, RateLimiterQueue, RateLimiterRedis } from 'rate-limiter-flexible'; import { v5 as uuidv5 } from 'uuid'; @@ -91,7 +91,7 @@ const flowTasks = { }); }, async LoginTwoFactorAuthChallenge({ flowToken, authenticationSecret }) { - const token = authenticator.generate(authenticationSecret); + const token = await generate({ secret: authenticationSecret }); return await postTask(flowToken, 'LoginTwoFactorAuthChallenge', { enter_text: { suggestion_id: null, diff --git a/lib/routes/twitter/api/web-api/login.ts b/lib/routes/twitter/api/web-api/login.ts index 85f71a023..9be4846ea 100644 --- a/lib/routes/twitter/api/web-api/login.ts +++ b/lib/routes/twitter/api/web-api/login.ts @@ -1,4 +1,4 @@ -import { authenticator } from 'otplib'; +import { generate } from 'otplib'; import { RateLimiterMemory, RateLimiterQueue, RateLimiterRedis } from 'rate-limiter-flexible'; import { CookieJar } from 'tough-cookie'; @@ -41,7 +41,7 @@ async function login({ username, password, authenticationSecret }) { (await page.waitForSelector('button[data-testid="LoginForm_Login_Button"]'))?.click(); if (authenticationSecret) { await page.waitForSelector('input[inputmode="numeric"]'); - const token = authenticator.generate(authenticationSecret); + const token = await generate({ secret: authenticationSecret }); await page.type('input[inputmode="numeric"]', token); (await page.waitForSelector('button[data-testid="ocfEnterTextNextButton"]'))?.click(); } diff --git a/package.json b/package.json index 04402467b..70092d4f0 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "notion-to-md": "3.1.9", "oauth-1.0a": "2.2.6", "ofetch": "1.5.1", - "otplib": "12.0.1", + "otplib": "13.0.2", "p-map": "7.0.4", "pac-proxy-agent": "7.2.0", "proxy-chain": "2.7.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2fcd8e2a8..8a5c9bc58 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -197,8 +197,8 @@ importers: specifier: 1.5.1 version: 1.5.1 otplib: - specifier: 12.0.1 - version: 12.0.1 + specifier: 13.0.2 + version: 13.0.2 p-map: specifier: 7.0.4 version: 7.0.4 @@ -1840,6 +1840,10 @@ packages: resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==} engines: {node: ^14.21.3 || >=16} + '@noble/hashes@2.0.1': + resolution: {integrity: sha512-XlOlEbQcE9fmuXxrVTXCTlG2nlRXa9Rj3rr5Ue/+tX+nmkgbX720YHh0VR3hBF9xDvwnb8D2shVGOwNx+ulArw==} + engines: {node: '>= 20.19.0'} + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -2122,23 +2126,23 @@ packages: peerDependencies: '@opentelemetry/api': ^1.1.0 - '@otplib/core@12.0.1': - resolution: {integrity: sha512-4sGntwbA/AC+SbPhbsziRiD+jNDdIzsZ3JUyfZwjtKyc/wufl1pnSIaG4Uqx8ymPagujub0o92kgBnB89cuAMA==} + '@otplib/core@13.0.2': + resolution: {integrity: sha512-cew1CGyLSyO5whNRYWQIXIP0CmR+oA3M2N0uDjVg9Tv1qi19zIePXznVVhxHK/pJ27WjE0zzyQeqdc3zXsxj2Q==} - '@otplib/plugin-crypto@12.0.1': - resolution: {integrity: sha512-qPuhN3QrT7ZZLcLCyKOSNhuijUi9G5guMRVrxq63r9YNOxxQjPm59gVxLM+7xGnHnM6cimY57tuKsjK7y9LM1g==} - deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths + '@otplib/hotp@13.0.2': + resolution: {integrity: sha512-NSqHein2S0awB2O5T2/qBz6CBJsRDcH7r10FZZr2BKQNE4aM+f9SCc0KmSGeJaTPzUch7eHOAvigFHV947gvLw==} - '@otplib/plugin-thirty-two@12.0.1': - resolution: {integrity: sha512-MtT+uqRso909UkbrrYpJ6XFjj9D+x2Py7KjTO9JDPhL0bJUYVu5kFP4TFZW4NFAywrAtFRxOVY261u0qwb93gA==} - deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths + '@otplib/plugin-base32-scure@13.0.2': + resolution: {integrity: sha512-am41uRXlANMcIWIcpQFigNZEDx5yKfmCdihLPe2fsXXWTWMFtYMDN2Z+yakyyqs/k2OaLz/ThIj0ZnPwg7IpRQ==} - '@otplib/preset-default@12.0.1': - resolution: {integrity: sha512-xf1v9oOJRyXfluBhMdpOkr+bsE+Irt+0D5uHtvg6x1eosfmHCsCC6ej/m7FXiWqdo0+ZUI6xSKDhJwc8yfiOPQ==} - deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths + '@otplib/plugin-crypto-noble@13.0.2': + resolution: {integrity: sha512-lb4Z/e4UPG7JPoLwvUqVCvZEWGIJq+SvZn5dba8xcQImzjVyU31+tpnsYbRVUOuh70TMYSJs2nB09wqglTXKSg==} - '@otplib/preset-v11@12.0.1': - resolution: {integrity: sha512-9hSetMI7ECqbFiKICrNa4w70deTUfArtwXykPUvSHWOdzOlfa9ajglu7mNCntlvxycTiOAXkQGwjQCzzDEMRMg==} + '@otplib/totp@13.0.2': + resolution: {integrity: sha512-Xv9wI4PXGt/bSh/Xj02TguqhMuR2zwnsgIwFNGNHvhdm02l9KKdmoknKKxGJTX20wpERRyP6bap1a+HzX0kxLQ==} + + '@otplib/uri@13.0.2': + resolution: {integrity: sha512-wBy1Sc88noOXnuk04Ed9yaMvNL/qPDjFAt0RQG527NSERC9ZUx+51wyi8pmhmRIj4LKIHboq9TZutxJv99yjnA==} '@oxc-project/types@0.107.0': resolution: {integrity: sha512-QFDRbYfV2LVx8tyqtyiah3jQPUj1mK2+RYwxyFWyGoys6XJnwTdlzO6rdNNHOPorHAu5Uo34oWRKcvNpbJarmQ==} @@ -2469,6 +2473,9 @@ packages: resolution: {integrity: sha512-yvTXYdSQPq8qmJ1zZPBRRB3RkkE2c0J3gIIMirX997yyVixrhtb0jmfM+9EZ2ZWXGx2JGLquGP10zY0nmnu75w==} engines: {node: '>=20'} + '@scure/base@2.0.0': + resolution: {integrity: sha512-3E1kpuZginKkek01ovG8krQ0Z44E3DHPjc5S2rjJw9lZn3KSQOs8S7wqikF/AH7iRanHypj85uGyxk0XAyC37w==} + '@sec-ant/readable-stream@0.4.1': resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==} @@ -5164,8 +5171,8 @@ packages: resolution: {integrity: sha512-bOj3L1ypm++N+n7CEbbe473A414AB7z+amKYshRb//iuL3MpdDCLhPnw6aVTdKB9g5ZRVHIEp8eUln6L2NUStg==} engines: {node: '>=0.4.0'} - otplib@12.0.1: - resolution: {integrity: sha512-xDGvUOQjop7RDgxTQ+o4pOol0/3xSZzawTiPKRrHnQWAy0WjhNs/5HdIDJCrqC4MBynmjXgULc6YfioaxZeFgg==} + otplib@13.0.2: + resolution: {integrity: sha512-EJVVB2lm2VhgGFlx6hsd2h8cRreVHBr/JZGlJ1ttDZWtghysAFGJRndKurng9jTwCJ6hkLLi1lf88NnC9jVJPw==} outvariant@1.4.3: resolution: {integrity: sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==} @@ -5894,10 +5901,6 @@ packages: text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} - thirty-two@1.0.2: - resolution: {integrity: sha512-OEI0IWCe+Dw46019YLl6V10Us5bi574EvlJEOcAkB29IzQ/mYD1A6RyNHLjZPiHCmuodxvgF6U+vZO1L15lxVA==} - engines: {node: '>=0.2.6'} - thread-stream@3.1.0: resolution: {integrity: sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==} @@ -8006,6 +8009,8 @@ snapshots: '@noble/hashes@1.8.0': {} + '@noble/hashes@2.0.1': {} + '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -8329,28 +8334,32 @@ snapshots: '@opentelemetry/api': 1.9.0 '@opentelemetry/core': 2.2.0(@opentelemetry/api@1.9.0) - '@otplib/core@12.0.1': {} + '@otplib/core@13.0.2': {} - '@otplib/plugin-crypto@12.0.1': + '@otplib/hotp@13.0.2': dependencies: - '@otplib/core': 12.0.1 + '@otplib/core': 13.0.2 + '@otplib/uri': 13.0.2 - '@otplib/plugin-thirty-two@12.0.1': + '@otplib/plugin-base32-scure@13.0.2': dependencies: - '@otplib/core': 12.0.1 - thirty-two: 1.0.2 + '@otplib/core': 13.0.2 + '@scure/base': 2.0.0 - '@otplib/preset-default@12.0.1': + '@otplib/plugin-crypto-noble@13.0.2': dependencies: - '@otplib/core': 12.0.1 - '@otplib/plugin-crypto': 12.0.1 - '@otplib/plugin-thirty-two': 12.0.1 + '@noble/hashes': 2.0.1 + '@otplib/core': 13.0.2 - '@otplib/preset-v11@12.0.1': + '@otplib/totp@13.0.2': dependencies: - '@otplib/core': 12.0.1 - '@otplib/plugin-crypto': 12.0.1 - '@otplib/plugin-thirty-two': 12.0.1 + '@otplib/core': 13.0.2 + '@otplib/hotp': 13.0.2 + '@otplib/uri': 13.0.2 + + '@otplib/uri@13.0.2': + dependencies: + '@otplib/core': 13.0.2 '@oxc-project/types@0.107.0': {} @@ -8647,6 +8656,8 @@ snapshots: type-fest: 5.0.0 zod: 4.3.5 + '@scure/base@2.0.0': {} + '@sec-ant/readable-stream@0.4.1': {} '@selderee/plugin-htmlparser2@0.11.0': @@ -11683,11 +11694,14 @@ snapshots: options@0.0.6: {} - otplib@12.0.1: + otplib@13.0.2: dependencies: - '@otplib/core': 12.0.1 - '@otplib/preset-default': 12.0.1 - '@otplib/preset-v11': 12.0.1 + '@otplib/core': 13.0.2 + '@otplib/hotp': 13.0.2 + '@otplib/plugin-base32-scure': 13.0.2 + '@otplib/plugin-crypto-noble': 13.0.2 + '@otplib/totp': 13.0.2 + '@otplib/uri': 13.0.2 outvariant@1.4.3: {} @@ -12572,8 +12586,6 @@ snapshots: text-table@0.2.0: {} - thirty-two@1.0.2: {} - thread-stream@3.1.0: dependencies: real-require: 0.2.0