@drmhse/sso-sdk 0.2.1 → 0.2.2

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 CHANGED
@@ -4,12 +4,12 @@ A zero-dependency, strongly-typed TypeScript SDK for interacting with the multi-
4
4
 
5
5
  ## Features
6
6
 
7
- - **Zero Dependencies**: Built on native `fetch` API - no external dependencies
8
- - **Framework Agnostic**: Pure TypeScript - works in any JavaScript environment
9
- - **Strongly Typed**: Complete TypeScript definitions for all API endpoints
10
- - **Stateless Design**: No internal state management - integrates with any state solution
11
- - **Predictable Error Handling**: Custom `SsoApiError` class with structured error information
12
- - **Modern**: Supports Node.js 18+ and all modern browsers
7
+ - **Zero Dependencies**: Built on native `fetch` API - no external dependencies.
8
+ - **Framework Agnostic**: Pure TypeScript - works in any JavaScript environment.
9
+ - **Strongly Typed**: Complete TypeScript definitions for all API endpoints.
10
+ - **Stateless Design**: No internal state management - integrates with any state solution.
11
+ - **Predictable Error Handling**: Custom `SsoApiError` class with structured error information.
12
+ - **Modern**: Supports Node.js 18+ and all modern browsers.
13
13
 
14
14
  ## Installation
15
15
 
@@ -97,7 +97,7 @@ const deviceAuth = await sso.auth.deviceCode.request({
97
97
  console.log(`Visit: ${deviceAuth.verification_uri}`);
98
98
  console.log(`Enter code: ${deviceAuth.user_code}`);
99
99
 
100
- // 3. Poll for the token
100
+ // 4. Poll for the token
101
101
  const pollForToken = async () => {
102
102
  // Polling logic...
103
103
  };
@@ -109,11 +109,12 @@ pollForToken();
109
109
  // 2. After user enters the code, verify it to get context
110
110
  const context = await sso.auth.deviceCode.verify(userEnteredCode);
111
111
 
112
- // Redirect user to the appropriate login flow with the user_code
112
+ // 3. Redirect user to the appropriate login flow, passing the user_code
113
+ // This links the browser session to the device waiting for authorization.
113
114
  const loginUrl = sso.auth.getLoginUrl('github', {
114
115
  org: context.org_slug,
115
116
  service: context.service_slug,
116
- user_code: userEnteredCode,
117
+ user_code: userEnteredCode, // CRITICAL: Pass user_code here
117
118
  });
118
119
  window.location.href = loginUrl; // User logs in, authorizing the device
119
120
  ```
@@ -147,9 +148,9 @@ localStorage.removeItem('sso_refresh_token');
147
148
 
148
149
  ## API Reference
149
150
 
150
- ### Analytics
151
+ ### Analytics (`sso.analytics`)
151
152
 
152
- The analytics module provides login tracking and metrics for organizations.
153
+ Provides login tracking and metrics for a specific organization.
153
154
 
154
155
  ```typescript
155
156
  // Get login trends over time
@@ -159,7 +160,19 @@ const trends = await sso.analytics.getLoginTrends('acme-corp', {
159
160
  });
160
161
  ```
161
162
 
162
- ### Organizations
163
+ ### Authentication (`sso.auth`)
164
+
165
+ Handles all authentication flows, including OAuth, device flow, and token management.
166
+
167
+ ```typescript
168
+ // Get a fresh OAuth token for an external provider (e.g., GitHub)
169
+ const githubToken = await sso.auth.getProviderToken('github');
170
+ // Use githubToken.access_token to make GitHub API calls
171
+ ```
172
+
173
+ ### Organizations (`sso.organizations`)
174
+
175
+ Manages organizations, members, and BYOO credentials.
163
176
 
164
177
  ```typescript
165
178
  // Create organization (public endpoint)
@@ -176,7 +189,7 @@ await sso.organizations.oauthCredentials.set('acme-corp', 'github', {
176
189
  });
177
190
  ```
178
191
 
179
- ### End-User Management
192
+ #### End-User Management (`sso.organizations.endUsers`)
180
193
 
181
194
  Manage your organization's customers (end-users with subscriptions).
182
195
 
@@ -191,7 +204,9 @@ const endUsers = await sso.organizations.endUsers.list('acme-corp', {
191
204
  await sso.organizations.endUsers.revokeSessions('acme-corp', 'user-id-123');
192
205
  ```
193
206
 
194
- ### Services & Plans
207
+ ### Services & Plans (`sso.services`)
208
+
209
+ Manages the applications (services) and subscription plans for an organization.
195
210
 
196
211
  ```typescript
197
212
  // Create a service
@@ -211,9 +226,9 @@ await sso.services.plans.create('acme-corp', 'main-app', {
211
226
  });
212
227
  ```
213
228
 
214
- ### User Profile & Identities
229
+ ### User Profile & Identities (`sso.user`)
215
230
 
216
- Manage the authenticated user's own profile and linked social accounts.
231
+ Manages the authenticated user's own profile and linked social accounts.
217
232
 
218
233
  ```typescript
219
234
  // Get profile
@@ -227,7 +242,22 @@ window.location.href = authorization_url;
227
242
  await sso.user.identities.unlink('github');
228
243
  ```
229
244
 
230
- ### Platform Administration
245
+ ### Invitations (`sso.invitations`)
246
+
247
+ Manages team invitations for an organization.
248
+
249
+ ```typescript
250
+ // Create and send an invitation
251
+ await sso.invitations.create('acme-corp', {
252
+ email: 'new-dev@example.com',
253
+ role: 'member'
254
+ });
255
+
256
+ // List invitations for the current user
257
+ const myInvites = await sso.invitations.listForUser();
258
+ ```
259
+
260
+ ### Platform Administration (`sso.platform`)
231
261
 
232
262
  Platform owner methods require a Platform Owner JWT.
233
263
 
@@ -241,8 +271,14 @@ const pendingOrgs = await sso.platform.organizations.list({
241
271
  await sso.platform.organizations.approve('org-id-123', {
242
272
  tier_id: 'tier-starter'
243
273
  });
274
+ ```
275
+
276
+ #### Platform Analytics (`sso.platform.analytics`)
244
277
 
245
- // Get platform-wide analytics
278
+ Provides platform-wide metrics for platform owners.
279
+
280
+ ```typescript
281
+ // Get platform-wide analytics overview
246
282
  const overview = await sso.platform.analytics.getOverview();
247
283
  console.log(`Total Users: ${overview.total_users}`);
248
284
  ```
package/dist/index.d.mts CHANGED
@@ -560,7 +560,6 @@ interface Invitation {
560
560
  status: InvitationStatus;
561
561
  expires_at: string;
562
562
  created_at: string;
563
- updated_at: string;
564
563
  }
565
564
  /**
566
565
  * Create invitation payload
package/dist/index.d.ts CHANGED
@@ -560,7 +560,6 @@ interface Invitation {
560
560
  status: InvitationStatus;
561
561
  expires_at: string;
562
562
  created_at: string;
563
- updated_at: string;
564
563
  }
565
564
  /**
566
565
  * Create invitation payload
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drmhse/sso-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Zero-dependency TypeScript SDK for the multi-tenant SSO Platform API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",