initial: bootstrap from BukidBountyApp base
This commit is contained in:
97
plans/HashPayloadURLPlan.md
Normal file
97
plans/HashPayloadURLPlan.md
Normal file
@@ -0,0 +1,97 @@
|
||||
## Final Implementation Plan for Hashkey/Payload URL Encoding System
|
||||
|
||||
### Understanding the Requirement
|
||||
|
||||
Based on your clarification:
|
||||
- **Current navigation pattern:** `navigate({ page: 'EditUser', props: { target_user: hashkey } })`
|
||||
- **URL format should be:** `/page-name--h:HASHKEY` or `/page-name--e:PAYLOAD`
|
||||
- **Hashkeys are passed as values** (not prop names)
|
||||
- **Encrypted payloads needed** for sensitive data
|
||||
- **Universal resolver** - same mechanism for users, products, stores, etc.
|
||||
|
||||
### Revised Implementation Plan
|
||||
|
||||
#### 1. Frontend - New Composables
|
||||
|
||||
**File: `resources/js/composables/useUrlArgument.js`**
|
||||
```javascript
|
||||
export function useUrlArgument() {
|
||||
// Extract hashkey/payload from URL path segments
|
||||
// Parse format like "/edituser--h:HASHKEY" or "/product--e:ENCODED_PAYLOAD"
|
||||
// Return: { slug, type, hashkey, payload }
|
||||
}
|
||||
```
|
||||
|
||||
**File: `resources/js/composables/useUrlEncoder.js`**
|
||||
```javascript
|
||||
export function useUrlEncoder() {
|
||||
const encodeHash = (hashkey) => `h:${hashkey}`;
|
||||
const encodePayload = (payload) => `e:${base64Encode(JSON.stringify(payload))}`;
|
||||
// Returns URL-friendly encoded strings
|
||||
}
|
||||
```
|
||||
|
||||
#### 2. Frontend - Updated useNavigate
|
||||
|
||||
Modify existing `resources/js/composables/Core/useNavigate.js` to:
|
||||
- Detect hashkey/payload in props and encode them into URL
|
||||
- Support format: `/page-name--h:HASHKEY` or `/page-name--e:PAYLOAD`
|
||||
- Maintain backward compatibility with current navigation
|
||||
- Extract from current URL on page load
|
||||
|
||||
#### 3. Backend - PHP Helpers
|
||||
|
||||
**File: `app/Support/RouteArgumentParser.php`**
|
||||
```php
|
||||
class RouteArgumentParser {
|
||||
public function parseArgument($argument)
|
||||
// Parse format: "page-name--h:HASHKEY" or "page-name--e:ENCODED_PAYLOAD"
|
||||
// Returns structured data for the resource
|
||||
}
|
||||
```
|
||||
|
||||
**File: `app/Support/HashkeyResolver.php`**
|
||||
```php
|
||||
class HashkeyResolver {
|
||||
public function resolveByHashkey($hashkey, $modelClass)
|
||||
// Generic resolver that accepts any model class (User, Product, Store, etc.)
|
||||
}
|
||||
```
|
||||
|
||||
#### 4. Backend - Middleware
|
||||
|
||||
**File: `app/Middleware/DecodeRouteArgumentMiddleware.php`**
|
||||
```php
|
||||
class DecodeRouteArgumentMiddleware {
|
||||
public function handle($request, Closure $next)
|
||||
// Automatically parses URL arguments and attaches to request
|
||||
// Makes decoded data available as $request->decodedRoute
|
||||
}
|
||||
```
|
||||
|
||||
### URL Format Examples
|
||||
- **User route:** `/edituser--h:USER_HASHKEY123`
|
||||
- **Product route:** `/product/edit--h:PRODUCT_HASH456`
|
||||
- **Store route:** `/store/view--h:STORE_HASH789`
|
||||
- **Payload route (encrypted):** `/data/review--e:ENCODED_PAYLOAD`
|
||||
|
||||
### Current Navigation to URL Mapping
|
||||
|
||||
| Current Nav | New URL Format |
|
||||
|-------------|----------------|
|
||||
| `navigate({ page: 'EditUser', props: { target_user: hashkey } })` | `/edituser--h:HASHKEY` |
|
||||
|
||||
### Migration Strategy
|
||||
|
||||
1. **Phase 1: Composables** - Create `useUrlArgument.js` and `useUrlEncoder.js`
|
||||
2. **Phase 2: Frontend Integration** - Update `useNavigate.js`
|
||||
3. **Phase 3: Backend Parsing** - Create PHP helpers
|
||||
4. **Phase 4: Middleware** - Add middleware for automatic parsing
|
||||
5. **Phase 5: Testing** - Verify navigation works with both old and new formats
|
||||
|
||||
### Key Features
|
||||
|
||||
- ✅ Backward compatible (existing navigation still works)
|
||||
- ✅ Universal hashkey resolver for all resource types
|
||||
- ✅ Encrypted payload support for sensitive data
|
||||
- ✅ Standard URL format across all routes
|
||||
Reference in New Issue
Block a user