-
Notifications
You must be signed in to change notification settings - Fork 1
OAuth scopes and email #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add base OAuth scope constants - Add Zod schemas for permission primitives - Add NSID and MIME type validation patterns - Export inferred TypeScript types
- Implement AccountPermissionSchema with Zod transform - Support optional action parameter - Transform to correct permission string format - Add comprehensive validation tests
- Implement RepoPermissionSchema with NSID validation - Support optional actions array - Transform to correct query string format - Add validation for collection names
- Implement BlobPermissionSchema with MIME type validation - Implement RpcPermissionSchema with lexicon/aud validation - Implement IdentityPermissionSchema for handle permissions - Implement IncludePermissionSchema with NSID validation - Add PermissionSchema union combining all six permission types - Fix NSID regex to allow uppercase letters (valid per atproto spec) - Add comprehensive tests (72 tests, all passing) - Update NSID test cases to reflect correct specification
- Implement PermissionBuilder class with method chaining - Add convenience methods: accountEmail, accountRepo, repoRead, repoWrite, repoFull - Support all permission types: account, repo, blob, rpc, identity, include - Add transitional scope support with short names (email, generic, chat.bsky) - Include utility methods: atproto(), custom(), clear(), count() - Add 36 comprehensive tests covering all builder methods - All 108 tests passing
- Implement buildScope() to join permissions with spaces - Implement parseScope() to split scope strings - Add hasPermission() for checking single permission - Add hasAllPermissions() and hasAnyPermission() for multiple checks - Add mergeScopes() with deduplication - Add removePermissions() for filtering - Add validateScope() for basic well-formedness checking - Add 41 comprehensive tests for all utility functions - All 149 tests passing
- Add ScopePresets object with 14 pre-built permission sets - Include EMAIL_READ, PROFILE_READ/WRITE, POST_WRITE presets - Add SOCIAL_WRITE for likes/reposts/follows - Add MEDIA_UPLOAD and IMAGE_UPLOAD presets - Add POSTING_APP preset combining posts and media - Add READ_ONLY and FULL_ACCESS presets - Include EMAIL_AND_PROFILE combo preset - Add transitional scope presets for backward compatibility - Add 18 comprehensive tests for all presets - All 167 tests passing
- Export all permission schemas and types - Export PermissionBuilder class - Export ScopePresets object - Export all utility functions (buildScope, parseScope, etc.) - Export TypeScript types for type inference - Build successful with new exports
- Add concise OAuth permissions explainer - Document PermissionBuilder and ScopePresets usage - List all available presets with descriptions - Include code examples for custom scope building - Link to detailed documentation
- Add comprehensive JSDoc examples for scope field - Document usage with PermissionBuilder and ScopePresets - Add validation: scope must be non-empty string - Link to atproto permission specs - Build and lint successful
- Add comprehensive JSDoc examples for scope parameter - Document usage with ScopePresets and PermissionBuilder - Include preset examples (EMAIL_AND_PROFILE, POSTING_APP) - Include custom scope building example - Preserve legacy scope examples - Build and lint successful
🦋 Changeset detectedLatest commit: ec17a44 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
- Implement email retrieval from authenticated session - Support both transitional and granular permissions - Return null when permission not granted - Add comprehensive error handling and validation - Add 7 test cases covering all scenarios
68d03e1 to
ec17a44
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add OAuth Scopes and Granular Permissions System
This PR implements a comprehensive OAuth permissions system to help developers easily define correct OAuth scopes, with specific support for accessing user emails via the OAuth flow.
Key Features
1. Permission Type System
account,repo,blob,rpc,identity,include2. Fluent Permission Builder API
3. Scope Utilities
buildScope(),parseScope(),hasPermission(),mergeScopes(),validateScope()and more4. Pre-built Scope Presets
EMAIL_READ,POSTING_APP,FULL_ACCESS, etc.5. Enhanced OAuth Integration
6. Email Access Helper