universe-code 0.0.91 → 0.0.93
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.
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
class EncryptionService {
|
|
2
|
-
constructor() {
|
|
3
|
-
|
|
4
|
-
"
|
|
1
|
+
export class EncryptionService {
|
|
2
|
+
constructor(pass) {
|
|
3
|
+
if (!pass) {
|
|
4
|
+
throw new Error("Encryption PASS is required");
|
|
5
|
+
}
|
|
6
|
+
this.PASS = pass;
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
// --- Encoding helpers ---
|
|
@@ -142,7 +144,4 @@ class EncryptionService {
|
|
|
142
144
|
const [iv, payload] = data.split("###");
|
|
143
145
|
return this.decryption1({ iv, payload });
|
|
144
146
|
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Export / usage
|
|
148
|
-
export const encryptionService = new EncryptionService();
|
|
147
|
+
}
|
package/dist/angular/index.js
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/* ---------- INTERNAL STATE ---------- */
|
|
2
|
+
let SECRET_PASS = null;
|
|
3
|
+
let PASS = null;
|
|
4
|
+
|
|
5
|
+
/* ---------- INIT FUNCTION ---------- */
|
|
6
|
+
export function initEncryptionService(secret) {
|
|
7
|
+
if (!secret || typeof secret !== "string") {
|
|
8
|
+
throw new Error("SECRET_PASS is required to initialize encryption service");
|
|
9
|
+
}
|
|
10
|
+
SECRET_PASS = secret;
|
|
11
|
+
PASS = secret;
|
|
12
|
+
}
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
/* ---------- SAFETY CHECK ---------- */
|
|
15
|
+
function ensureInit() {
|
|
16
|
+
if (!SECRET_PASS) {
|
|
17
|
+
throw new Error("Crypto service not initialized. Call initEncryptionService()");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
8
20
|
|
|
9
|
-
/* ----------
|
|
21
|
+
/* ---------- HELPERS ---------- */
|
|
10
22
|
|
|
11
23
|
const enc = (str) => new TextEncoder().encode(str);
|
|
12
24
|
const dec = (buf) => new TextDecoder().decode(buf);
|
|
13
25
|
|
|
14
26
|
const hasBuffer = typeof Buffer !== "undefined";
|
|
15
27
|
|
|
16
|
-
/* Base64 encode (Node + Browser
|
|
28
|
+
/* Base64 encode (Node + Browser) */
|
|
17
29
|
const b64 = (data) => {
|
|
18
30
|
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
19
31
|
|
|
@@ -28,7 +40,7 @@ const b64 = (data) => {
|
|
|
28
40
|
return btoa(binary);
|
|
29
41
|
};
|
|
30
42
|
|
|
31
|
-
/* Base64 decode (Node + Browser
|
|
43
|
+
/* Base64 decode (Node + Browser) */
|
|
32
44
|
const ub64 = (base64) => {
|
|
33
45
|
if (hasBuffer) {
|
|
34
46
|
return new Uint8Array(Buffer.from(base64, "base64"));
|
|
@@ -42,31 +54,30 @@ const ub64 = (base64) => {
|
|
|
42
54
|
return bytes;
|
|
43
55
|
};
|
|
44
56
|
|
|
45
|
-
/* WebCrypto subtle (Browser + Node
|
|
57
|
+
/* WebCrypto subtle (Browser + Node + Next SSR) */
|
|
46
58
|
const subtle = () => {
|
|
47
59
|
if (typeof window !== "undefined" && window.crypto?.subtle) {
|
|
48
60
|
return window.crypto.subtle;
|
|
49
61
|
}
|
|
50
|
-
|
|
51
62
|
if (globalThis.crypto?.subtle) {
|
|
52
63
|
return globalThis.crypto.subtle;
|
|
53
64
|
}
|
|
54
|
-
|
|
55
|
-
throw new Error("WebCrypto API not supported in this environment");
|
|
65
|
+
throw new Error("WebCrypto API not supported");
|
|
56
66
|
};
|
|
57
67
|
|
|
58
|
-
/* Random
|
|
68
|
+
/* Random IV (Browser + Node) */
|
|
59
69
|
const randomIV = () => {
|
|
60
70
|
if (typeof window !== "undefined" && window.crypto) {
|
|
61
71
|
return window.crypto.getRandomValues(new Uint8Array(12));
|
|
62
72
|
}
|
|
63
|
-
|
|
64
73
|
return globalThis.crypto.getRandomValues(new Uint8Array(12));
|
|
65
74
|
};
|
|
66
75
|
|
|
67
|
-
/* ----------
|
|
76
|
+
/* ---------- KEY DERIVATION ---------- */
|
|
68
77
|
|
|
69
78
|
async function getKey() {
|
|
79
|
+
ensureInit();
|
|
80
|
+
|
|
70
81
|
const keyMaterial = await subtle().importKey(
|
|
71
82
|
"raw",
|
|
72
83
|
enc(SECRET_PASS),
|
|
@@ -90,6 +101,8 @@ async function getKey() {
|
|
|
90
101
|
}
|
|
91
102
|
|
|
92
103
|
async function key1() {
|
|
104
|
+
ensureInit();
|
|
105
|
+
|
|
93
106
|
const keyMaterial = await subtle().importKey(
|
|
94
107
|
"raw",
|
|
95
108
|
enc(PASS),
|
|
@@ -112,11 +125,13 @@ async function key1() {
|
|
|
112
125
|
);
|
|
113
126
|
}
|
|
114
127
|
|
|
115
|
-
/* ----------
|
|
128
|
+
/* ---------- CRYPTO SERVICE ---------- */
|
|
116
129
|
|
|
117
130
|
export const encryptionService = {
|
|
118
|
-
/* Encrypt
|
|
131
|
+
/* Encrypt (main key) */
|
|
119
132
|
async encryption(obj) {
|
|
133
|
+
ensureInit();
|
|
134
|
+
|
|
120
135
|
const iv = randomIV();
|
|
121
136
|
const key = await getKey();
|
|
122
137
|
|
|
@@ -132,8 +147,10 @@ export const encryptionService = {
|
|
|
132
147
|
};
|
|
133
148
|
},
|
|
134
149
|
|
|
135
|
-
/* Decrypt
|
|
150
|
+
/* Decrypt (main key) */
|
|
136
151
|
async decryption(data) {
|
|
152
|
+
ensureInit();
|
|
153
|
+
|
|
137
154
|
const key = await getKey();
|
|
138
155
|
|
|
139
156
|
const decrypted = await subtle().decrypt(
|
|
@@ -145,8 +162,10 @@ export const encryptionService = {
|
|
|
145
162
|
return JSON.parse(dec(decrypted));
|
|
146
163
|
},
|
|
147
164
|
|
|
148
|
-
/* Encrypt
|
|
165
|
+
/* Encrypt (secondary key) */
|
|
149
166
|
async encryption1(obj) {
|
|
167
|
+
ensureInit();
|
|
168
|
+
|
|
150
169
|
const iv = randomIV();
|
|
151
170
|
const key = await key1();
|
|
152
171
|
|
|
@@ -162,8 +181,10 @@ export const encryptionService = {
|
|
|
162
181
|
};
|
|
163
182
|
},
|
|
164
183
|
|
|
165
|
-
/* Decrypt
|
|
184
|
+
/* Decrypt (secondary key) */
|
|
166
185
|
async decryption1(data) {
|
|
186
|
+
ensureInit();
|
|
187
|
+
|
|
167
188
|
const key = await key1();
|
|
168
189
|
|
|
169
190
|
const decrypted = await subtle().decrypt(
|
|
@@ -177,6 +198,8 @@ export const encryptionService = {
|
|
|
177
198
|
|
|
178
199
|
/* API helper */
|
|
179
200
|
async decryptApiResponse(data) {
|
|
201
|
+
ensureInit();
|
|
202
|
+
|
|
180
203
|
if (!data || !data.includes("###")) return null;
|
|
181
204
|
const [iv, payload] = data.split("###");
|
|
182
205
|
return this.decryption1({ iv, payload });
|
package/dist/react/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import { getIdbStore } from './indexdb/store/idbStore.js';
|
|
|
2
2
|
import { useIdbStore } from './indexdb/hooks/idbHook.js';
|
|
3
3
|
import { configureIdb } from "./indexdb/store/config.js";
|
|
4
4
|
import { useColorSpark } from "./spark/index.js";
|
|
5
|
-
import { encryptionService } from "./encryption/index.js";
|
|
5
|
+
import { encryptionService, initEncryptionService } from "./encryption/index.js";
|
|
6
6
|
|
|
7
7
|
// Export everything as a unified object or individual pieces
|
|
8
|
-
export { configureIdb, getIdbStore, useIdbStore, useColorSpark, encryptionService };
|
|
8
|
+
export { configureIdb, getIdbStore, useIdbStore, useColorSpark, encryptionService, initEncryptionService };
|
|
9
9
|
|
|
10
10
|
// Default export for easy usage
|
|
11
11
|
export default {
|
|
@@ -13,5 +13,6 @@ export default {
|
|
|
13
13
|
getIdbStore,
|
|
14
14
|
useIdbStore,
|
|
15
15
|
useColorSpark,
|
|
16
|
-
encryptionService
|
|
16
|
+
encryptionService,
|
|
17
|
+
initEncryptionService
|
|
17
18
|
};
|
package/dist/uiux/table/index.js
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
class UniverseDataTable {
|
|
2
|
+
constructor({
|
|
3
|
+
container,
|
|
4
|
+
apiData = [],
|
|
5
|
+
columns = [],
|
|
6
|
+
pagination = {},
|
|
7
|
+
jumpToPage = "",
|
|
8
|
+
shouldEnableJumpToPage = false,
|
|
9
|
+
handleJumpToPage = () => { },
|
|
10
|
+
handleKeyPress = () => { },
|
|
11
|
+
handlePageChange = () => { },
|
|
12
|
+
shouldShowPagination = true,
|
|
13
|
+
}) {
|
|
14
|
+
if (!container) throw new Error("UniverseDataTable: container is required");
|
|
15
|
+
if (typeof document !== "undefined") {
|
|
16
|
+
this.injectStyles();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
this.container = container;
|
|
20
|
+
this.apiData = apiData;
|
|
21
|
+
this.columns = columns;
|
|
22
|
+
this.pagination = pagination;
|
|
23
|
+
|
|
24
|
+
this.jumpToPage = jumpToPage;
|
|
25
|
+
this.shouldEnableJumpToPage = shouldEnableJumpToPage;
|
|
26
|
+
this.handleJumpToPage = handleJumpToPage;
|
|
27
|
+
this.handleKeyPress = handleKeyPress;
|
|
28
|
+
this.handlePageChange = handlePageChange;
|
|
29
|
+
|
|
30
|
+
this.shouldShowPagination = shouldShowPagination;
|
|
31
|
+
|
|
32
|
+
this.render();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
injectStyles() {
|
|
36
|
+
if (document.getElementById("udt-style")) return;
|
|
37
|
+
|
|
38
|
+
const style = document.createElement("style");
|
|
39
|
+
style.id = "udt-style";
|
|
40
|
+
style.textContent = `
|
|
4
41
|
/* Container & Table */
|
|
5
42
|
.udt-container {
|
|
6
43
|
background-color: #fff;
|
|
@@ -179,39 +216,8 @@ style.textContent = `
|
|
|
179
216
|
}
|
|
180
217
|
}
|
|
181
218
|
`;
|
|
182
|
-
document.head.appendChild(style);
|
|
183
|
-
|
|
184
|
-
// UniverseDataTable Class
|
|
185
|
-
class UniverseDataTable {
|
|
186
|
-
constructor({
|
|
187
|
-
container,
|
|
188
|
-
apiData = [],
|
|
189
|
-
columns = [],
|
|
190
|
-
pagination = {},
|
|
191
|
-
jumpToPage = "",
|
|
192
|
-
shouldEnableJumpToPage = false,
|
|
193
|
-
handleJumpToPage = () => { },
|
|
194
|
-
handleKeyPress = () => { },
|
|
195
|
-
handlePageChange = () => { },
|
|
196
|
-
shouldShowPagination = true,
|
|
197
|
-
}) {
|
|
198
|
-
if (!container) throw new Error("UniverseDataTable: container is required");
|
|
199
|
-
|
|
200
|
-
this.container = container;
|
|
201
|
-
this.apiData = apiData;
|
|
202
|
-
this.columns = columns;
|
|
203
|
-
this.pagination = pagination;
|
|
204
|
-
|
|
205
|
-
this.jumpToPage = jumpToPage;
|
|
206
|
-
this.shouldEnableJumpToPage = shouldEnableJumpToPage;
|
|
207
|
-
this.handleJumpToPage = handleJumpToPage;
|
|
208
|
-
this.handleKeyPress = handleKeyPress;
|
|
209
|
-
this.handlePageChange = handlePageChange;
|
|
210
|
-
|
|
211
|
-
this.shouldShowPagination = shouldShowPagination;
|
|
212
|
-
|
|
213
|
-
this.render();
|
|
214
|
-
}
|
|
219
|
+
document.head.appendChild(style);
|
|
220
|
+
}
|
|
215
221
|
|
|
216
222
|
th(label) {
|
|
217
223
|
return `<th class="udt-th">${label}</th>`;
|