Skip to content

Commit 9b290b1

Browse files
Merge pull request #45 from muhammedaksam/develop
fix: authentication method and update package version
2 parents 42e2c4b + 19df50f commit 9b290b1

5 files changed

Lines changed: 33 additions & 40 deletions

File tree

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@muhammedaksam/waha-tui",
3-
"version": "1.5.11",
3+
"version": "1.5.12",
44
"description": "TUI client for WhatsApp using WAHA (WhatsApp HTTP API) - manage chats, send messages, and more from your terminal",
55
"type": "module",
66
"bin": {
@@ -71,7 +71,7 @@
7171
"typescript": "^5.9.3"
7272
},
7373
"dependencies": {
74-
"@muhammedaksam/waha-node": "^2026.1.4",
74+
"@muhammedaksam/waha-node": "2026.1.4-dev.2",
7575
"@opentui-ui/dialog": "^0.1.2",
7676
"@opentui-ui/toast": "^0.0.5",
7777
"@opentui/core": "^0.1.75",

src/utils/pairing.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
/**
2-
* Phone Number Pairing utilities
3-
* Alternative authentication method using pairing codes
2+
* Phone Number Pairing and QR Code utilities
3+
* Alternative authentication methods for WhatsApp sessions
44
*/
55

66
import { getClient } from "~/client"
77
import { debugLog } from "~/utils/debug"
88

9+
/**
10+
* Get QR code as raw data from WAHA API
11+
*/
12+
export async function getQRCode(sessionName: string): Promise<string | null> {
13+
try {
14+
debugLog("QR", `Fetching QR code for session: ${sessionName}`)
15+
const client = getClient()
16+
17+
const { data } = await client.pairing.authControllerGetQr(sessionName, {
18+
format: "raw",
19+
})
20+
21+
if (typeof data === "object" && data && "value" in data) {
22+
debugLog("QR", `QR code fetched successfully for ${sessionName}`)
23+
return (data as { value: string }).value
24+
}
25+
26+
debugLog("QR", `No QR value in response for ${sessionName}`)
27+
return null
28+
} catch (error) {
29+
debugLog("QR", `Failed to fetch QR code: ${error}`)
30+
return null
31+
}
32+
}
33+
934
export interface PairingResult {
1035
success: boolean
1136
code?: string
@@ -38,7 +63,7 @@ export async function requestPairingCode(
3863
debugLog("Pairing", `Requesting code for: ${cleanNumber}`)
3964
const client = getClient()
4065

41-
const { data } = await client.auth.authControllerRequestCode(sessionName, {
66+
const { data } = await client.pairing.authControllerRequestCode(sessionName, {
4267
phoneNumber: cleanNumber,
4368
method: undefined, // undefined = web pairing (not SMS/voice)
4469
})

src/utils/qr.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/views/QRCodeView.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import { Icons, WhatsAppTheme } from "~/config/theme"
1414
import { TIME_MS } from "~/constants"
1515
import { appState } from "~/state/AppState"
1616
import { debugLog } from "~/utils/debug"
17-
import { requestPairingCode } from "~/utils/pairing"
18-
import { getQRCode } from "~/utils/qr"
17+
import { getQRCode, requestPairingCode } from "~/utils/pairing"
1918
import { createNewSession } from "~/views/SessionCreate"
2019

2120
// Module-level intervals for QR refresh and status checking

0 commit comments

Comments
 (0)