@asgard-js/core 0.0.43-canary.25 → 0.0.43-canary.26

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 (2) hide show
  1. package/README.md +38 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -82,7 +82,7 @@ const client = new AsgardServiceClient({
82
82
 
83
83
  ## API Reference
84
84
 
85
- The core package exports three main classes for different levels of abstraction:
85
+ The core package exports three main classes for different levels of abstraction and includes authentication types for dynamic API key management:
86
86
 
87
87
  ### AsgardServiceClient
88
88
 
@@ -90,7 +90,7 @@ The main client class for interacting with the Asgard AI platform.
90
90
 
91
91
  #### Constructor Options (ClientConfig)
92
92
 
93
- - **apiKey**: `string` (required) - API key for authentication
93
+ - **apiKey**: `string` (optional) - API key for authentication. Can be provided later via dynamic authentication
94
94
  - **botProviderEndpoint**: `string` (required) - Bot provider endpoint URL (SSE endpoint will be auto-derived)
95
95
  - **endpoint?**: `string` (deprecated) - Legacy API endpoint URL. Use `botProviderEndpoint` instead.
96
96
  - **debugMode?**: `boolean` - Enable debug mode for deprecation warnings, defaults to `false`
@@ -212,6 +212,42 @@ const updatedConversation = conversation.pushMessage(userMessage);
212
212
  console.log('Messages:', Array.from(updatedConversation.messages.values()));
213
213
  ```
214
214
 
215
+ ### Authentication Types
216
+
217
+ The core package includes authentication-related types for dynamic API key management:
218
+
219
+ #### AuthState
220
+
221
+ Authentication state management for applications requiring dynamic API key input:
222
+
223
+ ```typescript
224
+ type AuthState = 'loading' | 'needApiKey' | 'authenticated' | 'error' | 'invalidApiKey';
225
+ ```
226
+
227
+ **States:**
228
+ - **`loading`**: Authentication in progress
229
+ - **`needApiKey`**: User needs to provide API key
230
+ - **`authenticated`**: Successfully authenticated
231
+ - **`error`**: General authentication error
232
+ - **`invalidApiKey`**: API key is invalid
233
+
234
+ **Usage:**
235
+ ```typescript
236
+ import { AuthState } from '@asgard-js/core';
237
+
238
+ function handleAuthState(state: AuthState) {
239
+ switch (state) {
240
+ case 'needApiKey':
241
+ // Show API key input interface
242
+ break;
243
+ case 'authenticated':
244
+ // Initialize chatbot normally
245
+ break;
246
+ // Handle other states...
247
+ }
248
+ }
249
+ ```
250
+
215
251
  ## Testing
216
252
 
217
253
  The core package includes comprehensive tests using Vitest.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgard-js/core",
3
- "version": "0.0.43-canary.25",
3
+ "version": "0.0.43-canary.26",
4
4
  "dependencies": {
5
5
  "@microsoft/fetch-event-source": "^2.0.1",
6
6
  "rxjs": "^7.8.1"