Skip to content

Commit ec54cff

Browse files
committed
docs: update bff readme
1 parent 6fc44ce commit ec54cff

File tree

1 file changed

+1
-238
lines changed

1 file changed

+1
-238
lines changed

AppleSignInBackend/README.md

Lines changed: 1 addition & 238 deletions
Original file line numberDiff line numberDiff line change
@@ -105,59 +105,6 @@ Ready to receive Apple Sign-in requests from Unity!
105105

106106
---
107107

108-
## Deployment
109-
110-
### Hosting Requirements
111-
112-
The BFF must be hosted by your studio. You have flexibility in where to deploy:
113-
114-
- **Cloud Providers**: AWS, Google Cloud, Azure, DigitalOcean
115-
- **Container Services**: Docker, Kubernetes, AWS ECS, Google Cloud Run
116-
- **Serverless**: AWS Lambda, Google Cloud Functions (with appropriate configuration)
117-
- **Traditional Hosting**: Any server capable of running Node.js
118-
119-
### Deployment Steps
120-
121-
1. **Choose a hosting provider**
122-
2. **Set environment variables** (never commit `.env` to source control)
123-
3. **Build the TypeScript** (if using TypeScript):
124-
```bash
125-
npm run build
126-
```
127-
4. **Deploy** the application
128-
5. **Configure HTTPS** (required for production)
129-
6. **Set up monitoring** and health checks
130-
7. **Configure the Unity SDK** to use your BFF URL
131-
132-
### Environment Variables (Production)
133-
134-
```bash
135-
# Server
136-
PORT=3000
137-
NODE_ENV=production
138-
139-
# Apple
140-
APPLE_BUNDLE_ID=com.yourstudio.yourgame
141-
142-
# Immutable (Production)
143-
IMX_AUTH_API_URL=https://api.immutable.com
144-
IMMUTABLE_API_KEY=sk_imapik_xxx... # From Immutable Hub
145-
PASSPORT_CLIENT_ID=xxx... # From Immutable Hub
146-
```
147-
148-
### Security Checklist
149-
150-
- [ ] HTTPS enabled (required for production)
151-
- [ ] Environment variables stored securely (not in code)
152-
- [ ] API key never exposed to clients
153-
- [ ] CORS configured to allow only your game domains
154-
- [ ] Rate limiting enabled
155-
- [ ] Logging and monitoring configured
156-
- [ ] Health checks set up
157-
- [ ] Firewall rules configured
158-
159-
---
160-
161108
## Unity Configuration
162109

163110
### Passport Initialization
@@ -269,7 +216,7 @@ Health check endpoint for monitoring.
269216

270217
### Token Exchange (BYOA)
271218

272-
The BFF uses Immutable's "Bring Your Own Auth" (BYOA) connection:
219+
The BFF uses BYOA connection:
273220

274221
```typescript
275222
// BFF calls IMX Engine Auth Service
@@ -367,109 +314,6 @@ SUCCESS: Apple Sign-in Complete - Returning Tokens
367314

368315
---
369316

370-
## Troubleshooting
371-
372-
### "ERROR: IMMUTABLE_API_KEY is required but not set"
373-
374-
The API key environment variable is missing or empty.
375-
376-
**Solution:**
377-
- Check your `.env` file has `IMMUTABLE_API_KEY=sk_imapik_xxx...`
378-
- Verify the `.env` file is in the same directory as `server.ts`
379-
- Get your API key from Immutable Hub if you don't have one
380-
381-
### "ERROR: PASSPORT_CLIENT_ID is required but not set"
382-
383-
The client ID environment variable is missing or empty.
384-
385-
**Solution:**
386-
- Check your `.env` file has `PASSPORT_CLIENT_ID=xxx...`
387-
- Get your client ID from Immutable Hub if you don't have one
388-
389-
### "ERROR: Client ID mismatch"
390-
391-
The client ID in the request doesn't match the expected value.
392-
393-
**Solution:**
394-
- Verify Unity SDK is using the same client ID as configured in BFF
395-
- Check the `.env` file has the correct `PASSPORT_CLIENT_ID`
396-
397-
### "ERROR: Apple token verification failed"
398-
399-
The Apple identity token could not be verified.
400-
401-
**Possible causes:**
402-
- Token is expired (tokens are valid for ~10 minutes)
403-
- Token signature is invalid
404-
- Bundle ID mismatch (token audience doesn't match `APPLE_BUNDLE_ID`)
405-
- Network issues connecting to Apple's JWKS endpoint
406-
407-
**Solution:**
408-
- Verify `APPLE_BUNDLE_ID` matches your iOS app's bundle identifier
409-
- Check token is not expired
410-
- Ensure server can reach `https://appleid.apple.com/auth/keys`
411-
- Check BFF logs for detailed error message
412-
413-
### "ERROR: Token exchange API call failed"
414-
415-
The call to IMX Engine Auth Service failed.
416-
417-
**Possible causes:**
418-
- Invalid API key
419-
- Invalid client ID
420-
- Network issues
421-
- Wrong environment URL
422-
423-
**Solution:**
424-
- Verify `IMMUTABLE_API_KEY` is correct and active
425-
- Verify `PASSPORT_CLIENT_ID` is correct
426-
- Check `IMX_AUTH_API_URL` is correct for your environment
427-
- Check BFF logs for detailed error response from IMX Engine
428-
429-
### "Cannot connect to backend" (from Unity)
430-
431-
Unity cannot reach the BFF server.
432-
433-
**Solution:**
434-
- Verify BFF is running (`GET /health` returns 200)
435-
- Check firewall allows connections on the BFF port
436-
- For iOS device: Use Mac's IP address, not `localhost`
437-
- For iOS simulator: `localhost` should work
438-
- Verify CORS is configured to allow Unity's origin
439-
440-
### "EADDRINUSE: port already in use"
441-
442-
Another process is using the configured port.
443-
444-
**Solution:**
445-
```bash
446-
# Kill the process using the port
447-
lsof -ti:3000 | xargs kill -9
448-
449-
# Or change port in .env
450-
PORT=3001
451-
```
452-
453-
---
454-
455-
## Project Structure
456-
457-
```
458-
AppleSignInBackend/
459-
├── server.ts # TypeScript server (recommended)
460-
├── server.js # JavaScript server (legacy)
461-
├── tsconfig.json # TypeScript configuration
462-
├── package.json # Dependencies and scripts
463-
├── env.example # Environment template
464-
├── .gitignore # Git ignore rules
465-
├── README.md # This file
466-
├── SIMPLIFIED_README.md # Quick reference
467-
├── TYPESCRIPT_MIGRATION.md # TypeScript conversion notes
468-
└── dist/ # Compiled TypeScript output (gitignored)
469-
```
470-
471-
---
472-
473317
## Scripts
474318

475319
```bash
@@ -480,85 +324,4 @@ npm run dev # Development with hot-reload
480324

481325
# Build utilities
482326
npm run dev:build # Watch mode - compile on changes
483-
484-
# JavaScript (legacy)
485-
npm run start:js # Run JavaScript directly
486327
```
487-
488-
---
489-
490-
## Security Best Practices
491-
492-
### API Key Protection
493-
494-
- ✅ Store API key in environment variables
495-
- ✅ Never commit API key to source control
496-
- ✅ Rotate API keys regularly
497-
- ✅ Use different keys for sandbox and production
498-
- ❌ Never expose API key to client applications
499-
- ❌ Never log API key values
500-
501-
### Network Security
502-
503-
- ✅ Use HTTPS in production (required)
504-
- ✅ Configure CORS to allow only your game domains
505-
- ✅ Implement rate limiting
506-
- ✅ Add request size limits
507-
- ✅ Use secure headers (helmet.js)
508-
509-
### Monitoring & Logging
510-
511-
- ✅ Set up health check monitoring
512-
- ✅ Log all authentication attempts
513-
- ✅ Alert on repeated failures
514-
- ✅ Monitor for unusual patterns
515-
- ❌ Don't log sensitive tokens (except for debugging)
516-
517-
### Maintenance
518-
519-
- ✅ Keep dependencies updated
520-
- ✅ Monitor for security advisories
521-
- ✅ Have a backup/failover plan
522-
- ✅ Document deployment procedures
523-
- ✅ Test token exchange regularly
524-
525-
---
526-
527-
## Production Deployment Checklist
528-
529-
- [ ] Environment variables configured
530-
- [ ] HTTPS enabled
531-
- [ ] CORS configured for production domains
532-
- [ ] Rate limiting enabled
533-
- [ ] Health checks configured
534-
- [ ] Monitoring and alerting set up
535-
- [ ] Logging configured
536-
- [ ] Backup and failover plan documented
537-
- [ ] API keys rotated and secured
538-
- [ ] Unity SDK configured with production BFF URL
539-
- [ ] End-to-end testing completed
540-
- [ ] Security review completed
541-
542-
---
543-
544-
## Related Documentation
545-
546-
- **Apple Sign-in Overview**: `docs/Apple_Signin.md`
547-
- **Unity SDK Setup**: See main documentation for Unity integration
548-
- **Test Script Example**: `sample/Assets/Scripts/Passport/AppleSignInTest/AppleSignInTestScript.cs`
549-
550-
---
551-
552-
## Support
553-
554-
For issues or questions:
555-
1. Check the troubleshooting section above
556-
2. Review the logs for detailed error messages
557-
3. Refer to `docs/Apple_Signin.md` for complete documentation
558-
4. Contact Immutable support if issues persist
559-
560-
---
561-
562-
## License
563-
564-
MIT

0 commit comments

Comments
 (0)