You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
6.9 KiB
6.9 KiB
TimeSafari Daily Notification Plugin - Request Configuration Quick Reference
Author: Matthew Raymer
Version: 1.0.0
Created: 2025-10-08 06:24:57 UTC
Quick Setup for TimeSafari PWA
Basic Configuration
import { DailyNotification } from '@timesafari/daily-notification-plugin';
await DailyNotification.configure({
// Required: Active DID for TimeSafari integration
timesafariConfig: {
activeDid: userDid
},
// Basic network settings
networkConfig: {
timeout: 30000,
retryAttempts: 3,
maxConcurrent: 5
}
});
Complete TimeSafari Configuration
await DailyNotification.configure({
// TimeSafari integration
timesafariConfig: {
activeDid: userDid,
endpoints: {
offersToPerson: 'https://endorser.ch/api/v1/offers/person',
offersToPlans: 'https://endorser.ch/api/v1/offers/plans'
},
syncConfig: {
enableParallel: true,
maxConcurrent: 3,
batchSize: 10
}
},
// Network configuration
networkConfig: {
timeout: 30000,
retryAttempts: 3,
retryDelay: 1000,
maxConcurrent: 5,
userAgent: 'TimeSafari-PWA/1.0.0'
},
// Authentication
authentication: {
jwt: {
secret: process.env.JWT_SECRET,
algorithm: 'HS256',
expirationMinutes: 60
}
},
// Observability
logging: {
level: 'INFO',
enableRequestLogging: true,
redactSensitiveData: true
}
});
Platform-Specific Quick Configs
Android
await DailyNotification.configure({
platform: 'android',
androidConfig: {
workManagerConstraints: {
requiresNetworkType: 'CONNECTED',
requiresBatteryNotLow: false
},
requestConfig: {
connectTimeout: 30000,
readTimeout: 30000
}
}
});
iOS
await DailyNotification.configure({
platform: 'ios',
iosConfig: {
backgroundTasks: {
'com.timesafari.daily-notification-fetch': {
requiresNetworkConnectivity: true
}
},
urlSessionConfig: {
timeoutIntervalForRequest: 30,
allowsCellularAccess: true
}
}
});
Electron
await DailyNotification.configure({
platform: 'electron',
electronConfig: {
sessionConfig: {
userAgent: 'TimeSafari-Desktop/1.0.0',
cacheEnabled: true
},
requestConfig: {
timeout: 30000,
maxRedirects: 5
}
}
});
Common Request Patterns
1. Content Fetching
await DailyNotification.configure({
contentFetch: {
enabled: true,
schedule: '0 8 * * *', // Daily at 8 AM
url: 'https://endorser.ch/api/v1/community/updates',
headers: {
'Authorization': `Bearer ${authToken}`,
'X-User-DID': userDid
},
timeout: 15000,
retryAttempts: 2
}
});
2. Callback Configuration
await DailyNotification.configure({
callbacks: {
apiService: 'https://api.timesafari.com/notifications/callback',
database: 'local://notification-storage',
reporting: 'https://analytics.timesafari.com/events',
onSuccess: async (data) => {
// Handle successful fetch
console.log('Content fetched:', data);
},
onError: async (error) => {
// Handle error
console.error('Fetch error:', error);
}
}
});
3. Circuit Breaker
await DailyNotification.configure({
circuitBreaker: {
failureThreshold: 5,
recoveryTimeout: 30000,
monitoringPeriod: 60000
}
});
4. Rate Limiting
await DailyNotification.configure({
rateLimiting: {
maxRequestsPerMinute: 30,
maxRequestsPerHour: 1000,
burstLimit: 10,
backoffStrategy: 'exponential'
}
});
Security Quick Configs
Certificate Pinning
await DailyNotification.configure({
security: {
certificatePinning: {
enabled: true,
pins: [
{
hostname: 'endorser.ch',
pins: ['sha256/YOUR_PIN_HERE']
}
]
}
}
});
Data Protection
await DailyNotification.configure({
dataProtection: {
encryption: {
enabled: true,
algorithm: 'AES-256-GCM'
},
redaction: {
enabled: true,
patterns: ['password', 'token', 'secret']
}
}
});
Debugging Configs
Enable Debug Logging
await DailyNotification.configure({
logging: {
level: 'DEBUG',
enableRequestLogging: true,
enableResponseLogging: true,
enableErrorLogging: true
}
});
Disable Security for Development
await DailyNotification.configure({
security: {
certificatePinning: {
enabled: false // Only for development
}
}
});
Error Handling Quick Configs
Retry Configuration
await DailyNotification.configure({
retry: {
strategy: 'exponential',
initialDelay: 1000,
maxDelay: 30000,
multiplier: 2,
maxRetries: {
contentFetch: 3,
notificationDelivery: 2
}
}
});
Fallback Configuration
await DailyNotification.configure({
fallback: {
contentFallbacks: [
{
condition: 'network_unavailable',
action: 'use_cached_content',
maxAge: 3600
}
]
}
});
Vue.js Integration Example
// In your Vue component
import { defineComponent } from 'vue';
import { DailyNotification } from '@timesafari/daily-notification-plugin';
export default defineComponent({
name: 'NotificationSettings',
async mounted() {
await DailyNotification.configure({
timesafariConfig: {
activeDid: this.userDid
},
contentFetch: {
enabled: true,
schedule: '0 9 * * *',
callbacks: {
onSuccess: this.handleSuccess,
onError: this.handleError
}
}
});
},
methods: {
handleSuccess(data: Record<string, unknown>) {
this.notificationData = data;
},
handleError(error: Error) {
this.showError(error.message);
}
}
});
Environment Variables
Required Environment Variables
# TimeSafari configuration
JWT_SECRET=your_jwt_secret_here
API_KEY=your_api_key_here
# Optional configuration
OAUTH_CLIENT_ID=your_oauth_client_id
OAUTH_CLIENT_SECRET=your_oauth_client_secret
Development Environment
# Development settings
NODE_ENV=development
LOG_LEVEL=DEBUG
CERTIFICATE_PINNING=false
Common Issues and Solutions
Issue: Network Timeout
Solution: Increase timeout
networkConfig: {
timeout: 60000 // 60 seconds
}
Issue: Authentication Errors
Solution: Check JWT configuration
authentication: {
jwt: {
secret: process.env.JWT_SECRET,
algorithm: 'HS256'
}
}
Issue: Certificate Errors
Solution: Disable pinning for development
security: {
certificatePinning: {
enabled: false
}
}
For detailed configuration options, see: docs/host-request-configuration.md