swcombine.js 0.0.11 → 0.1.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.
Files changed (51) hide show
  1. package/LICENSE +5 -17
  2. package/README.md +668 -97
  3. package/dist/index.d.ts +5 -522
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +3 -0
  6. package/dist/index.js.map +23 -0
  7. package/dist/src/auth/index.d.ts +8 -0
  8. package/dist/src/auth/index.d.ts.map +1 -0
  9. package/dist/src/auth/oauth-manager.d.ts +168 -0
  10. package/dist/src/auth/oauth-manager.d.ts.map +1 -0
  11. package/dist/src/auth/oauth.d.ts +101 -0
  12. package/dist/src/auth/oauth.d.ts.map +1 -0
  13. package/dist/src/auth/scopes.d.ts +61 -0
  14. package/dist/src/auth/scopes.d.ts.map +1 -0
  15. package/dist/src/auth/types.d.ts +118 -0
  16. package/dist/src/auth/types.d.ts.map +1 -0
  17. package/dist/src/client/base-resource.d.ts +33 -0
  18. package/dist/src/client/base-resource.d.ts.map +1 -0
  19. package/dist/src/client/client.d.ts +85 -0
  20. package/dist/src/client/client.d.ts.map +1 -0
  21. package/dist/src/client/errors.d.ts +63 -0
  22. package/dist/src/client/errors.d.ts.map +1 -0
  23. package/dist/src/client/http-client.d.ts +35 -0
  24. package/dist/src/client/http-client.d.ts.map +1 -0
  25. package/dist/src/client/index.d.ts +15 -0
  26. package/dist/src/client/index.d.ts.map +1 -0
  27. package/dist/src/client/rate-limit.d.ts +12 -0
  28. package/dist/src/client/rate-limit.d.ts.map +1 -0
  29. package/dist/src/client/resources/api.d.ts +42 -0
  30. package/dist/src/client/resources/api.d.ts.map +1 -0
  31. package/dist/src/client/resources/character.d.ts +98 -0
  32. package/dist/src/client/resources/character.d.ts.map +1 -0
  33. package/dist/src/client/resources/faction.d.ts +70 -0
  34. package/dist/src/client/resources/faction.d.ts.map +1 -0
  35. package/dist/src/client/resources/index.d.ts +8 -0
  36. package/dist/src/client/resources/index.d.ts.map +1 -0
  37. package/dist/src/client/resources/inventory.d.ts +205 -0
  38. package/dist/src/client/resources/inventory.d.ts.map +1 -0
  39. package/dist/src/client/types.d.ts +78 -0
  40. package/dist/src/client/types.d.ts.map +1 -0
  41. package/dist/src/index.d.ts +11 -0
  42. package/dist/src/index.d.ts.map +1 -0
  43. package/dist/src/utils/index.d.ts +6 -0
  44. package/dist/src/utils/index.d.ts.map +1 -0
  45. package/dist/src/utils/timestamp.d.ts +188 -0
  46. package/dist/src/utils/timestamp.d.ts.map +1 -0
  47. package/dist/src/utils/types.d.ts +42 -0
  48. package/dist/src/utils/types.d.ts.map +1 -0
  49. package/package.json +35 -55
  50. package/dist/index.cjs.js +0 -772
  51. package/dist/index.esm.js +0 -772
@@ -0,0 +1,168 @@
1
+ /**
2
+ * OAuth Manager for handling complete OAuth flow with token management
3
+ */
4
+ import type { OAuthConfig, StoredTokens, AuthorizationUrlParams, TokenResponse } from "./types.ts";
5
+ /**
6
+ * Token storage interface - implement this to persist tokens
7
+ */
8
+ export interface TokenStorage {
9
+ /** Get stored tokens */
10
+ get(): Promise<StoredTokens | null> | StoredTokens | null;
11
+ /** Store tokens */
12
+ set(tokens: StoredTokens): Promise<void> | void;
13
+ /** Clear stored tokens */
14
+ clear(): Promise<void> | void;
15
+ }
16
+ /**
17
+ * In-memory token storage (not persistent across restarts)
18
+ */
19
+ export declare class MemoryTokenStorage implements TokenStorage {
20
+ private tokens;
21
+ get(): StoredTokens | null;
22
+ set(tokens: StoredTokens): void;
23
+ clear(): void;
24
+ }
25
+ /**
26
+ * OAuth Manager - handles complete OAuth flow with automatic token refresh
27
+ *
28
+ * Can be used in two modes:
29
+ * 1. Full mode (with storage): Complete OAuth flow with token persistence
30
+ * 2. Utility mode (without storage): Generate auth URLs and manually refresh tokens
31
+ *
32
+ * @example Full mode with storage
33
+ * ```ts
34
+ * const oauth = new OAuthManager(
35
+ * {
36
+ * clientId: "your-client-id",
37
+ * clientSecret: "your-client-secret",
38
+ * redirectUri: "https://example.com/callback",
39
+ * defaultScopes: [ScopeKey.CharacterRead, ScopeKey.FactionMembers],
40
+ * },
41
+ * storage // TokenStorage instance
42
+ * );
43
+ *
44
+ * // 1. Generate authorization URL
45
+ * const authUrl = oauth.getAuthorizationUrl({
46
+ * state: "random-state",
47
+ * accessType: "offline", // Get refresh token
48
+ * });
49
+ *
50
+ * // 2. After user authorizes and returns with code
51
+ * await oauth.handleCallback("authorization-code");
52
+ *
53
+ * // 3. Get valid access token (auto-refreshes if needed)
54
+ * const token = await oauth.getAccessToken();
55
+ *
56
+ * // 4. Use token in API calls
57
+ * // ...
58
+ *
59
+ * // 5. Revoke when done
60
+ * await oauth.revoke();
61
+ * ```
62
+ *
63
+ * @example Utility mode without storage
64
+ * ```ts
65
+ * const oauth = new OAuthManager({
66
+ * clientId: "your-client-id",
67
+ * clientSecret: "your-client-secret",
68
+ * redirectUri: "https://example.com/callback",
69
+ * });
70
+ *
71
+ * // Generate auth URL
72
+ * const authUrl = oauth.getAuthorizationUrl({ scopes: [...] });
73
+ *
74
+ * // Manually refresh a token
75
+ * const tokens = await oauth.refreshAccessToken(refreshToken);
76
+ * ```
77
+ */
78
+ export declare class OAuthManager {
79
+ private config;
80
+ private storage;
81
+ constructor(config: OAuthConfig, storage?: TokenStorage);
82
+ /**
83
+ * Generate authorization URL to redirect users to
84
+ *
85
+ * @param options - Optional parameters (scopes, state, accessType, etc.)
86
+ * @returns Authorization URL
87
+ */
88
+ getAuthorizationUrl(options?: Partial<Omit<AuthorizationUrlParams, "clientId" | "redirectUri">>): string;
89
+ /**
90
+ * Handle OAuth callback by exchanging code for tokens
91
+ *
92
+ * Requires storage to be configured.
93
+ *
94
+ * @param code - Authorization code from callback
95
+ * @returns Token response
96
+ * @throws {SWCOAuthError} If storage is not configured
97
+ */
98
+ handleCallback(code: string): Promise<TokenResponse>;
99
+ /**
100
+ * Get a valid access token, automatically refreshing if expired
101
+ *
102
+ * Requires storage to be configured.
103
+ *
104
+ * @returns Current access token
105
+ * @throws {SWCOAuthError} If storage is not configured, no tokens are stored, or refresh fails
106
+ */
107
+ getAccessToken(): Promise<string>;
108
+ /**
109
+ * Manually refresh an access token using a refresh token
110
+ *
111
+ * This is a utility method that doesn't require storage. Useful for
112
+ * manually managing tokens or refreshing tokens obtained elsewhere.
113
+ *
114
+ * @param refreshToken - The refresh token to use
115
+ * @returns New token response with fresh access token
116
+ * @throws {SWCOAuthError} If refresh fails
117
+ */
118
+ refreshAccessToken(refreshToken: string): Promise<TokenResponse>;
119
+ /**
120
+ * Check if user is authenticated (has valid or refreshable tokens)
121
+ *
122
+ * Requires storage to be configured.
123
+ *
124
+ * @throws {SWCOAuthError} If storage is not configured
125
+ */
126
+ isAuthenticated(): Promise<boolean>;
127
+ /**
128
+ * Get stored tokens (if any)
129
+ *
130
+ * Requires storage to be configured.
131
+ *
132
+ * @throws {SWCOAuthError} If storage is not configured
133
+ */
134
+ getStoredTokens(): Promise<StoredTokens | null>;
135
+ /**
136
+ * Manually set tokens (useful for restoring from external storage)
137
+ *
138
+ * Requires storage to be configured.
139
+ *
140
+ * @throws {SWCOAuthError} If storage is not configured
141
+ */
142
+ setTokens(tokens: StoredTokens): Promise<void>;
143
+ /**
144
+ * Revoke the current refresh token and clear stored tokens
145
+ *
146
+ * Requires storage to be configured.
147
+ *
148
+ * @throws {SWCOAuthError} If storage is not configured
149
+ */
150
+ revoke(): Promise<void>;
151
+ /**
152
+ * Clear stored tokens without revoking them
153
+ *
154
+ * Requires storage to be configured.
155
+ *
156
+ * @throws {SWCOAuthError} If storage is not configured
157
+ */
158
+ logout(): Promise<void>;
159
+ /**
160
+ * Store tokens with expiration calculation
161
+ */
162
+ private storeTokens;
163
+ /**
164
+ * Check if storage is configured and throw error if not
165
+ */
166
+ private requireStorage;
167
+ }
168
+ //# sourceMappingURL=oauth-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-manager.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth-manager.ts"],"names":[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,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAazC;;;;;;OAMG;IACG,eAAe,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAKrD;;;;;;OAMG;IACG,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpD;;;;;;OAMG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB7B;;;;;;OAMG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAK7B;;OAEG;YACW,WAAW;IAazB;;OAEG;IACH,OAAO,CAAC,cAAc;CASvB"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * OAuth 2.0 implementation for SWC Combine API
3
+ *
4
+ * Key quirks:
5
+ * - Uses "Authorization: OAuth TOKEN" instead of "Bearer"
6
+ * - Refresh tokens only returned on first exchange with access_type=offline
7
+ * - Consent is persisted after initial grant
8
+ */
9
+ import type { AuthorizationUrlParams, TokenExchangeParams, TokenRefreshParams, TokenResponse, OAuthError, TokenRevokeParams } from "./types.ts";
10
+ /**
11
+ * SWC Combine OAuth error
12
+ */
13
+ export declare class SWCOAuthError extends Error {
14
+ code: string;
15
+ description?: string | undefined;
16
+ constructor(message: string, code: string, description?: string | undefined);
17
+ static fromResponse(error: OAuthError): SWCOAuthError;
18
+ }
19
+ /**
20
+ * Generate the OAuth authorization URL
21
+ *
22
+ * @param params - Authorization URL parameters
23
+ * @returns The complete authorization URL to redirect users to
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const url = generateAuthorizationUrl({
28
+ * clientId: "your-client-id",
29
+ * redirectUri: "https://example.com/callback",
30
+ * scopes: [ScopeKey.CharacterRead, ScopeKey.FactionMembers],
31
+ * state: "random-state-string",
32
+ * accessType: "offline", // To get refresh token
33
+ * });
34
+ *
35
+ * // Redirect user to this URL
36
+ * window.location.href = url;
37
+ * ```
38
+ */
39
+ export declare function generateAuthorizationUrl(params: AuthorizationUrlParams): string;
40
+ /**
41
+ * Exchange authorization code for access token
42
+ *
43
+ * @param params - Token exchange parameters
44
+ * @returns Token response with access_token and optional refresh_token
45
+ * @throws {SWCOAuthError} If the exchange fails
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * // After user is redirected back with code
50
+ * const tokens = await exchangeCodeForToken({
51
+ * code: "authorization-code-from-callback",
52
+ * clientId: "your-client-id",
53
+ * clientSecret: "your-client-secret",
54
+ * redirectUri: "https://example.com/callback",
55
+ * });
56
+ *
57
+ * console.log(tokens.access_token);
58
+ * if (tokens.refresh_token) {
59
+ * // Store refresh token securely for future use
60
+ * }
61
+ * ```
62
+ */
63
+ export declare function exchangeCodeForToken(params: TokenExchangeParams): Promise<TokenResponse>;
64
+ /**
65
+ * Refresh an access token using a refresh token
66
+ *
67
+ * @param params - Token refresh parameters
68
+ * @returns New token response with fresh access_token
69
+ * @throws {SWCOAuthError} If the refresh fails
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * const newTokens = await refreshAccessToken({
74
+ * refreshToken: "stored-refresh-token",
75
+ * clientId: "your-client-id",
76
+ * clientSecret: "your-client-secret",
77
+ * });
78
+ *
79
+ * console.log(newTokens.access_token);
80
+ * // Note: refresh_token is NOT included in response
81
+ * ```
82
+ */
83
+ export declare function refreshAccessToken(params: TokenRefreshParams): Promise<TokenResponse>;
84
+ /**
85
+ * Revoke a token (typically a refresh token)
86
+ *
87
+ * @param params - Token revocation parameters
88
+ * @throws {SWCOAuthError} If the revocation fails
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * await revokeToken({
93
+ * token: "refresh-token-to-revoke",
94
+ * clientId: "your-client-id",
95
+ * });
96
+ *
97
+ * console.log("Token revoked successfully");
98
+ * ```
99
+ */
100
+ export declare function revokeToken(params: TokenRevokeParams): Promise<void>;
101
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAMpB;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAG7B,IAAI,EAAE,MAAM;IACZ,WAAW,CAAC,EAAE,MAAM;gBAF3B,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,YAAA;IAM7B,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa;CAOtD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,sBAAsB,GAC7B,MAAM,CAuBR;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,aAAa,CAAC,CAwBxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,aAAa,CAAC,CAuBxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAa1E"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * OAuth scopes for SWC Combine API
3
+ *
4
+ * Scopes define what permissions your application has access to.
5
+ * Many scopes inherit from others, granting all permissions of their parent scopes.
6
+ */
7
+ /**
8
+ * All available OAuth scope keys as string literals
9
+ */
10
+ export type ScopeKey = "character_auth" | "character_read" | "character_stats" | "character_privileges" | "character_skills" | "character_credits" | "character_credits_write" | "character_force" | "character_location" | "character_events" | "character_all" | "messages_read" | "messages_send" | "messages_delete" | "messages_all" | "personal_inv_overview" | "personal_inv_ships_read" | "personal_inv_ships_rename" | "personal_inv_ships_assign" | "personal_inv_ships_makeover" | "personal_inv_ships_tags_read" | "personal_inv_ships_tags_write" | "personal_inv_ships_all" | "personal_inv_vehicles_read" | "personal_inv_vehicles_rename" | "personal_inv_vehicles_assign" | "personal_inv_vehicles_makeover" | "personal_inv_vehicles_tags_read" | "personal_inv_vehicles_tags_write" | "personal_inv_vehicles_all" | "personal_inv_stations_read" | "personal_inv_stations_rename" | "personal_inv_stations_assign" | "personal_inv_stations_makeover" | "personal_inv_stations_tags_read" | "personal_inv_stations_tags_write" | "personal_inv_stations_all" | "personal_inv_cities_read" | "personal_inv_cities_rename" | "personal_inv_cities_assign" | "personal_inv_cities_makeover" | "personal_inv_cities_tags_read" | "personal_inv_cities_tags_write" | "personal_inv_cities_all" | "personal_inv_facilities_read" | "personal_inv_facilities_rename" | "personal_inv_facilities_assign" | "personal_inv_facilities_makeover" | "personal_inv_facilities_tags_read" | "personal_inv_facilities_tags_write" | "personal_inv_facilities_all" | "personal_inv_planets_read" | "personal_inv_planets_assign" | "personal_inv_planets_tags_read" | "personal_inv_planets_tags_write" | "personal_inv_planets_all" | "personal_inv_items_read" | "personal_inv_items_rename" | "personal_inv_items_assign" | "personal_inv_items_makeover" | "personal_inv_items_tags_read" | "personal_inv_items_tags_write" | "personal_inv_items_all" | "personal_inv_npcs_read" | "personal_inv_npcs_assign" | "personal_inv_npcs_makeover" | "personal_inv_npcs_tags_read" | "personal_inv_npcs_tags_write" | "personal_inv_npcs_all" | "personal_inv_droids_read" | "personal_inv_droids_rename" | "personal_inv_droids_assign" | "personal_inv_droids_makeover" | "personal_inv_droids_tags_read" | "personal_inv_droids_tags_write" | "personal_inv_droids_all" | "personal_inv_materials_read" | "personal_inv_materials_rename" | "personal_inv_materials_makeover" | "personal_inv_materials_tags_read" | "personal_inv_materials_tags_write" | "personal_inv_materials_all" | "personal_inv_creatures_read" | "personal_inv_creatures_rename" | "personal_inv_creatures_assign" | "personal_inv_creatures_makeover" | "personal_inv_creatures_tags_read" | "personal_inv_creatures_tags_write" | "personal_inv_creatures_all" | "faction_inv_overview" | "faction_inv_ships_read" | "faction_inv_ships_rename" | "faction_inv_ships_assign" | "faction_inv_ships_makeover" | "faction_inv_ships_tags_read" | "faction_inv_ships_tags_write" | "faction_inv_ships_all" | "faction_inv_vehicles_read" | "faction_inv_vehicles_rename" | "faction_inv_vehicles_assign" | "faction_inv_vehicles_makeover" | "faction_inv_vehicles_tags_read" | "faction_inv_vehicles_tags_write" | "faction_inv_vehicles_all" | "faction_inv_stations_read" | "faction_inv_stations_rename" | "faction_inv_stations_assign" | "faction_inv_stations_makeover" | "faction_inv_stations_tags_read" | "faction_inv_stations_tags_write" | "faction_inv_stations_all" | "faction_inv_cities_read" | "faction_inv_cities_rename" | "faction_inv_cities_assign" | "faction_inv_cities_makeover" | "faction_inv_cities_tags_read" | "faction_inv_cities_tags_write" | "faction_inv_cities_all" | "faction_inv_facilities_read" | "faction_inv_facilities_rename" | "faction_inv_facilities_assign" | "faction_inv_facilities_makeover" | "faction_inv_facilities_tags_read" | "faction_inv_facilities_tags_write" | "faction_inv_facilities_all" | "faction_inv_planets_read" | "faction_inv_planets_assign" | "faction_inv_planets_tags_read" | "faction_inv_planets_tags_write" | "faction_inv_planets_all" | "faction_inv_items_read" | "faction_inv_items_rename" | "faction_inv_items_assign" | "faction_inv_items_makeover" | "faction_inv_items_tags_read" | "faction_inv_items_tags_write" | "faction_inv_items_all" | "faction_inv_npcs_read" | "faction_inv_npcs_assign" | "faction_inv_npcs_makeover" | "faction_inv_npcs_tags_read" | "faction_inv_npcs_tags_write" | "faction_inv_npcs_all" | "faction_inv_droids_read" | "faction_inv_droids_rename" | "faction_inv_droids_assign" | "faction_inv_droids_makeover" | "faction_inv_droids_tags_read" | "faction_inv_droids_tags_write" | "faction_inv_droids_all" | "faction_inv_materials_read" | "faction_inv_materials_rename" | "faction_inv_materials_makeover" | "faction_inv_materials_tags_read" | "faction_inv_materials_tags_write" | "faction_inv_materials_all" | "faction_inv_creatures_read" | "faction_inv_creatures_rename" | "faction_inv_creatures_assign" | "faction_inv_creatures_makeover" | "faction_inv_creatures_tags_read" | "faction_inv_creatures_tags_write" | "faction_inv_creatures_all" | "faction_read" | "faction_members" | "faction_stocks" | "faction_credits_read" | "faction_credits_write" | "faction_budgets_read" | "faction_budgets_write" | "faction_datacards_read" | "faction_datacards_write" | "faction_all";
11
+ /**
12
+ * Scope information
13
+ */
14
+ export interface Scope {
15
+ /** Scope name */
16
+ name: ScopeKey;
17
+ /** Human-readable description of what this scope allows */
18
+ description: string;
19
+ /** Scopes that this scope inherits from */
20
+ inherits: ScopeKey[];
21
+ }
22
+ /**
23
+ * Record of all available scopes with their metadata
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const scope = Scopes['character_read'];
28
+ * console.log(scope.description); // "Read basic character information..."
29
+ * console.log(scope.inherits); // []
30
+ * ```
31
+ */
32
+ export declare const Scopes: Record<ScopeKey, Scope>;
33
+ /**
34
+ * Array of all scope keys for iteration
35
+ */
36
+ export declare const ALL_SCOPE_KEYS: ScopeKey[];
37
+ /**
38
+ * Check if a string is a valid scope key
39
+ */
40
+ export declare function isValidScope(scope: string): scope is ScopeKey;
41
+ /**
42
+ * Convert an array of ScopeKeys to a space-delimited string for OAuth
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const scopeString = scopesToString(['character_read', 'faction_members']);
47
+ * // Returns: "character_read faction_members"
48
+ * ```
49
+ */
50
+ export declare function scopesToString(scopes: ScopeKey[]): string;
51
+ /**
52
+ * Parse a space-delimited scope string into an array of ScopeKeys
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const scopes = scopesFromString("character_read faction_members");
57
+ * // Returns: ['character_read', 'faction_members']
58
+ * ```
59
+ */
60
+ export declare function scopesFromString(scopeString: string): ScopeKey[];
61
+ //# sourceMappingURL=scopes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../../src/auth/scopes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MA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2BAA2B,GAE3B,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,sBAAsB,GACtB,uBAAuB,GACvB,sBAAsB,GACtB,uBAAuB,GACvB,wBAAwB,GACxB,yBAAyB,GACzB,aAAa,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,iBAAiB;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,KAAK,CA4+C1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,EAAsC,CAAC;AAE5E;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ,CAE7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAEzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,EAAE,CAIhE"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * OAuth 2.0 types for SWC Combine API
3
+ */
4
+ import type { ScopeKey } from "./scopes.ts";
5
+ /**
6
+ * Access type for OAuth authorization
7
+ * - online: Access token only (default)
8
+ * - offline: Includes refresh token for long-lived access
9
+ */
10
+ export type AccessType = "online" | "offline";
11
+ /**
12
+ * Parameters for generating the OAuth authorization URL
13
+ */
14
+ export interface AuthorizationUrlParams {
15
+ /** Your registered application client ID */
16
+ clientId: string;
17
+ /** Registered redirect URI where the authorization response will be sent */
18
+ redirectUri: string;
19
+ /** Array of permission scopes the application requests */
20
+ scopes: ScopeKey[];
21
+ /** Custom value returned in response for state management (CSRF protection) */
22
+ state?: string;
23
+ /** Access type: 'online' (default) or 'offline' for refresh token */
24
+ accessType?: AccessType;
25
+ /** Set to 'yes' to renew previously granted permissions not in current scope */
26
+ renewPreviouslyGranted?: boolean;
27
+ }
28
+ /**
29
+ * Authorization response from the OAuth callback
30
+ */
31
+ export interface AuthorizationResponse {
32
+ /** Authorization code to exchange for access token */
33
+ code?: string;
34
+ /** Error code if authorization was denied */
35
+ error?: string;
36
+ /** State value passed in the authorization request */
37
+ state?: string;
38
+ }
39
+ /**
40
+ * Parameters for exchanging authorization code for tokens
41
+ */
42
+ export interface TokenExchangeParams {
43
+ /** Authorization code from the callback */
44
+ code: string;
45
+ /** Your application's client ID */
46
+ clientId: string;
47
+ /** Your application's client secret */
48
+ clientSecret: string;
49
+ /** Redirect URI used in authorization (must match exactly) */
50
+ redirectUri: string;
51
+ }
52
+ /**
53
+ * Parameters for refreshing an access token
54
+ */
55
+ export interface TokenRefreshParams {
56
+ /** Refresh token obtained during initial token exchange */
57
+ refreshToken: string;
58
+ /** Your application's client ID */
59
+ clientId: string;
60
+ /** Your application's client secret */
61
+ clientSecret: string;
62
+ }
63
+ /**
64
+ * Successful token response from the API
65
+ */
66
+ export interface TokenResponse {
67
+ /** Bearer token for API calls */
68
+ access_token: string;
69
+ /** Token lifetime in seconds */
70
+ expires_in: number;
71
+ /** Refresh token (only present if access_type=offline was used) */
72
+ refresh_token?: string;
73
+ /** Token type (always "Bearer") */
74
+ token_type?: string;
75
+ }
76
+ /**
77
+ * Error response from OAuth endpoints
78
+ */
79
+ export interface OAuthError {
80
+ /** Error code */
81
+ error: string;
82
+ /** Human-readable error description */
83
+ error_description?: string;
84
+ }
85
+ /**
86
+ * Parameters for revoking a token
87
+ */
88
+ export interface TokenRevokeParams {
89
+ /** The token to revoke (typically refresh_token) */
90
+ token: string;
91
+ /** Your application's client ID */
92
+ clientId: string;
93
+ }
94
+ /**
95
+ * Configuration for OAuth client
96
+ */
97
+ export interface OAuthConfig {
98
+ /** Your application's client ID */
99
+ clientId: string;
100
+ /** Your application's client secret */
101
+ clientSecret: string;
102
+ /** Registered redirect URI */
103
+ redirectUri: string;
104
+ /** Default scopes to request */
105
+ defaultScopes?: ScopeKey[];
106
+ }
107
+ /**
108
+ * Stored token information
109
+ */
110
+ export interface StoredTokens {
111
+ /** Access token */
112
+ accessToken: string;
113
+ /** Refresh token (if available) */
114
+ refreshToken?: string;
115
+ /** Expiration timestamp (milliseconds since epoch) */
116
+ expiresAt: number;
117
+ }
118
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/auth/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,gFAAgF;IAChF,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,iCAAiC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Base class for all API resource classes
3
+ */
4
+ import type { SWCClient } from "./client.ts";
5
+ import type { RequestOptions } from "./types.ts";
6
+ /**
7
+ * Base resource class that provides HTTP methods for child resources
8
+ */
9
+ export declare abstract class BaseResource {
10
+ protected readonly client: SWCClient;
11
+ constructor(client: SWCClient);
12
+ /**
13
+ * Make a GET request
14
+ */
15
+ protected request_get(endpoint: string, options?: RequestOptions): Promise<any>;
16
+ /**
17
+ * Make a POST request
18
+ */
19
+ protected request_post(endpoint: string, body?: any, options?: RequestOptions): Promise<any>;
20
+ /**
21
+ * Make a PUT request
22
+ */
23
+ protected request_put(endpoint: string, body?: any, options?: RequestOptions): Promise<any>;
24
+ /**
25
+ * Make a PATCH request
26
+ */
27
+ protected request_patch(endpoint: string, body?: any, options?: RequestOptions): Promise<any>;
28
+ /**
29
+ * Make a DELETE request
30
+ */
31
+ protected request_delete(endpoint: string, body?: any, options?: RequestOptions): Promise<any>;
32
+ }
33
+ //# sourceMappingURL=base-resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-resource.d.ts","sourceRoot":"","sources":["../../../src/client/base-resource.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,8BAAsB,YAAY;IACpB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS;gBAAjB,MAAM,EAAE,SAAS;IAEhD;;OAEG;cACa,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAQrF;;OAEG;cACa,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,GAAG,EACV,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,GAAG,CAAC;IASf;;OAEG;cACa,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,GAAG,EACV,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,GAAG,CAAC;IASf;;OAEG;cACa,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,GAAG,EACV,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,GAAG,CAAC;IASf;;OAEG;cACa,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,GAAG,EACV,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,GAAG,CAAC;CAQhB"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Main SWC API Client
3
+ */
4
+ import type { OAuthManager } from "../auth/oauth-manager.ts";
5
+ import type { RequestConfig, SWCResponse } from "./types.ts";
6
+ import { ApiResource, CharacterResource, FactionResource, InventoryResource } from "./resources/index.ts";
7
+ /**
8
+ * Configuration options for SWCClient
9
+ */
10
+ export interface SWCClientConfig {
11
+ /** Authentication: either an OAuthManager instance or a direct access token string */
12
+ auth: OAuthManager | string;
13
+ /** Base URL for the API (defaults to SWC API v2.0) */
14
+ baseUrl?: string;
15
+ }
16
+ /**
17
+ * Main client for interacting with the Star Wars Combine API
18
+ *
19
+ * @example With OAuthManager
20
+ * ```typescript
21
+ * import { OAuthManager, SWCClient } from "swcombine.js";
22
+ *
23
+ * const oauth = new OAuthManager(
24
+ * {
25
+ * clientId: "your-client-id",
26
+ * clientSecret: "your-client-secret",
27
+ * redirectUri: "https://example.com/callback",
28
+ * },
29
+ * storage
30
+ * );
31
+ *
32
+ * const client = new SWCClient({ auth: oauth });
33
+ *
34
+ * // Access resources
35
+ * const character = await client.character.get();
36
+ * const skills = await client.character.skills.get();
37
+ * const faction = await client.faction.get();
38
+ * ```
39
+ *
40
+ * @example With direct access token
41
+ * ```typescript
42
+ * import { SWCClient } from "swcombine.js";
43
+ *
44
+ * const client = new SWCClient({ auth: "your-access-token" });
45
+ *
46
+ * // Access resources (token won't auto-refresh)
47
+ * const character = await client.character.get();
48
+ * ```
49
+ */
50
+ export declare class SWCClient {
51
+ private readonly httpClient;
52
+ /** API utility endpoints */
53
+ readonly api: ApiResource;
54
+ /** Character resource */
55
+ readonly character: CharacterResource;
56
+ /** Faction resource */
57
+ readonly faction: FactionResource;
58
+ /** Inventory resource */
59
+ readonly inventory: InventoryResource;
60
+ /**
61
+ * Create a new SWC API client
62
+ *
63
+ * @param oauth - OAuth manager instance for authentication (deprecated, use config object)
64
+ * @param baseUrl - Optional base URL (defaults to https://www.swcombine.com/ws/v2.0)
65
+ * @deprecated Use config object instead: `new SWCClient({ auth: oauth })`
66
+ */
67
+ constructor(oauth: OAuthManager, baseUrl?: string);
68
+ /**
69
+ * Create a new SWC API client
70
+ *
71
+ * @param config - Client configuration
72
+ */
73
+ constructor(config: SWCClientConfig);
74
+ /**
75
+ * Internal method used by resources to make requests
76
+ * @internal
77
+ */
78
+ request(config: RequestConfig): Promise<any>;
79
+ /**
80
+ * Internal method used by resources to make requests with full response
81
+ * @internal
82
+ */
83
+ requestWithResponse(config: RequestConfig): Promise<SWCResponse>;
84
+ }
85
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sFAAsF;IACtF,IAAI,EAAE,YAAY,GAAG,MAAM,CAAC;IAC5B,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAkBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC,4BAA4B;IAC5B,SAAgB,GAAG,EAAE,WAAW,CAAC;IAEjC,yBAAyB;IACzB,SAAgB,SAAS,EAAE,iBAAiB,CAAC;IAE7C,uBAAuB;IACvB,SAAgB,OAAO,EAAE,eAAe,CAAC;IAEzC,yBAAyB;IACzB,SAAgB,SAAS,EAAE,iBAAiB,CAAC;IAE7C;;;;;;OAMG;gBACS,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,MAAM;IAEjD;;;;OAIG;gBACS,MAAM,EAAE,eAAe;IAkCnC;;;OAGG;IACG,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC;IAKlD;;;OAGG;IACG,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC;CAGvE"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Error classes for SWC API client
3
+ */
4
+ import type { RateLimitInfo } from "./types.ts";
5
+ /**
6
+ * Base error class for all SWC client errors
7
+ */
8
+ export declare class SWCError extends Error {
9
+ readonly cause?: Error | undefined;
10
+ constructor(message: string, cause?: Error | undefined);
11
+ }
12
+ /**
13
+ * Network-level errors (fetch failures, timeouts, etc.)
14
+ */
15
+ export declare class NetworkError extends SWCError {
16
+ constructor(message: string, cause?: Error);
17
+ }
18
+ /**
19
+ * Base class for API errors (4xx, 5xx status codes)
20
+ */
21
+ export declare class APIError extends SWCError {
22
+ readonly statusCode: number;
23
+ readonly response?: any | undefined;
24
+ constructor(message: string, statusCode: number, response?: any | undefined);
25
+ }
26
+ /**
27
+ * Authentication error (401 Unauthorized)
28
+ */
29
+ export declare class AuthenticationError extends APIError {
30
+ constructor(message: string, response?: any);
31
+ }
32
+ /**
33
+ * Authorization error (403 Forbidden)
34
+ */
35
+ export declare class AuthorizationError extends APIError {
36
+ constructor(message: string, response?: any);
37
+ }
38
+ /**
39
+ * Validation error (400 Bad Request)
40
+ */
41
+ export declare class ValidationError extends APIError {
42
+ constructor(message: string, response?: any);
43
+ }
44
+ /**
45
+ * Rate limit error (429 Too Many Requests)
46
+ */
47
+ export declare class RateLimitError extends APIError {
48
+ readonly rateLimit: RateLimitInfo;
49
+ constructor(message: string, rateLimit: RateLimitInfo, response?: any);
50
+ }
51
+ /**
52
+ * Resource not found error (404 Not Found)
53
+ */
54
+ export declare class NotFoundError extends APIError {
55
+ constructor(message: string, response?: any);
56
+ }
57
+ /**
58
+ * Server error (5xx status codes)
59
+ */
60
+ export declare class ServerError extends APIError {
61
+ constructor(message: string, statusCode: number, response?: any);
62
+ }
63
+ //# sourceMappingURL=errors.d.ts.map