js_lis 3.1.2 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -164
- package/main.js +32 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,164 +1,135 @@
|
|
|
1
|
-
# js_lis
|
|
2
|
-
|
|
3
|
-
**js_lis** is a JavaScript on-screen keyboard
|
|
4
|
-
|
|
5
|
-
NPM package: [https://www.npmjs.com/package/js_lis](https://www.npmjs.com/package/js_lis)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
`
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
###
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
<button id="toggle" type="button">แสดง/ซ่อนคีย์บอร์ด</button>
|
|
137
|
-
<div id="keyboard-container"></div>
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
```javascript
|
|
141
|
-
import { VirtualKeyboard } from "./VirtualKeyboard.js";
|
|
142
|
-
|
|
143
|
-
window.addEventListener("DOMContentLoaded", () => {
|
|
144
|
-
const keyboard = new VirtualKeyboard();
|
|
145
|
-
|
|
146
|
-
// ตัวอย่างการเรียกใช้งาน element ผ่าน id
|
|
147
|
-
const secureInput = document.getElementById("secure-input");
|
|
148
|
-
if (secureInput) secureInput.focus();
|
|
149
|
-
});
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### แนวทางการใช้งานที่แนะนำ
|
|
153
|
-
|
|
154
|
-
- ให้บริการผ่าน HTTPS เท่านั้น
|
|
155
|
-
- กำหนดนโยบาย Content Security Policy (CSP) อย่างเข้มงวด
|
|
156
|
-
- หลีกเลี่ยงการใช้งานบนเครือข่ายที่ไม่เชื่อถือได้หรือมีความเสี่ยง MITM
|
|
157
|
-
- อัปเดตแพตช์ความปลอดภัยของระบบปฏิบัติการและเบราว์เซอร์อย่างสม่ำเสมอ
|
|
158
|
-
- ใช้งานร่วมกับระบบป้องกันและเฝ้าระวังความปลอดภัยของอุปกรณ์ปลายทาง
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## License
|
|
163
|
-
|
|
164
|
-
ISC
|
|
1
|
+
# js_lis (SOSK - Secure On-Screen Keyboard)
|
|
2
|
+
|
|
3
|
+
**js_lis** is a high-security JavaScript on-screen keyboard (SOSK) designed to mitigate the risk of keystroke interception. Unlike traditional virtual keyboards, it employs multi-layered security protocols to protect sensitive data from keyloggers, clipboard sniffers, and man-in-the-browser (MITB) attacks.
|
|
4
|
+
|
|
5
|
+
NPM package: [https://www.npmjs.com/package/js_lis](https://www.npmjs.com/package/js_lis)
|
|
6
|
+
Web Test Login + SOSK: [https://sosk-login-js-six.vercel.app](https://sosk-login-js-six.vercel.app)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## English
|
|
11
|
+
|
|
12
|
+
### Overview
|
|
13
|
+
|
|
14
|
+
`js_lis` provides a secure input interface that isolates user interactions from the host page. It is engineered for scenarios where standard hardware input is too risky, such as financial transactions, credential entry, or private communication.
|
|
15
|
+
|
|
16
|
+
### Advanced Security Architecture
|
|
17
|
+
|
|
18
|
+
1. **AES-GCM Memory Encryption**:
|
|
19
|
+
* **SecureBufferStore**: Uses a `WeakMap` to store encrypted buffers associated with input elements. This ensures that even if an attacker leaks the object, the data remains protected.
|
|
20
|
+
* **Cryptographic Strength**: Employs **AES-256-GCM** via the Web Crypto API. Each buffer is encrypted with a unique IV (Initialization Vector) generated per write operation.
|
|
21
|
+
* **Automatic Fallback**: Gracefully degrades to a non-encrypted buffer in insecure (HTTP) environments where the Web Crypto API is unavailable.
|
|
22
|
+
|
|
23
|
+
2. **Shadow DOM Isolation**:
|
|
24
|
+
* The keyboard UI is rendered within a **`closed` Shadow DOM**.
|
|
25
|
+
* **Isolation**: This prevents the host page's CSS from altering the keyboard appearance (anti-clickjacking) and blocks third-party JavaScript from inspecting the keyboard's internal DOM structure.
|
|
26
|
+
|
|
27
|
+
3. **IME Reconciliation Engine**:
|
|
28
|
+
* Natively handles Input Method Editors (IME) for languages like Thai, Chinese, or Japanese.
|
|
29
|
+
* **Sync Logic**: intercepts `compositionstart`, `compositionupdate`, and `compositionend` events to synchronize complex multi-character inputs with the encrypted secure buffer without exposing intermediate states.
|
|
30
|
+
|
|
31
|
+
4. **Anti-Clipboard Sniffing & Secure Paste**:
|
|
32
|
+
* **Event Blocking**: Intercepts and blocks unauthorized `copy` and `cut` events when the virtual keyboard is active.
|
|
33
|
+
* **Command Sanitization**: Monkey-patches `document.execCommand` to disable clipboard operations programmatically.
|
|
34
|
+
* **Secure Paste**: Implements an explicit `securePaste()` method using the `navigator.clipboard` API to ensure data only enters the secure buffer when intended.
|
|
35
|
+
|
|
36
|
+
5. **Physical Keyboard Synchronization**:
|
|
37
|
+
* Captures hardware `keydown` and `input` events to keep the secure buffer updated in real-time, even when a user switches between virtual and physical input.
|
|
38
|
+
|
|
39
|
+
### Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install js_lis
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Technical Integration
|
|
46
|
+
|
|
47
|
+
The recommended implementation uses a singleton pattern to manage the keyboard instance across your application.
|
|
48
|
+
|
|
49
|
+
#### DOM Requirements
|
|
50
|
+
- `keyboard-container`: The target div where the keyboard will be injected.
|
|
51
|
+
- `toggle` (Optional): A button to show/hide the keyboard.
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<input id="login-input" type="password" placeholder="Enter Password" />
|
|
55
|
+
<div id="keyboard-container"></div>
|
|
56
|
+
<button id="toggle">Toggle Keyboard</button>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### Initialization
|
|
60
|
+
```javascript
|
|
61
|
+
import { getKeyboard } from "js_lis/main.js";
|
|
62
|
+
|
|
63
|
+
// Get the existing singleton instance
|
|
64
|
+
const keyboard = getKeyboard();
|
|
65
|
+
|
|
66
|
+
// The keyboard automatically monitors all INPUT and TEXTAREA elements.
|
|
67
|
+
// To manually focus an element and start secure buffer tracking:
|
|
68
|
+
const input = document.getElementById("login-input");
|
|
69
|
+
keyboard.setCurrentInput(input);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Supported Layouts
|
|
73
|
+
- **Full**: QWERTY + Numpad + Symbols.
|
|
74
|
+
- **English/Thai**: Standard localized layouts.
|
|
75
|
+
- **Numpad**: Numeric entry only.
|
|
76
|
+
- **Symbols**: Special characters.
|
|
77
|
+
- **Dynamic Scramble**: Optional randomization of key positions to thwart coordinate tracking.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## ภาษาไทย (Technical Overview)
|
|
82
|
+
|
|
83
|
+
### ภาพรวม
|
|
84
|
+
`js_lis` คือระบบคีย์บอร์ดเสมือนที่มีความปลอดภัยสูง (Secure On-Screen Keyboard - SOSK) ออกแบบมาเพื่อป้องกันการดักจับข้อมูลการพิมพ์ (Keystroke Interception) โดยใช้เทคโนโลยีการป้องกันหลายชั้นเพื่อความปลอดภัยสูงสุดในระดับ Memory และ DOM Level
|
|
85
|
+
|
|
86
|
+
### สถาปัตยกรรมด้านความปลอดภัยขั้นสูง
|
|
87
|
+
|
|
88
|
+
1. **การเข้ารหัสหน่วยความจำระดับ AES-GCM**:
|
|
89
|
+
* **SecureBufferStore**: ใช้ `WeakMap` ในการเก็บข้อมูลจำลอง (Buffer) ที่ถูกเข้ารหัสแยกตาม Input Element เพื่อป้องกันการรั่วไหลของข้อมูลหาก Object ถูกเข้าถึงโดยไม่ได้รับอนุญาต
|
|
90
|
+
* **มาตรฐานการเข้ารหัส**: ใช้ **AES-256-GCM** ผ่าน Web Crypto API โดยทุกการอัปเดตข้อมูลจะมีการสร้าง IV (Initialization Vector) ใหม่เสมอ
|
|
91
|
+
* **ระบบสำรอง (Fallback)**: หากใช้งานผ่านโปรโตคอล HTTP (ซึ่งไม่มี SubtleCrypto) ระบบจะเปลี่ยนมาใช้การเก็บข้อมูลแบบ Plaintext โดยอัตโนมัติ
|
|
92
|
+
|
|
93
|
+
2. **การแยกส่วนด้วย Shadow DOM (Closed Mode)**:
|
|
94
|
+
* หน้าจอคีย์บอร์ดจะถูกสร้างขึ้นภายใน **Closed Shadow DOM**
|
|
95
|
+
* **การแยกส่วน (Isolation)**: ป้องกันไม่ให้ CSS จากภายนอกเข้ามาแก้ไขหน้าตาคีย์บอร์ด (ป้องกัน Clickjacking) และป้องกันไม่ให้ JavaScript จากภายนอกสามารถอ่านโครงสร้างปุ่มภายในได้
|
|
96
|
+
|
|
97
|
+
3. **ระบบประสานงาน IME (IME Reconciliation Engine)**:
|
|
98
|
+
* รองรับการพิมพ์ภาษาไทยและภาษาอื่นๆ ที่ต้องใช้การประสมคำ (Composition) ได้อย่างสมบูรณ์
|
|
99
|
+
* **การซิงโครไนซ์**: ดักจับ Event `compositionstart/update/end` เพื่อนำข้อมูลมาประมวลผลร่วมกับ Secure Buffer โดยที่ข้อมูลล่าสุดจะถูกเข้ารหัสทันทีที่จบการประสมคำ
|
|
100
|
+
|
|
101
|
+
4. **การป้องกันคลิปบอร์ดและการวางข้อมูลอย่างปลอดภัย (Anti-Clipboard)**:
|
|
102
|
+
* **การบล็อกเหตุการณ์**: บล็อกคำสั่ง `copy` และ `cut` เมื่อมีการใช้งานคีย์บอร์ดเสมือน
|
|
103
|
+
* **การป้องกันโปรแกรมมิ่ง**: ทำการ Override `document.execCommand` เพื่อปิดการทำงานที่เกี่ยวกับคลิปบอร์ดผ่านสคริปต์
|
|
104
|
+
* **Secure Paste**: รองรับการวางข้อมูลผ่าน `navigator.clipboard` API โดยเฉพาะเพื่อให้มั่นใจว่าข้อมูลจะถูกส่งเข้าสู่ Secure Buffer โดยตรง
|
|
105
|
+
|
|
106
|
+
5. **การซิงโครไนซ์กับคีย์บอร์ดจริง**:
|
|
107
|
+
* ติดตามเหตุการณ์ `keydown` และ `input` จากคีย์บอร์ดฮาร์ดแวร์เพื่ออัปเดตข้อมูลใน Secure Buffer ให้ตรงกันเสมอ ไม่ว่าจะพิมพ์ผ่านช่องทางใด
|
|
108
|
+
|
|
109
|
+
### การเรียกใช้งานทางเทคนิค
|
|
110
|
+
|
|
111
|
+
แนะนำให้ใช้งานในรูปแบบ Singleton เพื่อประสิทธิภาพสูงสุด
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
import { getKeyboard } from "js_lis/main.js";
|
|
115
|
+
|
|
116
|
+
// เข้าถึง Instance ที่ถูกสร้างไว้แล้ว
|
|
117
|
+
const osk = getKeyboard();
|
|
118
|
+
|
|
119
|
+
// ระบบจะคอยตรวจสอบ INPUT และ TEXTAREA บนหน้าเว็บโดยอัตโนมัติ
|
|
120
|
+
// หากต้องการกำหนดช่องรับข้อมูลที่ต้องการเริ่มต้นใช้งาน:
|
|
121
|
+
const myInput = document.getElementById("password-field");
|
|
122
|
+
osk.setCurrentInput(myInput);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### เลย์เอาต์ที่รองรับ
|
|
126
|
+
- **Full**: คีย์บอร์ดเต็มรูปแบบ (QWERTY + ตัวเลข + สัญลักษ์)
|
|
127
|
+
- **English / Thai**: คีย์บอร์ดภาษาอังกฤษและภาษาไทยมาตราฐาน
|
|
128
|
+
- **Numpad / Symbols**: เฉพาะตัวเลขหรือสัญลักษณ์พิเศษ
|
|
129
|
+
- **Dynamic Scramble**: ฟังก์ชันสลับตำแหน่งปุ่มแบบสุ่มเพื่อป้องกันการติดตามพิกัดการคลิก
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
ISC
|
package/main.js
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
import { VirtualKeyboard } from "./VirtualKeyboard.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { VirtualKeyboard } from "./VirtualKeyboard.js";
|
|
2
|
+
|
|
3
|
+
let keyboardInstance = null;
|
|
4
|
+
|
|
5
|
+
// init + singleton
|
|
6
|
+
function initKeyboard() {
|
|
7
|
+
if (keyboardInstance) return keyboardInstance;
|
|
8
|
+
|
|
9
|
+
const container = document.getElementById("keyboard-container");
|
|
10
|
+
if (!container) {
|
|
11
|
+
console.warn("Keyboard container not found");
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
keyboardInstance = new VirtualKeyboard();
|
|
16
|
+
return keyboardInstance;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// getter (ไว้ใช้จากที่อื่น ถ้าจำเป็น)
|
|
20
|
+
export function getKeyboard() {
|
|
21
|
+
return keyboardInstance;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// init ตอน DOM พร้อม
|
|
25
|
+
window.addEventListener("DOMContentLoaded", () => {
|
|
26
|
+
try {
|
|
27
|
+
initKeyboard();
|
|
28
|
+
console.log("Keyboard initialized safely");
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.error("Keyboard init error:", err);
|
|
31
|
+
}
|
|
32
|
+
});
|