berget 1.1.0 → 1.2.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/dist/index.js +47 -1
- package/dist/package.json +35 -0
- package/dist/src/client.js +24 -7
- package/dist/src/commands/api-keys.js +13 -7
- package/dist/src/commands/chat.js +84 -18
- package/dist/src/services/api-key-service.js +6 -16
- package/dist/src/services/chat-service.js +159 -36
- package/dist/src/utils/default-api-key.js +131 -5
- package/dist/src/utils/error-handler.js +4 -4
- package/index.ts +52 -1
- package/package.json +3 -2
- package/src/client.ts +23 -6
- package/src/commands/api-keys.ts +17 -7
- package/src/commands/chat.ts +122 -22
- package/src/services/api-key-service.ts +12 -20
- package/src/services/chat-service.ts +158 -40
- package/src/types/api.d.ts +203 -9
- package/src/types/json.d.ts +4 -0
- package/src/utils/default-api-key.ts +141 -6
- package/src/utils/error-handler.ts +4 -4
- package/tsconfig.json +1 -1
|
@@ -49,21 +49,133 @@ export class ChatService {
|
|
|
49
49
|
*/
|
|
50
50
|
public async createCompletion(options: ChatCompletionOptions): Promise<any> {
|
|
51
51
|
try {
|
|
52
|
+
console.log(chalk.yellow('DEBUG: Starting createCompletion method'))
|
|
53
|
+
|
|
54
|
+
// Check if options is defined
|
|
55
|
+
if (!options) {
|
|
56
|
+
console.log(chalk.red('ERROR: options is undefined'))
|
|
57
|
+
throw new Error('Chat completion options are undefined')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Log the raw options object
|
|
61
|
+
console.log(chalk.yellow('DEBUG: Raw options:'), typeof options, options ? 'defined' : 'undefined')
|
|
62
|
+
|
|
52
63
|
const headers: Record<string, string> = {}
|
|
53
64
|
|
|
54
65
|
// Check if debug is enabled
|
|
55
66
|
const isDebug = process.argv.includes('--debug')
|
|
56
67
|
|
|
68
|
+
if (isDebug) {
|
|
69
|
+
console.log(chalk.yellow('DEBUG: Starting createCompletion with options:'))
|
|
70
|
+
try {
|
|
71
|
+
console.log(chalk.yellow(JSON.stringify({
|
|
72
|
+
...options,
|
|
73
|
+
apiKey: options.apiKey ? '***' : undefined,
|
|
74
|
+
messages: options.messages ? `${options.messages.length} messages` : undefined
|
|
75
|
+
}, null, 2)))
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.log(chalk.red('ERROR: Failed to stringify options:'), error)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Create a copy of options to avoid modifying the original
|
|
82
|
+
const optionsCopy = { ...options }
|
|
83
|
+
|
|
84
|
+
if (isDebug) {
|
|
85
|
+
console.log(chalk.yellow('DEBUG: Checking for API key'))
|
|
86
|
+
console.log(chalk.yellow(`DEBUG: optionsCopy.apiKey exists: ${!!optionsCopy.apiKey}`))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Check for environment variables first - prioritize this over everything else
|
|
90
|
+
const envApiKey = process.env.BERGET_API_KEY;
|
|
91
|
+
if (envApiKey) {
|
|
92
|
+
if (isDebug) {
|
|
93
|
+
console.log(chalk.yellow('DEBUG: Using API key from BERGET_API_KEY environment variable'));
|
|
94
|
+
}
|
|
95
|
+
optionsCopy.apiKey = envApiKey;
|
|
96
|
+
}
|
|
97
|
+
// Only try to get the default API key if no API key is provided and no env var is set
|
|
98
|
+
else if (!optionsCopy.apiKey) {
|
|
99
|
+
if (isDebug) {
|
|
100
|
+
console.log(chalk.yellow('DEBUG: No API key provided, trying to get default'))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
// Import the DefaultApiKeyManager directly
|
|
105
|
+
if (isDebug) {
|
|
106
|
+
console.log(chalk.yellow('DEBUG: Importing DefaultApiKeyManager'))
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const DefaultApiKeyManager = (await import('../utils/default-api-key')).DefaultApiKeyManager;
|
|
110
|
+
const defaultApiKeyManager = DefaultApiKeyManager.getInstance();
|
|
111
|
+
|
|
112
|
+
if (isDebug) {
|
|
113
|
+
console.log(chalk.yellow('DEBUG: Got DefaultApiKeyManager instance'))
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Try to get the default API key
|
|
117
|
+
if (isDebug) {
|
|
118
|
+
console.log(chalk.yellow('DEBUG: Calling promptForDefaultApiKey'))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const defaultApiKeyData = defaultApiKeyManager.getDefaultApiKeyData();
|
|
122
|
+
const apiKey = defaultApiKeyData?.key || await defaultApiKeyManager.promptForDefaultApiKey();
|
|
123
|
+
|
|
124
|
+
if (isDebug) {
|
|
125
|
+
console.log(chalk.yellow(`DEBUG: Default API key data exists: ${!!defaultApiKeyData}`))
|
|
126
|
+
console.log(chalk.yellow(`DEBUG: promptForDefaultApiKey returned: ${apiKey ? 'a key' : 'null'}`))
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (apiKey) {
|
|
130
|
+
if (isDebug) {
|
|
131
|
+
console.log(chalk.yellow('DEBUG: Using API key from default API key manager'));
|
|
132
|
+
}
|
|
133
|
+
optionsCopy.apiKey = apiKey;
|
|
134
|
+
} else {
|
|
135
|
+
console.log(chalk.yellow('No API key available. You need to either:'));
|
|
136
|
+
console.log(chalk.yellow('1. Create an API key with: berget api-keys create --name "My Key"'));
|
|
137
|
+
console.log(chalk.yellow('2. Set a default API key with: berget api-keys set-default <id>'));
|
|
138
|
+
console.log(chalk.yellow('3. Provide an API key with the --api-key option'));
|
|
139
|
+
console.log(chalk.yellow('4. Set the BERGET_API_KEY environment variable'));
|
|
140
|
+
console.log(chalk.yellow('\nExample:'));
|
|
141
|
+
console.log(chalk.yellow(' export BERGET_API_KEY=your_api_key_here'));
|
|
142
|
+
console.log(chalk.yellow(' # or for a single command:'));
|
|
143
|
+
console.log(chalk.yellow(' BERGET_API_KEY=your_api_key_here berget chat run google/gemma-3-27b-it'));
|
|
144
|
+
throw new Error('No API key provided and no default API key set');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Set the API key in the options
|
|
148
|
+
if (isDebug) {
|
|
149
|
+
console.log(chalk.yellow('DEBUG: Setting API key in options'))
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Only set the API key if it's not null
|
|
153
|
+
if (apiKey) {
|
|
154
|
+
optionsCopy.apiKey = apiKey;
|
|
155
|
+
}
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.log(chalk.red('Error getting API key:'))
|
|
158
|
+
if (error instanceof Error) {
|
|
159
|
+
console.log(chalk.red(error.message))
|
|
160
|
+
}
|
|
161
|
+
console.log(chalk.yellow('Please create an API key with: berget api-keys create --name "My Key"'))
|
|
162
|
+
throw new Error('Failed to get API key')
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
57
166
|
if (isDebug) {
|
|
58
167
|
console.log(chalk.yellow('DEBUG: Chat completion options:'))
|
|
59
|
-
console.log(chalk.yellow(JSON.stringify(
|
|
168
|
+
console.log(chalk.yellow(JSON.stringify({
|
|
169
|
+
...optionsCopy,
|
|
170
|
+
apiKey: optionsCopy.apiKey ? '***' : undefined // Hide the actual API key in debug output
|
|
171
|
+
}, null, 2)))
|
|
60
172
|
}
|
|
61
173
|
|
|
62
174
|
// If an API key is provided, use it for this request
|
|
63
|
-
if (
|
|
64
|
-
headers['Authorization'] = `Bearer ${
|
|
175
|
+
if (optionsCopy.apiKey) {
|
|
176
|
+
headers['Authorization'] = `Bearer ${optionsCopy.apiKey}`
|
|
65
177
|
// Remove apiKey from options before sending to API
|
|
66
|
-
const { apiKey, ...requestOptions } =
|
|
178
|
+
const { apiKey, ...requestOptions } = optionsCopy
|
|
67
179
|
|
|
68
180
|
if (isDebug) {
|
|
69
181
|
console.log(chalk.yellow('DEBUG: Using provided API key'))
|
|
@@ -71,43 +183,45 @@ export class ChatService {
|
|
|
71
183
|
console.log(chalk.yellow(JSON.stringify(requestOptions, null, 2)))
|
|
72
184
|
}
|
|
73
185
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (isDebug) {
|
|
80
|
-
console.log(chalk.yellow('DEBUG: API response:'))
|
|
81
|
-
console.log(chalk.yellow(JSON.stringify({ data, error }, null, 2)))
|
|
186
|
+
try {
|
|
187
|
+
const response = await this.client.POST('/v1/chat/completions', {
|
|
188
|
+
body: requestOptions,
|
|
189
|
+
headers
|
|
190
|
+
})
|
|
82
191
|
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const { data, error } = await this.client.POST('/v1/chat/completions', {
|
|
97
|
-
body: options
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
if (isDebug) {
|
|
101
|
-
console.log(chalk.yellow('DEBUG: API response:'))
|
|
102
|
-
console.log(chalk.yellow(JSON.stringify({ data, error }, null, 2)))
|
|
192
|
+
// Check if response has an error property
|
|
193
|
+
const responseAny = response as any;
|
|
194
|
+
if (responseAny && responseAny.error)
|
|
195
|
+
throw new Error(JSON.stringify(responseAny.error))
|
|
196
|
+
|
|
197
|
+
if (isDebug) {
|
|
198
|
+
console.log(chalk.yellow('DEBUG: API response:'))
|
|
199
|
+
console.log(chalk.yellow(JSON.stringify(response, null, 2)))
|
|
200
|
+
|
|
201
|
+
// Output the complete response data for debugging
|
|
202
|
+
console.log(chalk.yellow('DEBUG: Complete response data:'))
|
|
203
|
+
console.log(chalk.yellow(JSON.stringify(response.data, null, 2)))
|
|
204
|
+
}
|
|
103
205
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
206
|
+
return response.data
|
|
207
|
+
} catch (requestError) {
|
|
208
|
+
if (process.argv.includes('--debug')) {
|
|
209
|
+
console.log(chalk.red(`DEBUG: Request error: ${requestError instanceof Error ? requestError.message : String(requestError)}`))
|
|
210
|
+
}
|
|
211
|
+
throw requestError
|
|
107
212
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
213
|
+
} else {
|
|
214
|
+
// We've exhausted all options for getting an API key
|
|
215
|
+
console.log(chalk.yellow('No API key available. You need to either:'));
|
|
216
|
+
console.log(chalk.yellow('1. Create an API key with: berget api-keys create --name "My Key"'));
|
|
217
|
+
console.log(chalk.yellow('2. Set a default API key with: berget api-keys set-default <id>'));
|
|
218
|
+
console.log(chalk.yellow('3. Provide an API key with the --api-key option'));
|
|
219
|
+
console.log(chalk.yellow('4. Set the BERGET_API_KEY environment variable'));
|
|
220
|
+
console.log(chalk.yellow('\nExample:'));
|
|
221
|
+
console.log(chalk.yellow(' export BERGET_API_KEY=your_api_key_here'));
|
|
222
|
+
console.log(chalk.yellow(' # or for a single command:'));
|
|
223
|
+
console.log(chalk.yellow(' BERGET_API_KEY=your_api_key_here berget chat run google/gemma-3-27b-it'));
|
|
224
|
+
throw new Error('No API key available. Please provide an API key or set a default API key.');
|
|
111
225
|
}
|
|
112
226
|
} catch (error) {
|
|
113
227
|
// Improved error handling
|
|
@@ -137,9 +251,13 @@ export class ChatService {
|
|
|
137
251
|
*/
|
|
138
252
|
public async listModels(apiKey?: string): Promise<any> {
|
|
139
253
|
try {
|
|
140
|
-
|
|
254
|
+
// Check for environment variable first, then fallback to provided API key
|
|
255
|
+
const envApiKey = process.env.BERGET_API_KEY;
|
|
256
|
+
const effectiveApiKey = envApiKey || apiKey;
|
|
257
|
+
|
|
258
|
+
if (effectiveApiKey) {
|
|
141
259
|
const headers = {
|
|
142
|
-
'Authorization': `Bearer ${
|
|
260
|
+
'Authorization': `Bearer ${effectiveApiKey}`
|
|
143
261
|
}
|
|
144
262
|
|
|
145
263
|
const { data, error } = await this.client.GET('/v1/models', { headers })
|
package/src/types/api.d.ts
CHANGED
|
@@ -14,6 +14,20 @@ export interface paths {
|
|
|
14
14
|
/**
|
|
15
15
|
* List all API keys
|
|
16
16
|
* @description Lists all API keys for the authenticated user's organization.
|
|
17
|
+
*
|
|
18
|
+
* ## Using the CLI
|
|
19
|
+
*
|
|
20
|
+
* You can also manage API keys using our CLI tool:
|
|
21
|
+
* ```
|
|
22
|
+
* # Login first (if you haven't already)
|
|
23
|
+
* npx berget auth login
|
|
24
|
+
*
|
|
25
|
+
* # List all API keys
|
|
26
|
+
* npx berget api-keys list
|
|
27
|
+
*
|
|
28
|
+
* # Create a new API key
|
|
29
|
+
* npx berget api-keys create --name my-api-key
|
|
30
|
+
* ```
|
|
17
31
|
*/
|
|
18
32
|
get: {
|
|
19
33
|
responses: {
|
|
@@ -36,6 +50,17 @@ export interface paths {
|
|
|
36
50
|
/**
|
|
37
51
|
* Create a new API key
|
|
38
52
|
* @description Creates a new API key for the authenticated user's organization. The full API key is only returned once at creation time.
|
|
53
|
+
*
|
|
54
|
+
* ## Using the CLI
|
|
55
|
+
*
|
|
56
|
+
* Creating an API key is easier with our CLI tool:
|
|
57
|
+
* ```
|
|
58
|
+
* # Login first (if you haven't already)
|
|
59
|
+
* npx berget auth login
|
|
60
|
+
*
|
|
61
|
+
* # Create a new API key
|
|
62
|
+
* npx berget api-keys create --name my-api-key
|
|
63
|
+
* ```
|
|
39
64
|
*/
|
|
40
65
|
post: {
|
|
41
66
|
requestBody: {
|
|
@@ -97,6 +122,21 @@ export interface paths {
|
|
|
97
122
|
/**
|
|
98
123
|
* Rotate an API key
|
|
99
124
|
* @description Rotates an API key by invalidating the old key and generating a new one. The new key is returned in the response and is only shown once.
|
|
125
|
+
*
|
|
126
|
+
* ## Using the CLI
|
|
127
|
+
*
|
|
128
|
+
* You can also rotate API keys using our CLI tool:
|
|
129
|
+
* ```
|
|
130
|
+
* # Login first (if you haven't already)
|
|
131
|
+
* npx berget auth login
|
|
132
|
+
*
|
|
133
|
+
* # Rotate an API key
|
|
134
|
+
* npx berget api-keys rotate --id <key-id>
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* ## Security Note
|
|
138
|
+
*
|
|
139
|
+
* When you rotate an API key, the old key becomes invalid immediately. Make sure to update any applications using the key.
|
|
100
140
|
*/
|
|
101
141
|
put: {
|
|
102
142
|
parameters: {
|
|
@@ -131,6 +171,20 @@ export interface paths {
|
|
|
131
171
|
/**
|
|
132
172
|
* Get API key usage statistics
|
|
133
173
|
* @description Returns usage statistics for a specific API key including request count, daily breakdown, model-specific usage, and token consumption.
|
|
174
|
+
*
|
|
175
|
+
* ## Using the CLI
|
|
176
|
+
*
|
|
177
|
+
* You can also view API key usage using our CLI tool:
|
|
178
|
+
* ```
|
|
179
|
+
* # Login first (if you haven't already)
|
|
180
|
+
* npx berget auth login
|
|
181
|
+
*
|
|
182
|
+
* # View usage for a specific API key
|
|
183
|
+
* npx berget api-keys usage --id <key-id>
|
|
184
|
+
*
|
|
185
|
+
* # View usage for all API keys
|
|
186
|
+
* npx berget usage
|
|
187
|
+
* ```
|
|
134
188
|
*/
|
|
135
189
|
get: {
|
|
136
190
|
parameters: {
|
|
@@ -351,13 +405,27 @@ export interface paths {
|
|
|
351
405
|
"/v1/auth/login": {
|
|
352
406
|
/**
|
|
353
407
|
* OAuth login
|
|
354
|
-
* @description Initiates OAuth login flow via Keycloak
|
|
408
|
+
* @description Initiates OAuth login flow via Keycloak.
|
|
409
|
+
*
|
|
410
|
+
* ## CLI Authentication
|
|
411
|
+
*
|
|
412
|
+
* For a simpler experience, you can use our CLI tool to authenticate:
|
|
413
|
+
* ```
|
|
414
|
+
* npx berget auth login
|
|
415
|
+
* ```
|
|
416
|
+
*
|
|
417
|
+
* After logging in, you can create an API key with:
|
|
418
|
+
* ```
|
|
419
|
+
* npx berget api-keys create --name my-api-key
|
|
420
|
+
* ```
|
|
355
421
|
*/
|
|
356
422
|
get: {
|
|
357
423
|
parameters: {
|
|
358
424
|
query?: {
|
|
359
425
|
/** @description URL to redirect to after successful login */
|
|
360
426
|
redirect_uri?: string;
|
|
427
|
+
/** @description How to return the token after successful login (default is redirect) */
|
|
428
|
+
response_type?: "redirect" | "json";
|
|
361
429
|
};
|
|
362
430
|
};
|
|
363
431
|
responses: {
|
|
@@ -389,29 +457,108 @@ export interface paths {
|
|
|
389
457
|
};
|
|
390
458
|
};
|
|
391
459
|
"/v1/auth/device": {
|
|
392
|
-
/**
|
|
460
|
+
/**
|
|
461
|
+
* Initiate device authorization flow
|
|
462
|
+
* @description Initiates the device authorization flow, returning a device code and user verification URL.
|
|
463
|
+
*
|
|
464
|
+
* ## Using the CLI
|
|
465
|
+
*
|
|
466
|
+
* The recommended way to authenticate is through our CLI tool:
|
|
467
|
+
* ```
|
|
468
|
+
* npx berget auth login
|
|
469
|
+
* ```
|
|
470
|
+
*
|
|
471
|
+
* This handles the device flow automatically and provides a better user experience.
|
|
472
|
+
*/
|
|
393
473
|
post: {
|
|
394
474
|
responses: {
|
|
395
475
|
/** @description Device authorization initiated */
|
|
396
476
|
200: {
|
|
397
|
-
content:
|
|
477
|
+
content: {
|
|
478
|
+
"application/json": components["schemas"]["DeviceAuthInitResponse"];
|
|
479
|
+
};
|
|
398
480
|
};
|
|
399
481
|
};
|
|
400
482
|
};
|
|
401
483
|
};
|
|
402
484
|
"/v1/auth/device/token": {
|
|
403
|
-
/**
|
|
485
|
+
/**
|
|
486
|
+
* Poll for device token
|
|
487
|
+
* @description Polls for the status of a device authorization flow. The client should poll this endpoint
|
|
488
|
+
* until it receives a token or an error.
|
|
489
|
+
*
|
|
490
|
+
* ## Using the CLI
|
|
491
|
+
*
|
|
492
|
+
* The recommended way to authenticate is through our CLI tool:
|
|
493
|
+
* ```
|
|
494
|
+
* npx berget auth login
|
|
495
|
+
* ```
|
|
496
|
+
*
|
|
497
|
+
* This handles the polling automatically and provides a better user experience.
|
|
498
|
+
*
|
|
499
|
+
* ## Troubleshooting
|
|
500
|
+
*
|
|
501
|
+
* - If you receive a 400 error, the device code may be invalid or expired
|
|
502
|
+
* - If you receive a 429 error, you're polling too frequently
|
|
503
|
+
* - If you receive a 500 error, there may be an issue with the authentication service
|
|
504
|
+
*/
|
|
404
505
|
post: {
|
|
405
506
|
requestBody: {
|
|
406
507
|
content: {
|
|
407
|
-
"application/json":
|
|
408
|
-
device_code?: string;
|
|
409
|
-
};
|
|
508
|
+
"application/json": components["schemas"]["DeviceAuthRequest"];
|
|
410
509
|
};
|
|
411
510
|
};
|
|
412
511
|
responses: {
|
|
413
512
|
/** @description Token returned or pending status */
|
|
414
513
|
200: {
|
|
514
|
+
content: {
|
|
515
|
+
"application/json": components["schemas"]["DeviceAuthPendingResponse"] | components["schemas"]["DeviceAuthTokenResponse"];
|
|
516
|
+
};
|
|
517
|
+
};
|
|
518
|
+
/** @description Invalid device code or expired token */
|
|
519
|
+
400: {
|
|
520
|
+
content: never;
|
|
521
|
+
};
|
|
522
|
+
/** @description Polling too frequently */
|
|
523
|
+
429: {
|
|
524
|
+
content: never;
|
|
525
|
+
};
|
|
526
|
+
/** @description Server error during authentication */
|
|
527
|
+
500: {
|
|
528
|
+
content: never;
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
};
|
|
532
|
+
};
|
|
533
|
+
"/v1/auth/refresh": {
|
|
534
|
+
/**
|
|
535
|
+
* Refresh access token
|
|
536
|
+
* @description Refreshes an access token using a refresh token. This endpoint can be used to obtain a new
|
|
537
|
+
* access token when the current one expires.
|
|
538
|
+
*
|
|
539
|
+
* ## Using the CLI
|
|
540
|
+
*
|
|
541
|
+
* The CLI tool handles token refresh automatically:
|
|
542
|
+
* ```
|
|
543
|
+
* # The CLI will refresh tokens as needed
|
|
544
|
+
* npx berget api-keys list
|
|
545
|
+
* ```
|
|
546
|
+
*/
|
|
547
|
+
post: {
|
|
548
|
+
requestBody: {
|
|
549
|
+
content: {
|
|
550
|
+
"application/json": components["schemas"]["RefreshTokenRequest"];
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
responses: {
|
|
554
|
+
/** @description New access and refresh tokens */
|
|
555
|
+
200: {
|
|
556
|
+
content: {
|
|
557
|
+
"application/json": components["schemas"]["RefreshTokenResponse"];
|
|
558
|
+
};
|
|
559
|
+
};
|
|
560
|
+
/** @description Invalid or expired refresh token */
|
|
561
|
+
401: {
|
|
415
562
|
content: never;
|
|
416
563
|
};
|
|
417
564
|
};
|
|
@@ -1418,8 +1565,6 @@ export interface components {
|
|
|
1418
1565
|
};
|
|
1419
1566
|
AuthToken: {
|
|
1420
1567
|
accessToken: string;
|
|
1421
|
-
/** @enum {string} */
|
|
1422
|
-
tokenType: "Bearer";
|
|
1423
1568
|
expiresIn: number;
|
|
1424
1569
|
user?: {
|
|
1425
1570
|
id: string;
|
|
@@ -1437,6 +1582,55 @@ export interface components {
|
|
|
1437
1582
|
/** Format: uri */
|
|
1438
1583
|
avatarUrl: string;
|
|
1439
1584
|
};
|
|
1585
|
+
RefreshTokenRequest: {
|
|
1586
|
+
/** @description The refresh token to use */
|
|
1587
|
+
refresh_token: string;
|
|
1588
|
+
/** @description Whether this is a device token */
|
|
1589
|
+
is_device_token?: boolean;
|
|
1590
|
+
};
|
|
1591
|
+
RefreshTokenResponse: {
|
|
1592
|
+
/** @description The new access token */
|
|
1593
|
+
token: string;
|
|
1594
|
+
/** @description The new refresh token */
|
|
1595
|
+
refresh_token: string;
|
|
1596
|
+
/** @description Seconds until the access token expires */
|
|
1597
|
+
expires_in: number;
|
|
1598
|
+
/** @description Seconds until the refresh token expires */
|
|
1599
|
+
refresh_expires_in: number;
|
|
1600
|
+
};
|
|
1601
|
+
DeviceAuthRequest: {
|
|
1602
|
+
/** @description The device code obtained from the device authorization request */
|
|
1603
|
+
device_code: string;
|
|
1604
|
+
};
|
|
1605
|
+
DeviceAuthInitResponse: {
|
|
1606
|
+
/** @description Code used by the device to poll for authentication status */
|
|
1607
|
+
device_code: string;
|
|
1608
|
+
/** @description Code displayed to the user for authentication */
|
|
1609
|
+
user_code: string;
|
|
1610
|
+
/** @description URL where the user should enter the user_code */
|
|
1611
|
+
verification_url: string;
|
|
1612
|
+
/** @description Expiration time in seconds */
|
|
1613
|
+
expires_in: number;
|
|
1614
|
+
/** @description Polling interval in seconds */
|
|
1615
|
+
interval: number;
|
|
1616
|
+
};
|
|
1617
|
+
DeviceAuthPendingResponse: {
|
|
1618
|
+
/**
|
|
1619
|
+
* @description Authentication is still pending
|
|
1620
|
+
* @enum {string}
|
|
1621
|
+
*/
|
|
1622
|
+
status: "pending";
|
|
1623
|
+
};
|
|
1624
|
+
DeviceAuthTokenResponse: {
|
|
1625
|
+
/** @description Access token */
|
|
1626
|
+
token: string;
|
|
1627
|
+
/** @description Refresh token */
|
|
1628
|
+
refresh_token: string;
|
|
1629
|
+
/** @description Access token expiration time in seconds */
|
|
1630
|
+
expires_in: number;
|
|
1631
|
+
/** @description Refresh token expiration time in seconds */
|
|
1632
|
+
refresh_expires_in: number;
|
|
1633
|
+
};
|
|
1440
1634
|
Usage: {
|
|
1441
1635
|
current_period: {
|
|
1442
1636
|
/** Format: date-time */
|