@drmhse/sso-sdk 0.1.0 → 0.1.1
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 +114 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,6 +122,29 @@ localStorage.removeItem('jwt');
|
|
|
122
122
|
|
|
123
123
|
## API Reference
|
|
124
124
|
|
|
125
|
+
### Analytics
|
|
126
|
+
|
|
127
|
+
The analytics module provides login tracking and metrics for organizations.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
// Get login trends over time
|
|
131
|
+
const trends = await sso.analytics.getLoginTrends('acme-corp', {
|
|
132
|
+
start_date: '2025-01-01',
|
|
133
|
+
end_date: '2025-01-31'
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Get logins grouped by service
|
|
137
|
+
const byService = await sso.analytics.getLoginsByService('acme-corp');
|
|
138
|
+
|
|
139
|
+
// Get logins grouped by OAuth provider
|
|
140
|
+
const byProvider = await sso.analytics.getLoginsByProvider('acme-corp');
|
|
141
|
+
|
|
142
|
+
// Get recent login events
|
|
143
|
+
const recent = await sso.analytics.getRecentLogins('acme-corp', {
|
|
144
|
+
limit: 10
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
125
148
|
### Organizations
|
|
126
149
|
|
|
127
150
|
```typescript
|
|
@@ -155,28 +178,61 @@ await sso.organizations.oauthCredentials.set('acme-corp', 'github', {
|
|
|
155
178
|
client_id: 'Iv1.abc123',
|
|
156
179
|
client_secret: 'secret-value'
|
|
157
180
|
});
|
|
181
|
+
|
|
182
|
+
// Get configured OAuth credentials
|
|
183
|
+
const creds = await sso.organizations.oauthCredentials.get('acme-corp', 'github');
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### End-User Management
|
|
187
|
+
|
|
188
|
+
Manage your organization's customers (end-users with subscriptions).
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// List all end-users for an organization
|
|
192
|
+
const endUsers = await sso.organizations.endUsers.list('acme-corp', {
|
|
193
|
+
page: 1,
|
|
194
|
+
limit: 20
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// Get detailed information about a specific end-user
|
|
198
|
+
const endUser = await sso.organizations.endUsers.get('acme-corp', 'user-id');
|
|
199
|
+
|
|
200
|
+
// Revoke all active sessions for an end-user
|
|
201
|
+
const result = await sso.organizations.endUsers.revokeSessions('acme-corp', 'user-id');
|
|
158
202
|
```
|
|
159
203
|
|
|
160
204
|
### Services
|
|
161
205
|
|
|
162
206
|
```typescript
|
|
163
|
-
// Create service
|
|
164
|
-
const
|
|
207
|
+
// Create service (returns service with provider grants and default plan)
|
|
208
|
+
const result = await sso.services.create('acme-corp', {
|
|
165
209
|
slug: 'main-app',
|
|
166
210
|
name: 'Main Application',
|
|
167
211
|
service_type: 'web',
|
|
168
212
|
github_scopes: ['user:email', 'read:org'],
|
|
213
|
+
microsoft_scopes: ['User.Read', 'email'],
|
|
214
|
+
google_scopes: ['openid', 'email', 'profile'],
|
|
169
215
|
redirect_uris: ['https://app.acme.com/callback']
|
|
170
216
|
});
|
|
217
|
+
console.log(result.service.client_id);
|
|
218
|
+
console.log(result.usage.current_services);
|
|
171
219
|
|
|
172
|
-
// List services
|
|
173
|
-
const
|
|
220
|
+
// List services (returns services with usage metadata)
|
|
221
|
+
const result = await sso.services.list('acme-corp');
|
|
222
|
+
console.log(`Using ${result.usage.current_services} of ${result.usage.max_services} services`);
|
|
223
|
+
result.services.forEach(svc => console.log(svc.name, svc.client_id));
|
|
174
224
|
|
|
175
|
-
// Get service details
|
|
176
|
-
const
|
|
225
|
+
// Get service details (includes provider grants and plans)
|
|
226
|
+
const service = await sso.services.get('acme-corp', 'main-app');
|
|
227
|
+
console.log(service.service.redirect_uris);
|
|
228
|
+
console.log(service.plans);
|
|
177
229
|
|
|
178
230
|
// Update service
|
|
179
|
-
await sso.services.update('acme-corp', 'main-app', {
|
|
231
|
+
const updated = await sso.services.update('acme-corp', 'main-app', {
|
|
232
|
+
name: 'Main Application v2',
|
|
233
|
+
github_scopes: ['user:email', 'read:org', 'repo'],
|
|
234
|
+
microsoft_scopes: ['User.Read', 'email', 'Mail.Read'],
|
|
235
|
+
google_scopes: ['openid', 'email', 'profile', 'drive.readonly'],
|
|
180
236
|
redirect_uris: ['https://app.acme.com/callback', 'https://app.acme.com/oauth']
|
|
181
237
|
});
|
|
182
238
|
|
|
@@ -186,9 +242,14 @@ await sso.services.delete('acme-corp', 'old-service');
|
|
|
186
242
|
// Manage plans
|
|
187
243
|
const plan = await sso.services.plans.create('acme-corp', 'main-app', {
|
|
188
244
|
name: 'pro',
|
|
245
|
+
description: 'Pro tier with advanced features',
|
|
189
246
|
price_monthly: 29.99,
|
|
190
|
-
features: ['api-access', 'advanced-analytics']
|
|
247
|
+
features: ['api-access', 'advanced-analytics', 'priority-support']
|
|
191
248
|
});
|
|
249
|
+
|
|
250
|
+
// List all plans for a service
|
|
251
|
+
const plans = await sso.services.plans.list('acme-corp', 'main-app');
|
|
252
|
+
plans.forEach(plan => console.log(plan.name, plan.price_monthly));
|
|
192
253
|
```
|
|
193
254
|
|
|
194
255
|
### Invitations
|
|
@@ -229,6 +290,22 @@ await sso.user.updateProfile({ email: 'newemail@example.com' });
|
|
|
229
290
|
const subscription = await sso.user.getSubscription();
|
|
230
291
|
```
|
|
231
292
|
|
|
293
|
+
### Social Account Identities
|
|
294
|
+
|
|
295
|
+
Manage linked social accounts for the authenticated user.
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
// List all linked social accounts
|
|
299
|
+
const identities = await sso.user.identities.list();
|
|
300
|
+
|
|
301
|
+
// Start linking a new social account
|
|
302
|
+
const { authorization_url } = await sso.user.identities.startLink('github');
|
|
303
|
+
window.location.href = authorization_url;
|
|
304
|
+
|
|
305
|
+
// Unlink a social account
|
|
306
|
+
await sso.user.identities.unlink('google');
|
|
307
|
+
```
|
|
308
|
+
|
|
232
309
|
### Provider Tokens
|
|
233
310
|
|
|
234
311
|
```typescript
|
|
@@ -274,6 +351,12 @@ await sso.platform.promoteOwner({
|
|
|
274
351
|
user_id: 'user-uuid-here'
|
|
275
352
|
});
|
|
276
353
|
|
|
354
|
+
// Demote platform owner to regular user
|
|
355
|
+
await sso.platform.demoteOwner('user-uuid-here');
|
|
356
|
+
|
|
357
|
+
// List available organization tiers
|
|
358
|
+
const tiers = await sso.platform.getTiers();
|
|
359
|
+
|
|
277
360
|
// Get audit log
|
|
278
361
|
const logs = await sso.platform.getAuditLog({
|
|
279
362
|
action: 'organization.approved',
|
|
@@ -306,6 +389,12 @@ try {
|
|
|
306
389
|
if (error.is('SERVICE_LIMIT_EXCEEDED')) {
|
|
307
390
|
// Handle specific error
|
|
308
391
|
}
|
|
392
|
+
if (error.isForbidden()) {
|
|
393
|
+
// Handle permission errors
|
|
394
|
+
}
|
|
395
|
+
if (error.isAuthError()) {
|
|
396
|
+
// Handle authentication errors
|
|
397
|
+
}
|
|
309
398
|
}
|
|
310
399
|
}
|
|
311
400
|
```
|
|
@@ -387,10 +476,26 @@ import type {
|
|
|
387
476
|
Service,
|
|
388
477
|
User,
|
|
389
478
|
JwtClaims,
|
|
390
|
-
OAuthProvider
|
|
479
|
+
OAuthProvider,
|
|
480
|
+
SsoClientOptions,
|
|
481
|
+
SsoApiError,
|
|
482
|
+
AnalyticsQuery,
|
|
483
|
+
LoginTrendPoint,
|
|
484
|
+
LoginsByService,
|
|
485
|
+
LoginsByProvider,
|
|
486
|
+
RecentLogin,
|
|
487
|
+
Invitation,
|
|
488
|
+
Subscription,
|
|
489
|
+
ProviderToken,
|
|
490
|
+
UserProfile,
|
|
491
|
+
PlatformOrganizationResponse,
|
|
492
|
+
AuditLogEntry,
|
|
493
|
+
// ... and many more types
|
|
391
494
|
} from '@drmhse/sso-sdk';
|
|
392
495
|
```
|
|
393
496
|
|
|
497
|
+
All API responses, request payloads, and configuration options are fully typed for excellent IDE support and compile-time safety.
|
|
498
|
+
|
|
394
499
|
## License
|
|
395
500
|
|
|
396
501
|
MIT
|