Quick Setup
PHP Setup
1. Publish the Config
bash
php artisan vendor:publish --provider="Wanadri\XSignPayload\Frameworks\Laravel\XSignPayloadServiceProvider"2. Generate Secret
bash
php artisan x-sign:installThis command will generate a secure 256-bit secret and add it to your .env file.
3. Configure Environment
env
X_SIGN_SECRET=your_generated_secret_here
X_SIGN_ALGORITHM=sha256
X_SIGN_ENABLE_TIMESTAMP=true
X_SIGN_REPLAY_WINDOW=104. Configure Settings (Optional)
php
// config/x-sign-payload.php
return [
'secret' => env('X_SIGN_SECRET'),
'algorithm' => env('X_SIGN_ALGORITHM', 'sha256'),
'enable_timestamp' => env('X_SIGN_ENABLE_TIMESTAMP', true),
'replay_window' => env('X_SIGN_REPLAY_WINDOW', 10),
];JavaScript / TypeScript Setup
1. Create Client Instance
typescript
import { XSignClient } from "x-sign-payload";
const xSign = new XSignClient({
secret: process.env.X_SIGN_SECRET, // Or pass directly
algorithm: "sha256", // 'sha256' | 'sha512'
enableTimestamp: true, // Enable replay protection
});
export default xSign;2. Environment Variables
Create .env file:
env
X_SIGN_SECRET=your_secret_here
X_SIGN_ALGORITHM=sha256Verify Your Setup
bash
php artisan tinker
> config('x-sign-payload.secret');Next Steps
- How to Use - Learn how to sign and verify requests
- Middleware Implementation - Protect your routes