diff --git a/.gitattributes b/.gitattributes
index dfe0770..5a0d5e4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization
-* text=auto
+* text=auto eol=lf
diff --git a/DOCS.md b/DOCS.md
index c5a996b..a28eda8 100644
--- a/DOCS.md
+++ b/DOCS.md
@@ -1064,28 +1064,50 @@ This method only works for E2EE (end-to-end encrypted) messages. For regular mes
## client.getDeviceData()
-Get E2EE device data for storage.
+Get the current E2EE device data as JSON string.
+
+This returns the current in-memory E2EE device state, which includes:
+- Noise key pair (for encrypted communication)
+- Identity key pair (for identity verification)
+- Signed pre-key (for session establishment)
+- Registration ID
+- All sessions and identities established with other users
__Returns__
string - Device data as JSON string
-__Note__
+__Works with all device store modes__
+
+| Mode | Description |
+|------|-------------|
+| `e2eeMemoryOnly: true` | Get the ephemeral device data before it's lost on disconnect |
+| `deviceData: "..."` | Get the updated state after sessions/keys change |
+| `devicePath: "..."` | Get current state (also auto-saved to file) |
-Save device data to avoid setting up E2EE again on each startup.
+__Use cases__
+
+- Save device data to database instead of file
+- Backup device state periodically
+- Transfer device state between instances
+- Export state from memory-only mode before disconnect
__Example__
```typescript
import { writeFileSync } from 'fs'
-// Save device data
+// Save device data to file
const deviceData = client.getDeviceData()
writeFileSync('device.json', deviceData)
+// Or save to database
+await db.saveDeviceData(userId, deviceData)
+
// Load on startup
const client = new Client(cookies, {
deviceData: readFileSync('device.json', 'utf-8')
+ // or: deviceData: await db.getDeviceData(userId)
})
```
diff --git a/DOCS_VI.md b/DOCS_VI.md
index 2f15782..e52a686 100644
--- a/DOCS_VI.md
+++ b/DOCS_VI.md
@@ -1064,28 +1064,50 @@ Method này chỉ hoạt động với tin nhắn E2EE (mã hóa đầu cuối).
## client.getDeviceData()
-Lấy E2EE device data để lưu trữ.
+Lấy dữ liệu E2EE device hiện tại dưới dạng JSON string.
+
+Method này trả về trạng thái E2EE device hiện tại trong bộ nhớ, bao gồm:
+- Noise key pair (cho giao tiếp mã hóa)
+- Identity key pair (cho xác minh danh tính)
+- Signed pre-key (cho thiết lập session)
+- Registration ID
+- Tất cả sessions và identities đã thiết lập với người dùng khác
__Trả về__
string - Device data dưới dạng JSON string
-__Lưu ý__
+__Hoạt động với tất cả các chế độ device store__
+
+| Chế độ | Mô tả |
+|------|-------------|
+| `e2eeMemoryOnly: true` | Lấy dữ liệu tạm thời trước khi mất khi ngắt kết nối |
+| `deviceData: "..."` | Lấy trạng thái đã cập nhật sau khi sessions/keys thay đổi |
+| `devicePath: "..."` | Lấy trạng thái hiện tại (cũng tự động lưu vào file) |
-Lưu device data để tránh phải setup E2EE lại mỗi lần khởi động.
+__Các trường hợp sử dụng__
+
+- Lưu device data vào database thay vì file
+- Backup trạng thái device định kỳ
+- Chuyển trạng thái device giữa các instance
+- Xuất trạng thái từ memory-only mode trước khi ngắt kết nối
__Ví dụ__
```typescript
import { writeFileSync } from 'fs'
-// Lưu device data
+// Lưu device data vào file
const deviceData = client.getDeviceData()
writeFileSync('device.json', deviceData)
+// Hoặc lưu vào database
+await db.saveDeviceData(userId, deviceData)
+
// Load khi khởi động
const client = new Client(cookies, {
deviceData: readFileSync('device.json', 'utf-8')
+ // hoặc: deviceData: await db.getDeviceData(userId)
})
```
diff --git a/src/client.ts b/src/client.ts
index e22e759..303648f 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -710,11 +710,39 @@ export class Client extends (EventEmitter as new () => TypedEventEmitter