@juv/codego-react-ui 3.5.5 → 3.5.7
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 +47 -0
- package/dist/index.cjs +2477 -2544
- package/dist/index.d.cts +13 -23
- package/dist/index.d.ts +13 -23
- package/dist/index.global.js +2447 -2513
- package/dist/index.js +3159 -3225
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -739,6 +739,53 @@ function AnnouncementsPage() {
|
|
|
739
739
|
|
|
740
740
|
---
|
|
741
741
|
|
|
742
|
+
## Laravel Response Decryption
|
|
743
|
+
|
|
744
|
+
Use `decryptResponse` to decrypt Laravel-encrypted API responses (AES-256-CBC).
|
|
745
|
+
|
|
746
|
+
### Setup
|
|
747
|
+
|
|
748
|
+
Add your Laravel `APP_KEY` to `.env`:
|
|
749
|
+
|
|
750
|
+
```env
|
|
751
|
+
VITE_LARAVEL_KEY=base64:your_laravel_app_key_here
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
### Usage
|
|
755
|
+
|
|
756
|
+
```tsx
|
|
757
|
+
import { api, decryptResponse } from "@juv/codego-react-ui"
|
|
758
|
+
|
|
759
|
+
type Certificate = { id: number; name: string }
|
|
760
|
+
|
|
761
|
+
const fetchCertificates = async () => {
|
|
762
|
+
const data = await api.get<string>('/certificate')
|
|
763
|
+
const decoded = decryptResponse<Certificate[]>(data)
|
|
764
|
+
console.log(decoded)
|
|
765
|
+
}
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
> `api.get` should be typed as `string` since the raw response is an encrypted payload. `decryptResponse` reads `VITE_LARAVEL_KEY` automatically.
|
|
769
|
+
|
|
770
|
+
You can also pass the key explicitly:
|
|
771
|
+
|
|
772
|
+
```tsx
|
|
773
|
+
const decoded = decryptResponse<Certificate[]>(data, "base64:your_key_here")
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
### API
|
|
777
|
+
|
|
778
|
+
| Export | Description |
|
|
779
|
+
|---|---|
|
|
780
|
+
| `decryptResponse(response, key?)` | Decrypts a Laravel-encrypted string or `{ data: string }` object. |
|
|
781
|
+
| `decryptLaravelPayload(payload, key?)` | Low-level decryption of a raw encrypted payload string. |
|
|
782
|
+
| `getLaravelSecretKey()` | Reads the key from `VITE_LARAVEL_KEY`, `REACT_APP_LARAVEL_KEY`, or `window.__LARAVEL_KEY__`. |
|
|
783
|
+
| `parseLaravelKey(secretKey)` | Parses a `base64:...` or raw key string into a `CryptoJS.WordArray`. |
|
|
784
|
+
| `parseLaravelEncryptedPayload(payload)` | Parses a base64-encoded Laravel encrypted payload into `{ iv, value, mac }`. |
|
|
785
|
+
| `LaravelEncryptedPayload` | Type for the parsed payload object. |
|
|
786
|
+
|
|
787
|
+
---
|
|
788
|
+
|
|
742
789
|
## Run Locally
|
|
743
790
|
|
|
744
791
|
**Prerequisites:** Node.js
|