titanpl 7.0.0 → 7.0.1

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 (54) hide show
  1. package/package.json +1 -1
  2. package/packages/cli/package.json +4 -4
  3. package/packages/cli/src/commands/build-ext.js +17 -4
  4. package/packages/engine-darwin-arm64/package.json +1 -1
  5. package/packages/engine-linux-x64/package.json +1 -1
  6. package/packages/engine-win32-x64/bin/titan-server.exe +0 -0
  7. package/packages/engine-win32-x64/package.json +1 -1
  8. package/packages/native/index.d.ts +27 -0
  9. package/packages/native/index.js +1 -0
  10. package/packages/native/package.json +1 -1
  11. package/packages/native/t.native.d.ts +99 -3
  12. package/packages/packet/package.json +1 -1
  13. package/packages/route/package.json +1 -1
  14. package/packages/sdk/package.json +1 -1
  15. package/templates/extension/README_WASM.md +38 -0
  16. package/templates/extension/package.json +2 -2
  17. package/templates/js/package.json +7 -7
  18. package/templates/rust-js/package.json +4 -4
  19. package/templates/rust-ts/package.json +4 -4
  20. package/templates/ts/package.json +7 -7
  21. package/packages/core-source/LICENSE +0 -15
  22. package/packages/core-source/README.md +0 -128
  23. package/packages/core-source/V8_SERIALIZATION.md +0 -125
  24. package/packages/core-source/configure.js +0 -50
  25. package/packages/core-source/globals.d.ts +0 -2238
  26. package/packages/core-source/index.d.ts +0 -515
  27. package/packages/core-source/index.js +0 -639
  28. package/packages/core-source/jsconfig.json +0 -12
  29. package/packages/core-source/mkctx.config.json +0 -7
  30. package/packages/core-source/native/Cargo.lock +0 -1559
  31. package/packages/core-source/native/Cargo.toml +0 -30
  32. package/packages/core-source/native/src/crypto_impl.rs +0 -139
  33. package/packages/core-source/native/src/lib.rs +0 -702
  34. package/packages/core-source/native/src/storage_impl.rs +0 -73
  35. package/packages/core-source/native/src/v8_impl.rs +0 -93
  36. package/packages/core-source/package-lock.json +0 -1464
  37. package/packages/core-source/package.json +0 -53
  38. package/packages/core-source/tests/buffer.test.js +0 -78
  39. package/packages/core-source/tests/cookies.test.js +0 -117
  40. package/packages/core-source/tests/crypto.test.js +0 -142
  41. package/packages/core-source/tests/fs.test.js +0 -176
  42. package/packages/core-source/tests/ls.test.js +0 -149
  43. package/packages/core-source/tests/net.test.js +0 -84
  44. package/packages/core-source/tests/os.test.js +0 -81
  45. package/packages/core-source/tests/path.test.js +0 -102
  46. package/packages/core-source/tests/response.test.js +0 -146
  47. package/packages/core-source/tests/session.test.js +0 -110
  48. package/packages/core-source/tests/setup.js +0 -325
  49. package/packages/core-source/tests/time.test.js +0 -57
  50. package/packages/core-source/tests/url.test.js +0 -82
  51. package/packages/core-source/titan-ext.d.ts +0 -2
  52. package/packages/core-source/titan.json +0 -9
  53. package/packages/core-source/vitest.config.js +0 -8
  54. package/templates/extension/README.md +0 -69
@@ -1,30 +0,0 @@
1
- [package]
2
- name = "titan-core"
3
- version = "0.1.0"
4
- edition = "2021"
5
-
6
- [lib]
7
- crate-type = ["cdylib"]
8
-
9
- [dependencies]
10
- serde = { version = "1.0", features = ["derive"] }
11
- serde_json = "1.0"
12
- uuid = { version = "1.4", features = ["v4", "fast-rng"] }
13
- sha2 = "0.10"
14
- md-5 = "0.10"
15
- base64 = "0.21"
16
- rand = "0.8"
17
- sys-info = "0.9"
18
- chrono = "0.4"
19
- dns-lookup = "2.0"
20
- local-ip-address = "0.5"
21
- whoami = "1.4"
22
- hex = "0.4"
23
- aes-gcm = "0.10"
24
- hmac = "0.12"
25
- subtle = "2.5"
26
- regex = "1"
27
- parking_lot = "0.12"
28
- sysinfo = "0.30"
29
- v8 = "0.106.0"
30
-
@@ -1,139 +0,0 @@
1
- use aes_gcm::{
2
- aead::{Aead, KeyInit},
3
- Aes256Gcm, Nonce,
4
- };
5
- use hmac::{Hmac, Mac};
6
- use sha2::{Sha256, Sha512};
7
- use sha2::Digest;
8
- use subtle::ConstantTimeEq;
9
- use base64::{Engine as _, engine::general_purpose};
10
- use std::str;
11
-
12
- // Helper to decode key or use as is
13
- fn prepare_key(key: &str, expected_len: usize) -> Result<Vec<u8>, String> {
14
- // Try user string as bytes
15
- let bytes = key.as_bytes();
16
- if bytes.len() == expected_len {
17
- return Ok(bytes.to_vec());
18
- }
19
- // If not, maybe it is hex?
20
- if let Ok(decoded) = hex::decode(key) {
21
- if decoded.len() == expected_len {
22
- return Ok(decoded);
23
- }
24
- }
25
- // If not, maybe base64?
26
- if let Ok(decoded) = general_purpose::STANDARD.decode(key) {
27
- if decoded.len() == expected_len {
28
- return Ok(decoded);
29
- }
30
- }
31
- Err(format!("Invalid key length. Expected {} bytes.", expected_len))
32
- }
33
-
34
- /// Encrypts plaintext using AES-256-GCM.
35
- /// Returns Base64 encoded string containing nonce + ciphertext.
36
- pub fn encrypt(algo: &str, key: &str, plaintext: &str) -> Result<String, String> {
37
- match algo {
38
- "aes-256-gcm" | "aes256" => {
39
- let key_bytes = prepare_key(key, 32)?;
40
- let cipher = Aes256Gcm::new_from_slice(&key_bytes).map_err(|e| e.to_string())?;
41
- // Generate a random 96-bit nonce
42
- let mut nonce_bytes = [0u8; 12];
43
- rand::Rng::fill(&mut rand::thread_rng(), &mut nonce_bytes);
44
- let nonce = Nonce::from_slice(&nonce_bytes);
45
-
46
- let ciphertext = cipher.encrypt(nonce, plaintext.as_bytes())
47
- .map_err(|_| "Encryption failed".to_string())?;
48
-
49
- // Return format: nonce + ciphertext (base64)
50
- let mut combined = nonce_bytes.to_vec();
51
- combined.extend(ciphertext);
52
- Ok(general_purpose::STANDARD.encode(&combined))
53
- },
54
- _ => Err(format!("Unsupported algorithm: {}", algo))
55
- }
56
- }
57
-
58
- /// Decrypts a Base64 encoded string (nonce + ciphertext) using AES-256-GCM.
59
- pub fn decrypt(algo: &str, key: &str, ciphertext: &str) -> Result<Vec<u8>, String> {
60
- match algo {
61
- "aes-256-gcm" | "aes256" => {
62
- let key_bytes = prepare_key(key, 32)?;
63
- let cipher = Aes256Gcm::new_from_slice(&key_bytes).map_err(|e| e.to_string())?;
64
-
65
- let data = general_purpose::STANDARD.decode(ciphertext)
66
- .map_err(|_| "Invalid Base64 ciphertext".to_string())?;
67
-
68
- if data.len() < 12 {
69
- return Err("DECRYPTION_FAILED: Invalid ciphertext length".to_string());
70
- }
71
-
72
- let (nonce_bytes, ciphertext_bytes) = data.split_at(12);
73
- let nonce = Nonce::from_slice(nonce_bytes);
74
-
75
- let plaintext_bytes = cipher.decrypt(nonce, ciphertext_bytes)
76
- .map_err(|_| "DECRYPTION_FAILED".to_string())?;
77
-
78
- Ok(plaintext_bytes)
79
- },
80
- _ => Err(format!("Unsupported algorithm: {}", algo))
81
- }
82
- }
83
-
84
- pub fn hash_keyed(algo: &str, key: &str, message: &str) -> Result<String, String> {
85
- match algo {
86
- "sha256" => {
87
- type HmacSha256 = Hmac<Sha256>;
88
- let mut mac = <HmacSha256 as Mac>::new_from_slice(key.as_bytes())
89
- .map_err(|_| "Invalid key length".to_string())?;
90
- mac.update(message.as_bytes());
91
- let result = mac.finalize();
92
- Ok(hex::encode(result.into_bytes()))
93
- },
94
- "sha512" => {
95
- type HmacSha512 = Hmac<Sha512>;
96
- let mut mac = <HmacSha512 as Mac>::new_from_slice(key.as_bytes())
97
- .map_err(|_| "Invalid key length".to_string())?;
98
- mac.update(message.as_bytes());
99
- let result = mac.finalize();
100
- Ok(hex::encode(result.into_bytes()))
101
- },
102
- _ => Err(format!("Unsupported algorithm: {}", algo))
103
- }
104
- }
105
-
106
-
107
- pub fn compare(a: &str, b: &str) -> bool {
108
- let a_bytes = a.as_bytes();
109
- let b_bytes = b.as_bytes();
110
- if a_bytes.len() != b_bytes.len() {
111
- return false;
112
- }
113
- a_bytes.ct_eq(b_bytes).into()
114
- }
115
-
116
- pub fn hash(algo: &str, data: &str) -> String {
117
- match algo {
118
- "sha512" => {
119
- use sha2::Digest;
120
- let mut h = Sha512::new();
121
- h.update(data.as_bytes());
122
- hex::encode(h.finalize())
123
- },
124
- _ => {
125
- // Default: sha256
126
- use sha2::Digest;
127
- let mut h = Sha256::new();
128
- h.update(data.as_bytes());
129
- hex::encode(h.finalize())
130
- }
131
- }
132
- }
133
-
134
- pub fn random_bytes(size: usize) -> String {
135
- use rand::RngCore;
136
- let mut bytes = vec![0u8; size];
137
- rand::thread_rng().fill_bytes(&mut bytes);
138
- general_purpose::STANDARD.encode(&bytes)
139
- }