js_lis 1.0.12 → 1.0.14

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.
Files changed (2) hide show
  1. package/VirtualKeyboard.js +15 -11
  2. package/package.json +1 -1
@@ -16,12 +16,10 @@ export class VirtualKeyboard {
16
16
  // ใช้ Web Crypto API สำหรับการจัดการคีย์
17
17
  this.cryptoKey = null;
18
18
  this.iv = window.crypto.getRandomValues(new Uint8Array(12)); // สร้าง IV สำหรับการเข้ารหัส/ถอดรหัส
19
- this.generateKey();
20
-
21
- this.render();
19
+
22
20
  this.initialize();
23
21
  }
24
-
22
+
25
23
  async initialize() {
26
24
  try {
27
25
  await this.generateKey();
@@ -33,13 +31,19 @@ export class VirtualKeyboard {
33
31
  }
34
32
  }
35
33
 
36
- async generateKey() {
37
- this.cryptoKey = await window.crypto.subtle.generateKey(
38
- { name: "AES-GCM", length: 256 },
39
- true,
40
- ["encrypt", "decrypt"]
41
- );
42
- }
34
+ async generateKey() {
35
+ try {
36
+ this.cryptoKey = await window.crypto.subtle.generateKey(
37
+ { name: "AES-GCM", length: 256 },
38
+ true,
39
+ ["encrypt", "decrypt"]
40
+ );
41
+ } catch (error) {
42
+ console.error("Error generating key:", error);
43
+ throw error;
44
+ // rethrow the error to be caught in initialize
45
+ }
46
+ }
43
47
 
44
48
  async encodeText(text) {
45
49
  const encodedData = new TextEncoder().encode(text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js_lis",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"