@juv/codego-react-ui 3.1.2 → 3.1.5
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/dist/index.cjs +27 -20
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.global.js +27 -20
- package/dist/index.js +27 -19
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2131,13 +2131,19 @@ var import_react_dom = require("react-dom");
|
|
|
2131
2131
|
|
|
2132
2132
|
// src/components/tools/decryptPayload.ts
|
|
2133
2133
|
var import_crypto_js = __toESM(require("crypto-js"), 1);
|
|
2134
|
-
var import_meta = {};
|
|
2135
2134
|
function getLaravelSecretKey() {
|
|
2136
|
-
const viteKey =
|
|
2135
|
+
const viteKey = (() => {
|
|
2136
|
+
try {
|
|
2137
|
+
return new Function("return import.meta.env")();
|
|
2138
|
+
} catch {
|
|
2139
|
+
return void 0;
|
|
2140
|
+
}
|
|
2141
|
+
})()?.VITE_LARAVEL_KEY;
|
|
2137
2142
|
const legacyKey = globalThis?.process?.env?.REACT_APP_LARAVEL_KEY;
|
|
2138
|
-
const
|
|
2143
|
+
const windowKey = globalThis?.__LARAVEL_KEY__;
|
|
2144
|
+
const key = viteKey || legacyKey || windowKey;
|
|
2139
2145
|
if (!key) {
|
|
2140
|
-
throw new Error("Missing Laravel decryption key. Set VITE_LARAVEL_KEY in your .env.");
|
|
2146
|
+
throw new Error("Missing Laravel decryption key. Set VITE_LARAVEL_KEY in your .env or inject window.__LARAVEL_KEY__ via Blade.");
|
|
2141
2147
|
}
|
|
2142
2148
|
return key;
|
|
2143
2149
|
}
|
|
@@ -2155,13 +2161,13 @@ function parseLaravelEncryptedPayload(payload) {
|
|
|
2155
2161
|
}
|
|
2156
2162
|
return JSON.parse(jsonStr);
|
|
2157
2163
|
}
|
|
2158
|
-
function decryptLaravelPayload(payload) {
|
|
2159
|
-
const
|
|
2164
|
+
function decryptLaravelPayload(payload, secretKey) {
|
|
2165
|
+
const resolvedKey = secretKey ?? getLaravelSecretKey();
|
|
2160
2166
|
const parsed = parseLaravelEncryptedPayload(payload);
|
|
2161
2167
|
if (parsed.tag) {
|
|
2162
2168
|
throw new Error("Unsupported Laravel cipher (AEAD tag present). Expected AES-*-CBC payload.");
|
|
2163
2169
|
}
|
|
2164
|
-
const key = parseLaravelKey(
|
|
2170
|
+
const key = parseLaravelKey(resolvedKey);
|
|
2165
2171
|
const expectedMac = import_crypto_js.default.HmacSHA256(parsed.iv + parsed.value, key).toString();
|
|
2166
2172
|
if (expectedMac !== parsed.mac) {
|
|
2167
2173
|
throw new Error("Invalid payload MAC (wrong key or tampered payload).");
|
|
@@ -2178,7 +2184,6 @@ function decryptLaravelPayload(payload) {
|
|
|
2178
2184
|
if (!plaintext) {
|
|
2179
2185
|
throw new Error("Decryption produced empty plaintext (wrong key/cipher).");
|
|
2180
2186
|
}
|
|
2181
|
-
console.log("Decrypted payload:", plaintext);
|
|
2182
2187
|
return JSON.parse(plaintext);
|
|
2183
2188
|
}
|
|
2184
2189
|
|
|
@@ -4899,7 +4904,7 @@ Input.displayName = "Input";
|
|
|
4899
4904
|
|
|
4900
4905
|
// src/components/ui/data-grid.tsx
|
|
4901
4906
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
4902
|
-
function useServerDataGrid({ url, params, encrypt }) {
|
|
4907
|
+
function useServerDataGrid({ url, params, encrypt, key, decryptPayloadLog }) {
|
|
4903
4908
|
const [data, setData] = React24.useState([]);
|
|
4904
4909
|
const [columns, setColumns] = React24.useState([]);
|
|
4905
4910
|
const [currentPage, setCurrentPage] = React24.useState(1);
|
|
@@ -4913,7 +4918,8 @@ function useServerDataGrid({ url, params, encrypt }) {
|
|
|
4913
4918
|
setError(null);
|
|
4914
4919
|
import_axios.default.get(url, { params: { ...params, page: currentPage } }).then(({ data: res }) => {
|
|
4915
4920
|
if (cancelled) return;
|
|
4916
|
-
const payload = encrypt ? decryptLaravelPayload(res) : res;
|
|
4921
|
+
const payload = encrypt ? decryptLaravelPayload(res, key) : res;
|
|
4922
|
+
if (encrypt && decryptPayloadLog) console.log("[useServerDataGrid] decrypted payload:", payload);
|
|
4917
4923
|
setData(payload.data);
|
|
4918
4924
|
const rawTotal = payload.total;
|
|
4919
4925
|
const rawPerPage = payload.per_page;
|
|
@@ -4932,9 +4938,9 @@ function useServerDataGrid({ url, params, encrypt }) {
|
|
|
4932
4938
|
setPagination(pg);
|
|
4933
4939
|
if (payload.data.length > 0) {
|
|
4934
4940
|
setColumns(
|
|
4935
|
-
Object.keys(payload.data[0]).map((
|
|
4936
|
-
key,
|
|
4937
|
-
header:
|
|
4941
|
+
Object.keys(payload.data[0]).map((key2) => ({
|
|
4942
|
+
key: key2,
|
|
4943
|
+
header: key2.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase())
|
|
4938
4944
|
}))
|
|
4939
4945
|
);
|
|
4940
4946
|
}
|
|
@@ -4947,7 +4953,7 @@ function useServerDataGrid({ url, params, encrypt }) {
|
|
|
4947
4953
|
return () => {
|
|
4948
4954
|
cancelled = true;
|
|
4949
4955
|
};
|
|
4950
|
-
}, [url, currentPage, tick, JSON.stringify(params)]);
|
|
4956
|
+
}, [url, currentPage, tick, JSON.stringify(params), encrypt, decryptPayloadLog]);
|
|
4951
4957
|
return {
|
|
4952
4958
|
data,
|
|
4953
4959
|
columns,
|
|
@@ -9563,7 +9569,7 @@ var import_react_dom2 = require("react-dom");
|
|
|
9563
9569
|
var import_axios2 = __toESM(require("axios"), 1);
|
|
9564
9570
|
var import_lucide_react28 = require("lucide-react");
|
|
9565
9571
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
9566
|
-
function useServerTable({ url, params, encrypt }) {
|
|
9572
|
+
function useServerTable({ url, params, encrypt, key, decryptPayloadLog }) {
|
|
9567
9573
|
const [data, setData] = React44.useState([]);
|
|
9568
9574
|
const [columns, setColumns] = React44.useState([]);
|
|
9569
9575
|
const [currentPage, setCurrentPage] = React44.useState(1);
|
|
@@ -9579,7 +9585,8 @@ function useServerTable({ url, params, encrypt }) {
|
|
|
9579
9585
|
params: { ...params, page: currentPage }
|
|
9580
9586
|
}).then(({ data: res }) => {
|
|
9581
9587
|
if (cancelled) return;
|
|
9582
|
-
const payload = encrypt ? decryptLaravelPayload(res) : res;
|
|
9588
|
+
const payload = encrypt ? decryptLaravelPayload(res, key) : res;
|
|
9589
|
+
if (encrypt && decryptPayloadLog) console.log("[useServerTable] decrypted payload:", payload);
|
|
9583
9590
|
setData(payload.data);
|
|
9584
9591
|
const rawTotal = payload.total;
|
|
9585
9592
|
const rawPerPage = payload.per_page;
|
|
@@ -9598,9 +9605,9 @@ function useServerTable({ url, params, encrypt }) {
|
|
|
9598
9605
|
setPagination(pg);
|
|
9599
9606
|
if (payload.data.length > 0) {
|
|
9600
9607
|
setColumns(
|
|
9601
|
-
Object.keys(payload.data[0]).map((
|
|
9602
|
-
key,
|
|
9603
|
-
title:
|
|
9608
|
+
Object.keys(payload.data[0]).map((key2) => ({
|
|
9609
|
+
key: key2,
|
|
9610
|
+
title: key2.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase())
|
|
9604
9611
|
}))
|
|
9605
9612
|
);
|
|
9606
9613
|
}
|
|
@@ -9613,7 +9620,7 @@ function useServerTable({ url, params, encrypt }) {
|
|
|
9613
9620
|
return () => {
|
|
9614
9621
|
cancelled = true;
|
|
9615
9622
|
};
|
|
9616
|
-
}, [url, currentPage, tick, JSON.stringify(params)]);
|
|
9623
|
+
}, [url, currentPage, tick, JSON.stringify(params), encrypt, decryptPayloadLog]);
|
|
9617
9624
|
return {
|
|
9618
9625
|
data,
|
|
9619
9626
|
columns,
|
package/dist/index.d.cts
CHANGED
|
@@ -361,8 +361,12 @@ interface UseServerTableOptions {
|
|
|
361
361
|
url: string;
|
|
362
362
|
/** Extra query params merged on every request */
|
|
363
363
|
params?: Record<string, string | number>;
|
|
364
|
-
/** If true, the response is expected to be a Laravel-encrypted payload
|
|
364
|
+
/** If true, the response is expected to be a Laravel-encrypted payload */
|
|
365
365
|
encrypt?: boolean;
|
|
366
|
+
/** Laravel APP_KEY used for decryption. Pass import.meta.env["VITE_LARAVEL_KEY"] */
|
|
367
|
+
key?: string;
|
|
368
|
+
/** If true, logs the decrypted payload to the console */
|
|
369
|
+
decryptPayloadLog?: boolean;
|
|
366
370
|
}
|
|
367
371
|
interface UseServerTableReturn<T> {
|
|
368
372
|
data: T[];
|
|
@@ -380,7 +384,7 @@ interface ServerPaginationProp {
|
|
|
380
384
|
currentPage: number;
|
|
381
385
|
goToPage: (page: number) => void;
|
|
382
386
|
}
|
|
383
|
-
declare function useServerTable<T extends Record<string, any>>({ url, params, encrypt }: UseServerTableOptions): UseServerTableReturn<T>;
|
|
387
|
+
declare function useServerTable<T extends Record<string, any>>({ url, params, encrypt, key, decryptPayloadLog }: UseServerTableOptions): UseServerTableReturn<T>;
|
|
384
388
|
type ActionFieldType = "input" | "password" | "textarea" | "checkbox" | "toggle" | "select" | "radio" | "slider" | "tag-input" | "otp" | "combobox" | "color-picker" | "date-range" | "rich-text" | "file-upload" | "repeater";
|
|
385
389
|
interface ActionField {
|
|
386
390
|
key: string;
|
|
@@ -467,8 +471,12 @@ interface ServerDataGridProp {
|
|
|
467
471
|
interface UseServerDataGridOptions {
|
|
468
472
|
url: string;
|
|
469
473
|
params?: Record<string, string | number>;
|
|
470
|
-
/** If true, the response is expected to be a Laravel-encrypted payload
|
|
474
|
+
/** If true, the response is expected to be a Laravel-encrypted payload */
|
|
471
475
|
encrypt?: boolean;
|
|
476
|
+
/** Laravel APP_KEY used for decryption. Pass import.meta.env["VITE_LARAVEL_KEY"] */
|
|
477
|
+
key?: string;
|
|
478
|
+
/** If true, logs the decrypted payload to the console */
|
|
479
|
+
decryptPayloadLog?: boolean;
|
|
472
480
|
}
|
|
473
481
|
interface UseServerDataGridReturn<T> {
|
|
474
482
|
data: T[];
|
|
@@ -481,7 +489,7 @@ interface UseServerDataGridReturn<T> {
|
|
|
481
489
|
goToPage: (page: number) => void;
|
|
482
490
|
reload: () => void;
|
|
483
491
|
}
|
|
484
|
-
declare function useServerDataGrid<T extends Record<string, any>>({ url, params, encrypt }: UseServerDataGridOptions): UseServerDataGridReturn<T>;
|
|
492
|
+
declare function useServerDataGrid<T extends Record<string, any>>({ url, params, encrypt, key, decryptPayloadLog }: UseServerDataGridOptions): UseServerDataGridReturn<T>;
|
|
485
493
|
type SortDir = "asc" | "desc" | null;
|
|
486
494
|
interface DataGridColumn<T> {
|
|
487
495
|
key: keyof T | string;
|
package/dist/index.d.ts
CHANGED
|
@@ -361,8 +361,12 @@ interface UseServerTableOptions {
|
|
|
361
361
|
url: string;
|
|
362
362
|
/** Extra query params merged on every request */
|
|
363
363
|
params?: Record<string, string | number>;
|
|
364
|
-
/** If true, the response is expected to be a Laravel-encrypted payload
|
|
364
|
+
/** If true, the response is expected to be a Laravel-encrypted payload */
|
|
365
365
|
encrypt?: boolean;
|
|
366
|
+
/** Laravel APP_KEY used for decryption. Pass import.meta.env["VITE_LARAVEL_KEY"] */
|
|
367
|
+
key?: string;
|
|
368
|
+
/** If true, logs the decrypted payload to the console */
|
|
369
|
+
decryptPayloadLog?: boolean;
|
|
366
370
|
}
|
|
367
371
|
interface UseServerTableReturn<T> {
|
|
368
372
|
data: T[];
|
|
@@ -380,7 +384,7 @@ interface ServerPaginationProp {
|
|
|
380
384
|
currentPage: number;
|
|
381
385
|
goToPage: (page: number) => void;
|
|
382
386
|
}
|
|
383
|
-
declare function useServerTable<T extends Record<string, any>>({ url, params, encrypt }: UseServerTableOptions): UseServerTableReturn<T>;
|
|
387
|
+
declare function useServerTable<T extends Record<string, any>>({ url, params, encrypt, key, decryptPayloadLog }: UseServerTableOptions): UseServerTableReturn<T>;
|
|
384
388
|
type ActionFieldType = "input" | "password" | "textarea" | "checkbox" | "toggle" | "select" | "radio" | "slider" | "tag-input" | "otp" | "combobox" | "color-picker" | "date-range" | "rich-text" | "file-upload" | "repeater";
|
|
385
389
|
interface ActionField {
|
|
386
390
|
key: string;
|
|
@@ -467,8 +471,12 @@ interface ServerDataGridProp {
|
|
|
467
471
|
interface UseServerDataGridOptions {
|
|
468
472
|
url: string;
|
|
469
473
|
params?: Record<string, string | number>;
|
|
470
|
-
/** If true, the response is expected to be a Laravel-encrypted payload
|
|
474
|
+
/** If true, the response is expected to be a Laravel-encrypted payload */
|
|
471
475
|
encrypt?: boolean;
|
|
476
|
+
/** Laravel APP_KEY used for decryption. Pass import.meta.env["VITE_LARAVEL_KEY"] */
|
|
477
|
+
key?: string;
|
|
478
|
+
/** If true, logs the decrypted payload to the console */
|
|
479
|
+
decryptPayloadLog?: boolean;
|
|
472
480
|
}
|
|
473
481
|
interface UseServerDataGridReturn<T> {
|
|
474
482
|
data: T[];
|
|
@@ -481,7 +489,7 @@ interface UseServerDataGridReturn<T> {
|
|
|
481
489
|
goToPage: (page: number) => void;
|
|
482
490
|
reload: () => void;
|
|
483
491
|
}
|
|
484
|
-
declare function useServerDataGrid<T extends Record<string, any>>({ url, params, encrypt }: UseServerDataGridOptions): UseServerDataGridReturn<T>;
|
|
492
|
+
declare function useServerDataGrid<T extends Record<string, any>>({ url, params, encrypt, key, decryptPayloadLog }: UseServerDataGridOptions): UseServerDataGridReturn<T>;
|
|
485
493
|
type SortDir = "asc" | "desc" | null;
|
|
486
494
|
interface DataGridColumn<T> {
|
|
487
495
|
key: keyof T | string;
|
package/dist/index.global.js
CHANGED
|
@@ -59632,13 +59632,19 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
59632
59632
|
|
|
59633
59633
|
// src/components/tools/decryptPayload.ts
|
|
59634
59634
|
var import_crypto_js = __toESM(require_crypto_js(), 1);
|
|
59635
|
-
var import_meta = {};
|
|
59636
59635
|
function getLaravelSecretKey() {
|
|
59637
|
-
const viteKey =
|
|
59636
|
+
const viteKey = (() => {
|
|
59637
|
+
try {
|
|
59638
|
+
return new Function("return import.meta.env")();
|
|
59639
|
+
} catch {
|
|
59640
|
+
return void 0;
|
|
59641
|
+
}
|
|
59642
|
+
})()?.VITE_LARAVEL_KEY;
|
|
59638
59643
|
const legacyKey = globalThis?.process?.env?.REACT_APP_LARAVEL_KEY;
|
|
59639
|
-
const
|
|
59644
|
+
const windowKey = globalThis?.__LARAVEL_KEY__;
|
|
59645
|
+
const key = viteKey || legacyKey || windowKey;
|
|
59640
59646
|
if (!key) {
|
|
59641
|
-
throw new Error("Missing Laravel decryption key. Set VITE_LARAVEL_KEY in your .env.");
|
|
59647
|
+
throw new Error("Missing Laravel decryption key. Set VITE_LARAVEL_KEY in your .env or inject window.__LARAVEL_KEY__ via Blade.");
|
|
59642
59648
|
}
|
|
59643
59649
|
return key;
|
|
59644
59650
|
}
|
|
@@ -59656,13 +59662,13 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
59656
59662
|
}
|
|
59657
59663
|
return JSON.parse(jsonStr);
|
|
59658
59664
|
}
|
|
59659
|
-
function decryptLaravelPayload(payload) {
|
|
59660
|
-
const
|
|
59665
|
+
function decryptLaravelPayload(payload, secretKey) {
|
|
59666
|
+
const resolvedKey = secretKey ?? getLaravelSecretKey();
|
|
59661
59667
|
const parsed = parseLaravelEncryptedPayload(payload);
|
|
59662
59668
|
if (parsed.tag) {
|
|
59663
59669
|
throw new Error("Unsupported Laravel cipher (AEAD tag present). Expected AES-*-CBC payload.");
|
|
59664
59670
|
}
|
|
59665
|
-
const key = parseLaravelKey(
|
|
59671
|
+
const key = parseLaravelKey(resolvedKey);
|
|
59666
59672
|
const expectedMac = import_crypto_js.default.HmacSHA256(parsed.iv + parsed.value, key).toString();
|
|
59667
59673
|
if (expectedMac !== parsed.mac) {
|
|
59668
59674
|
throw new Error("Invalid payload MAC (wrong key or tampered payload).");
|
|
@@ -59679,7 +59685,6 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
59679
59685
|
if (!plaintext) {
|
|
59680
59686
|
throw new Error("Decryption produced empty plaintext (wrong key/cipher).");
|
|
59681
59687
|
}
|
|
59682
|
-
console.log("Decrypted payload:", plaintext);
|
|
59683
59688
|
return JSON.parse(plaintext);
|
|
59684
59689
|
}
|
|
59685
59690
|
|
|
@@ -68023,7 +68028,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
68023
68028
|
|
|
68024
68029
|
// src/components/ui/data-grid.tsx
|
|
68025
68030
|
var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
|
|
68026
|
-
function useServerDataGrid({ url: url2, params, encrypt }) {
|
|
68031
|
+
function useServerDataGrid({ url: url2, params, encrypt, key, decryptPayloadLog }) {
|
|
68027
68032
|
const [data, setData] = React24.useState([]);
|
|
68028
68033
|
const [columns, setColumns] = React24.useState([]);
|
|
68029
68034
|
const [currentPage, setCurrentPage] = React24.useState(1);
|
|
@@ -68037,7 +68042,8 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
68037
68042
|
setError(null);
|
|
68038
68043
|
axios_default.get(url2, { params: { ...params, page: currentPage } }).then(({ data: res }) => {
|
|
68039
68044
|
if (cancelled) return;
|
|
68040
|
-
const payload = encrypt ? decryptLaravelPayload(res) : res;
|
|
68045
|
+
const payload = encrypt ? decryptLaravelPayload(res, key) : res;
|
|
68046
|
+
if (encrypt && decryptPayloadLog) console.log("[useServerDataGrid] decrypted payload:", payload);
|
|
68041
68047
|
setData(payload.data);
|
|
68042
68048
|
const rawTotal = payload.total;
|
|
68043
68049
|
const rawPerPage = payload.per_page;
|
|
@@ -68056,9 +68062,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
68056
68062
|
setPagination(pg);
|
|
68057
68063
|
if (payload.data.length > 0) {
|
|
68058
68064
|
setColumns(
|
|
68059
|
-
Object.keys(payload.data[0]).map((
|
|
68060
|
-
key,
|
|
68061
|
-
header:
|
|
68065
|
+
Object.keys(payload.data[0]).map((key2) => ({
|
|
68066
|
+
key: key2,
|
|
68067
|
+
header: key2.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase())
|
|
68062
68068
|
}))
|
|
68063
68069
|
);
|
|
68064
68070
|
}
|
|
@@ -68071,7 +68077,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
68071
68077
|
return () => {
|
|
68072
68078
|
cancelled = true;
|
|
68073
68079
|
};
|
|
68074
|
-
}, [url2, currentPage, tick, JSON.stringify(params)]);
|
|
68080
|
+
}, [url2, currentPage, tick, JSON.stringify(params), encrypt, decryptPayloadLog]);
|
|
68075
68081
|
return {
|
|
68076
68082
|
data,
|
|
68077
68083
|
columns,
|
|
@@ -73098,7 +73104,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
73098
73104
|
var React46 = __toESM(require_react(), 1);
|
|
73099
73105
|
var import_react_dom3 = __toESM(require_react_dom(), 1);
|
|
73100
73106
|
var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
|
|
73101
|
-
function useServerTable({ url: url2, params, encrypt }) {
|
|
73107
|
+
function useServerTable({ url: url2, params, encrypt, key, decryptPayloadLog }) {
|
|
73102
73108
|
const [data, setData] = React46.useState([]);
|
|
73103
73109
|
const [columns, setColumns] = React46.useState([]);
|
|
73104
73110
|
const [currentPage, setCurrentPage] = React46.useState(1);
|
|
@@ -73114,7 +73120,8 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
73114
73120
|
params: { ...params, page: currentPage }
|
|
73115
73121
|
}).then(({ data: res }) => {
|
|
73116
73122
|
if (cancelled) return;
|
|
73117
|
-
const payload = encrypt ? decryptLaravelPayload(res) : res;
|
|
73123
|
+
const payload = encrypt ? decryptLaravelPayload(res, key) : res;
|
|
73124
|
+
if (encrypt && decryptPayloadLog) console.log("[useServerTable] decrypted payload:", payload);
|
|
73118
73125
|
setData(payload.data);
|
|
73119
73126
|
const rawTotal = payload.total;
|
|
73120
73127
|
const rawPerPage = payload.per_page;
|
|
@@ -73133,9 +73140,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
73133
73140
|
setPagination(pg);
|
|
73134
73141
|
if (payload.data.length > 0) {
|
|
73135
73142
|
setColumns(
|
|
73136
|
-
Object.keys(payload.data[0]).map((
|
|
73137
|
-
key,
|
|
73138
|
-
title:
|
|
73143
|
+
Object.keys(payload.data[0]).map((key2) => ({
|
|
73144
|
+
key: key2,
|
|
73145
|
+
title: key2.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase())
|
|
73139
73146
|
}))
|
|
73140
73147
|
);
|
|
73141
73148
|
}
|
|
@@ -73148,7 +73155,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
73148
73155
|
return () => {
|
|
73149
73156
|
cancelled = true;
|
|
73150
73157
|
};
|
|
73151
|
-
}, [url2, currentPage, tick, JSON.stringify(params)]);
|
|
73158
|
+
}, [url2, currentPage, tick, JSON.stringify(params), encrypt, decryptPayloadLog]);
|
|
73152
73159
|
return {
|
|
73153
73160
|
data,
|
|
73154
73161
|
columns,
|
package/dist/index.js
CHANGED
|
@@ -2001,11 +2001,18 @@ import { createPortal as createPortal2 } from "react-dom";
|
|
|
2001
2001
|
// src/components/tools/decryptPayload.ts
|
|
2002
2002
|
import CryptoJS from "crypto-js";
|
|
2003
2003
|
function getLaravelSecretKey() {
|
|
2004
|
-
const viteKey =
|
|
2004
|
+
const viteKey = (() => {
|
|
2005
|
+
try {
|
|
2006
|
+
return new Function("return import.meta.env")();
|
|
2007
|
+
} catch {
|
|
2008
|
+
return void 0;
|
|
2009
|
+
}
|
|
2010
|
+
})()?.VITE_LARAVEL_KEY;
|
|
2005
2011
|
const legacyKey = globalThis?.process?.env?.REACT_APP_LARAVEL_KEY;
|
|
2006
|
-
const
|
|
2012
|
+
const windowKey = globalThis?.__LARAVEL_KEY__;
|
|
2013
|
+
const key = viteKey || legacyKey || windowKey;
|
|
2007
2014
|
if (!key) {
|
|
2008
|
-
throw new Error("Missing Laravel decryption key. Set VITE_LARAVEL_KEY in your .env.");
|
|
2015
|
+
throw new Error("Missing Laravel decryption key. Set VITE_LARAVEL_KEY in your .env or inject window.__LARAVEL_KEY__ via Blade.");
|
|
2009
2016
|
}
|
|
2010
2017
|
return key;
|
|
2011
2018
|
}
|
|
@@ -2023,13 +2030,13 @@ function parseLaravelEncryptedPayload(payload) {
|
|
|
2023
2030
|
}
|
|
2024
2031
|
return JSON.parse(jsonStr);
|
|
2025
2032
|
}
|
|
2026
|
-
function decryptLaravelPayload(payload) {
|
|
2027
|
-
const
|
|
2033
|
+
function decryptLaravelPayload(payload, secretKey) {
|
|
2034
|
+
const resolvedKey = secretKey ?? getLaravelSecretKey();
|
|
2028
2035
|
const parsed = parseLaravelEncryptedPayload(payload);
|
|
2029
2036
|
if (parsed.tag) {
|
|
2030
2037
|
throw new Error("Unsupported Laravel cipher (AEAD tag present). Expected AES-*-CBC payload.");
|
|
2031
2038
|
}
|
|
2032
|
-
const key = parseLaravelKey(
|
|
2039
|
+
const key = parseLaravelKey(resolvedKey);
|
|
2033
2040
|
const expectedMac = CryptoJS.HmacSHA256(parsed.iv + parsed.value, key).toString();
|
|
2034
2041
|
if (expectedMac !== parsed.mac) {
|
|
2035
2042
|
throw new Error("Invalid payload MAC (wrong key or tampered payload).");
|
|
@@ -2046,7 +2053,6 @@ function decryptLaravelPayload(payload) {
|
|
|
2046
2053
|
if (!plaintext) {
|
|
2047
2054
|
throw new Error("Decryption produced empty plaintext (wrong key/cipher).");
|
|
2048
2055
|
}
|
|
2049
|
-
console.log("Decrypted payload:", plaintext);
|
|
2050
2056
|
return JSON.parse(plaintext);
|
|
2051
2057
|
}
|
|
2052
2058
|
|
|
@@ -4784,7 +4790,7 @@ Input.displayName = "Input";
|
|
|
4784
4790
|
|
|
4785
4791
|
// src/components/ui/data-grid.tsx
|
|
4786
4792
|
import { Fragment as Fragment9, jsx as jsx28, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
4787
|
-
function useServerDataGrid({ url, params, encrypt }) {
|
|
4793
|
+
function useServerDataGrid({ url, params, encrypt, key, decryptPayloadLog }) {
|
|
4788
4794
|
const [data, setData] = React24.useState([]);
|
|
4789
4795
|
const [columns, setColumns] = React24.useState([]);
|
|
4790
4796
|
const [currentPage, setCurrentPage] = React24.useState(1);
|
|
@@ -4798,7 +4804,8 @@ function useServerDataGrid({ url, params, encrypt }) {
|
|
|
4798
4804
|
setError(null);
|
|
4799
4805
|
axios.get(url, { params: { ...params, page: currentPage } }).then(({ data: res }) => {
|
|
4800
4806
|
if (cancelled) return;
|
|
4801
|
-
const payload = encrypt ? decryptLaravelPayload(res) : res;
|
|
4807
|
+
const payload = encrypt ? decryptLaravelPayload(res, key) : res;
|
|
4808
|
+
if (encrypt && decryptPayloadLog) console.log("[useServerDataGrid] decrypted payload:", payload);
|
|
4802
4809
|
setData(payload.data);
|
|
4803
4810
|
const rawTotal = payload.total;
|
|
4804
4811
|
const rawPerPage = payload.per_page;
|
|
@@ -4817,9 +4824,9 @@ function useServerDataGrid({ url, params, encrypt }) {
|
|
|
4817
4824
|
setPagination(pg);
|
|
4818
4825
|
if (payload.data.length > 0) {
|
|
4819
4826
|
setColumns(
|
|
4820
|
-
Object.keys(payload.data[0]).map((
|
|
4821
|
-
key,
|
|
4822
|
-
header:
|
|
4827
|
+
Object.keys(payload.data[0]).map((key2) => ({
|
|
4828
|
+
key: key2,
|
|
4829
|
+
header: key2.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase())
|
|
4823
4830
|
}))
|
|
4824
4831
|
);
|
|
4825
4832
|
}
|
|
@@ -4832,7 +4839,7 @@ function useServerDataGrid({ url, params, encrypt }) {
|
|
|
4832
4839
|
return () => {
|
|
4833
4840
|
cancelled = true;
|
|
4834
4841
|
};
|
|
4835
|
-
}, [url, currentPage, tick, JSON.stringify(params)]);
|
|
4842
|
+
}, [url, currentPage, tick, JSON.stringify(params), encrypt, decryptPayloadLog]);
|
|
4836
4843
|
return {
|
|
4837
4844
|
data,
|
|
4838
4845
|
columns,
|
|
@@ -9448,7 +9455,7 @@ import { createPortal as createPortal4 } from "react-dom";
|
|
|
9448
9455
|
import axios2 from "axios";
|
|
9449
9456
|
import { ChevronLeft as ChevronLeft6, ChevronRight as ChevronRight9, Search as Search5, Trash2 as Trash23, ChevronsUpDown as ChevronsUpDown2, ChevronUp as ChevronUp2, ChevronDown as ChevronDown7, X as X13, Eye as Eye2, Pencil as Pencil2, Trash as Trash3, Loader2 as Loader22 } from "lucide-react";
|
|
9450
9457
|
import { Fragment as Fragment15, jsx as jsx55, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
9451
|
-
function useServerTable({ url, params, encrypt }) {
|
|
9458
|
+
function useServerTable({ url, params, encrypt, key, decryptPayloadLog }) {
|
|
9452
9459
|
const [data, setData] = React44.useState([]);
|
|
9453
9460
|
const [columns, setColumns] = React44.useState([]);
|
|
9454
9461
|
const [currentPage, setCurrentPage] = React44.useState(1);
|
|
@@ -9464,7 +9471,8 @@ function useServerTable({ url, params, encrypt }) {
|
|
|
9464
9471
|
params: { ...params, page: currentPage }
|
|
9465
9472
|
}).then(({ data: res }) => {
|
|
9466
9473
|
if (cancelled) return;
|
|
9467
|
-
const payload = encrypt ? decryptLaravelPayload(res) : res;
|
|
9474
|
+
const payload = encrypt ? decryptLaravelPayload(res, key) : res;
|
|
9475
|
+
if (encrypt && decryptPayloadLog) console.log("[useServerTable] decrypted payload:", payload);
|
|
9468
9476
|
setData(payload.data);
|
|
9469
9477
|
const rawTotal = payload.total;
|
|
9470
9478
|
const rawPerPage = payload.per_page;
|
|
@@ -9483,9 +9491,9 @@ function useServerTable({ url, params, encrypt }) {
|
|
|
9483
9491
|
setPagination(pg);
|
|
9484
9492
|
if (payload.data.length > 0) {
|
|
9485
9493
|
setColumns(
|
|
9486
|
-
Object.keys(payload.data[0]).map((
|
|
9487
|
-
key,
|
|
9488
|
-
title:
|
|
9494
|
+
Object.keys(payload.data[0]).map((key2) => ({
|
|
9495
|
+
key: key2,
|
|
9496
|
+
title: key2.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase())
|
|
9489
9497
|
}))
|
|
9490
9498
|
);
|
|
9491
9499
|
}
|
|
@@ -9498,7 +9506,7 @@ function useServerTable({ url, params, encrypt }) {
|
|
|
9498
9506
|
return () => {
|
|
9499
9507
|
cancelled = true;
|
|
9500
9508
|
};
|
|
9501
|
-
}, [url, currentPage, tick, JSON.stringify(params)]);
|
|
9509
|
+
}, [url, currentPage, tick, JSON.stringify(params), encrypt, decryptPayloadLog]);
|
|
9502
9510
|
return {
|
|
9503
9511
|
data,
|
|
9504
9512
|
columns,
|