@hypercerts-org/sdk-core 0.9.0-beta.0 → 0.10.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -2
- package/dist/index.cjs +1195 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1183 -7
- package/dist/index.mjs +1170 -5
- package/dist/index.mjs.map +1 -1
- package/dist/testing.d.ts +26 -1
- package/dist/types.cjs +27 -2
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +89 -5
- package/dist/types.mjs +27 -2
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -141,9 +141,11 @@ const orgRepo = sdsRepo.repo(organizationDid);
|
|
|
141
141
|
// Teammate can now access orgRepo and create hypercerts
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
### 2. Authentication
|
|
144
|
+
### 2. Authentication & OAuth Permissions
|
|
145
145
|
|
|
146
|
-
The SDK uses OAuth 2.0 for authentication with
|
|
146
|
+
The SDK uses OAuth 2.0 for authentication with granular permission control.
|
|
147
|
+
|
|
148
|
+
#### Basic Authentication
|
|
147
149
|
|
|
148
150
|
```typescript
|
|
149
151
|
// First-time user authentication
|
|
@@ -164,6 +166,48 @@ const session = await sdk.restoreSession("did:plc:user123");
|
|
|
164
166
|
const repo = sdk.getRepository(session);
|
|
165
167
|
```
|
|
166
168
|
|
|
169
|
+
#### OAuth Scopes & Permissions
|
|
170
|
+
|
|
171
|
+
Control exactly what your app can access using type-safe permission builders:
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { PermissionBuilder, ScopePresets, buildScope } from '@hypercerts-org/sdk-core';
|
|
175
|
+
|
|
176
|
+
// Use ready-made presets
|
|
177
|
+
const scope = ScopePresets.EMAIL_AND_PROFILE; // Request email + profile access
|
|
178
|
+
const scope = ScopePresets.POSTING_APP; // Full posting capabilities
|
|
179
|
+
|
|
180
|
+
// Or build custom permissions
|
|
181
|
+
const scope = buildScope(
|
|
182
|
+
new PermissionBuilder()
|
|
183
|
+
.accountEmail('read') // Read user's email
|
|
184
|
+
.repoWrite('app.bsky.feed.post') // Create/update posts
|
|
185
|
+
.blob(['image/*', 'video/*']) // Upload media
|
|
186
|
+
.build()
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
// Use in OAuth configuration
|
|
190
|
+
const sdk = createATProtoSDK({
|
|
191
|
+
oauth: {
|
|
192
|
+
clientId: 'your-client-id',
|
|
193
|
+
redirectUri: 'https://your-app.com/callback',
|
|
194
|
+
scope: scope, // Your custom scope
|
|
195
|
+
// ... other config
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Available Presets:**
|
|
201
|
+
- `EMAIL_READ` - User's email address
|
|
202
|
+
- `PROFILE_READ` / `PROFILE_WRITE` - Profile access
|
|
203
|
+
- `POST_WRITE` - Create posts
|
|
204
|
+
- `SOCIAL_WRITE` - Likes, reposts, follows
|
|
205
|
+
- `MEDIA_UPLOAD` - Image and video uploads
|
|
206
|
+
- `POSTING_APP` - Full posting with media
|
|
207
|
+
- `EMAIL_AND_PROFILE` - Common combination
|
|
208
|
+
|
|
209
|
+
See [OAuth Permissions Documentation](./docs/implementations/atproto_oauth_scopes.md) for detailed usage.
|
|
210
|
+
|
|
167
211
|
### 3. Working with Hypercerts
|
|
168
212
|
|
|
169
213
|
#### Creating a Hypercert
|