swcombine-sdk 1.4.0 → 1.5.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 +26 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,10 +44,21 @@ pnpm add swcombine-sdk
|
|
|
44
44
|
```typescript
|
|
45
45
|
import { SWCombine } from 'swcombine-sdk';
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
// Public mode (no auth)
|
|
48
|
+
const publicClient = new SWCombine();
|
|
49
|
+
|
|
50
|
+
// Token-only mode (use an existing token)
|
|
51
|
+
const tokenClient = new SWCombine({
|
|
52
|
+
token: process.env.SWC_ACCESS_TOKEN!,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Full OAuth mode (required for OAuth flows and token refresh)
|
|
56
|
+
const fullClient = new SWCombine({
|
|
48
57
|
clientId: process.env.SWC_CLIENT_ID!,
|
|
49
58
|
clientSecret: process.env.SWC_CLIENT_SECRET!,
|
|
50
|
-
token: process.env.SWC_ACCESS_TOKEN, // Optional -
|
|
59
|
+
token: process.env.SWC_ACCESS_TOKEN, // Optional - string or OAuthToken object
|
|
60
|
+
redirectUri: 'http://localhost:3000/callback',
|
|
61
|
+
accessType: 'offline',
|
|
51
62
|
});
|
|
52
63
|
```
|
|
53
64
|
|
|
@@ -55,7 +66,7 @@ const client = new SWCombine({
|
|
|
55
66
|
|
|
56
67
|
```typescript
|
|
57
68
|
// Get public character information (no auth required)
|
|
58
|
-
const character = await
|
|
69
|
+
const character = await publicClient.character.getByHandle({
|
|
59
70
|
handle: 'character-handle',
|
|
60
71
|
});
|
|
61
72
|
|
|
@@ -68,8 +79,6 @@ console.log(character.name); // "Character Name"
|
|
|
68
79
|
```typescript
|
|
69
80
|
// For authenticated endpoints, provide an access token
|
|
70
81
|
const authenticatedClient = new SWCombine({
|
|
71
|
-
clientId: process.env.SWC_CLIENT_ID!,
|
|
72
|
-
clientSecret: process.env.SWC_CLIENT_SECRET!,
|
|
73
82
|
token: process.env.SWC_ACCESS_TOKEN!,
|
|
74
83
|
});
|
|
75
84
|
|
|
@@ -110,6 +119,12 @@ npm run get-token
|
|
|
110
119
|
|
|
111
120
|
### Manual OAuth Flow
|
|
112
121
|
|
|
122
|
+
OAuth-only methods require full OAuth mode (`clientId` + `clientSecret`):
|
|
123
|
+
- `client.auth.getAuthorizationUrl(...)`
|
|
124
|
+
- `client.auth.handleCallback(...)`
|
|
125
|
+
- `client.auth.revokeToken(...)`
|
|
126
|
+
- `client.refreshToken()`
|
|
127
|
+
|
|
113
128
|
```typescript
|
|
114
129
|
import { SWCombine, CharacterScopes, MessageScopes } from 'swcombine-sdk';
|
|
115
130
|
|
|
@@ -408,11 +423,12 @@ await client.character.messages.list({
|
|
|
408
423
|
|
|
409
424
|
```typescript
|
|
410
425
|
interface ClientConfig {
|
|
411
|
-
//
|
|
412
|
-
|
|
413
|
-
|
|
426
|
+
// Optional OAuth credentials
|
|
427
|
+
// If provided, both must be set together
|
|
428
|
+
clientId?: string;
|
|
429
|
+
clientSecret?: string;
|
|
414
430
|
|
|
415
|
-
// Optional authentication -
|
|
431
|
+
// Optional authentication - string or full OAuthToken object
|
|
416
432
|
token?: string | OAuthToken;
|
|
417
433
|
|
|
418
434
|
// Optional OAuth settings
|
|
@@ -445,10 +461,7 @@ See the [examples](examples/) directory for complete working examples:
|
|
|
445
461
|
```typescript
|
|
446
462
|
import { SWCombine } from 'swcombine-sdk';
|
|
447
463
|
|
|
448
|
-
const client = new SWCombine(
|
|
449
|
-
clientId: process.env.SWC_CLIENT_ID!,
|
|
450
|
-
clientSecret: process.env.SWC_CLIENT_SECRET!,
|
|
451
|
-
});
|
|
464
|
+
const client = new SWCombine();
|
|
452
465
|
|
|
453
466
|
// Get character info
|
|
454
467
|
const character = await client.character.getByHandle({
|