Introduces a new PermissionsApiService to query user feature permissions from the backend, enabling fine-grained access control for features like AI models, storage limits, and wallet capabilities.
- Added
PermissionsApiServiceclass with methods:getPermissions()- Get all user permissionscheckFeature(feature)- Check single feature accesscheckFeatures(features)- Batch check multiple featuresgetFeaturesInCategory(category)- Get features by categoryhasFeature(feature)- Simple boolean helpergetFeatureLimit(feature)- Get limit value/unit for a feature
- Added
Permission,PermissionsResponse,FeatureCheckResponse,MultiFeatureCheckResponse,CategoryFeaturesResponse
- Exposed permission methods to other plugins:
checkPermission(feature)- Check feature with limitshasPermission(feature)- Simple boolean checkgetAllPermissions()- Get all user permissionscheckPermissions(features)- Batch checkgetFeaturesByCategory(category)- Category-based queriesgetFeatureLimit(feature)- Get limits only
- Added
setToken()method to all API service classes for proper encapsulation (removesas anycasts) - Added permissions endpoint URL to
@remix-endpoints-helper
// Simple boolean check - is feature allowed?
const canUseGPT4 = await call('auth', 'hasPermission', 'ai:gpt-4')
if (!canUseGPT4) {
showUpgradeModal('GPT-4 requires a Pro subscription')
}
// Check with limit info
const storage = await call('auth', 'checkPermission', 'storage:workspace')
if (storage.allowed) {
console.log(`Storage allowed: ${storage.limit} ${storage.unit}`) // e.g., "500 MB"
}
// Get just the limit for a feature
const { limit, unit } = await call('auth', 'getFeatureLimit', 'ai:monthly-requests')
console.log(`You have ${limit} ${unit} remaining`) // e.g., "1000 requests"
// Batch check multiple features at once (single API call)
const permissions = await call('auth', 'checkPermissions', [
'ai:gpt-4',
'ai:claude',
'wallet:mainnet',
'storage:5gb'
])
// Returns: { 'ai:gpt-4': { allowed: true }, 'ai:claude': { allowed: false }, ... }
// Get all AI-related features
const aiFeatures = await call('auth', 'getFeaturesByCategory', 'ai')
// Returns: [{ feature_name: 'ai:gpt-4', allowed: true, limit_value: 100, limit_unit: 'requests' }, ...]
// Get all permissions for current user (useful for settings/profile page)
const allPermissions = await call('auth', 'getAllPermissions')
allPermissions.forEach(p => {
console.log(`${p.feature_name}: ${p.allowed ? '✓' : '✗'}`)
})// In an AI plugin
async handleUserPrompt(prompt: string, model: string) {
// Check if user can use this model
const { allowed, limit, unit } = await this.call('auth', 'checkPermission', `ai:${model}`)
if (!allowed) {
throw new Error(`${model} is not available on your plan. Please upgrade.`)
}
if (limit !== undefined) {
const usage = await this.getMonthlyUsage()
if (usage >= limit) {
throw new Error(`You've reached your ${limit} ${unit} limit for ${model}.`)
}
}
// Proceed with API call...
}