@useknest/widget-core 0.0.1-alpha.6 → 0.0.1-alpha.8
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/auth.d.ts +25 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/config.d.ts +7 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8367 -1442
- package/dist/streaming.d.ts +1 -0
- package/dist/streaming.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
/**
|
|
3
|
+
* Initializes the Supabase client and signs in anonymously.
|
|
4
|
+
* This must be called before sending chat messages.
|
|
5
|
+
*
|
|
6
|
+
* @param supabaseUrl - The Supabase project URL
|
|
7
|
+
* @param supabaseAnonKey - The Supabase anonymous/public key
|
|
8
|
+
* @returns Promise resolving to true if auth succeeded, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
export declare function initWidgetAuth(supabaseUrl: string, supabaseAnonKey: string): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Gets the current access token for API requests.
|
|
13
|
+
* Returns null if not authenticated.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getAccessToken(): Promise<string | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns whether the widget is authenticated.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isAuthenticated(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the Supabase client instance.
|
|
22
|
+
* Returns null if not initialized.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSupabaseClient(): SupabaseClient | null;
|
|
25
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAM1E;;;;;;;GAOG;AACH,wBAAsB,cAAc,CACnC,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC,CAmDlB;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAU7D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAEzD"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { WidgetConfig } from './types';
|
|
2
|
+
export type ConfigErrorType = 'auth' | 'network' | null;
|
|
3
|
+
export interface ConfigResult {
|
|
4
|
+
config: WidgetConfig | null;
|
|
5
|
+
error: ConfigErrorType;
|
|
6
|
+
}
|
|
2
7
|
/**
|
|
3
8
|
* Fetches widget configuration from the API.
|
|
4
9
|
* @param publishableApiKey - The API key for authentication
|
|
5
10
|
* @param baseUrl - Base URL for the API. Defaults to https://useknest.com. Pass empty string for relative paths.
|
|
11
|
+
* @returns ConfigResult with config data or error type
|
|
6
12
|
*/
|
|
7
|
-
export declare function fetchWidgetConfig(publishableApiKey: string, baseUrl?: string): Promise<
|
|
13
|
+
export declare function fetchWidgetConfig(publishableApiKey: string, baseUrl?: string): Promise<ConfigResult>;
|
|
8
14
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAExD,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE,eAAe,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACtC,iBAAiB,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,CAAC,CA6BvB"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare function getChatApiUrl(baseUrl?: string): string;
|
|
|
6
6
|
export declare function getConfigApiUrl(baseUrl?: string): string;
|
|
7
7
|
export declare const FALLBACK_ERROR_MESSAGE = "Sorry, I didn't get a response.";
|
|
8
8
|
export declare const DEFAULT_ERROR_MESSAGE = "Unknown error occurred";
|
|
9
|
+
export declare const AUTH_ERROR_MESSAGE = "This domain is not authorized. Please add it to your allowed origins in the Knest dashboard.";
|
|
9
10
|
export declare const DEFAULT_AVATAR_URL = "https://useknest.com/default-avatar.svg";
|
|
10
11
|
export declare const DEFAULT_BRAND_COLOR = "#0d7a7f";
|
|
11
12
|
export declare const DEFAULT_WELCOME_MESSAGE = "Hi! I'm your AI assistant. I'm trained to answer questions about your documentation. How can I help you today?";
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AACvD,eAAO,MAAM,QAAQ,YAAY,CAAC;AAElC,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,OAAO,GAAE,MAAyB,GAAG,MAAM,CAExE;AAED,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,OAAO,GAAE,MAAyB,GAAG,MAAM,CAE1E;AAED,eAAO,MAAM,sBAAsB,oCAAoC,CAAC;AACxE,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAC9D,eAAO,MAAM,kBAAkB,4CAA4C,CAAC;AAC5E,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,uBAAuB,mHAC6E,CAAC;AAClH,eAAO,MAAM,yBAAyB,UAIrC,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AACvD,eAAO,MAAM,QAAQ,YAAY,CAAC;AAElC,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,OAAO,GAAE,MAAyB,GAAG,MAAM,CAExE;AAED,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,OAAO,GAAE,MAAyB,GAAG,MAAM,CAE1E;AAED,eAAO,MAAM,sBAAsB,oCAAoC,CAAC;AACxE,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAC9D,eAAO,MAAM,kBAAkB,iGACgE,CAAC;AAChG,eAAO,MAAM,kBAAkB,4CAA4C,CAAC;AAC5E,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,uBAAuB,mHAC6E,CAAC;AAClH,eAAO,MAAM,yBAAyB,UAIrC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export type { MessageRole, Source, Message, ChatMessageRequest, ChatMessageResponse, ChatApiError, WidgetConfig, SSEEvent } from './types';
|
|
2
|
-
export { DEFAULT_BASE_URL, API_PATH, getChatApiUrl, getConfigApiUrl, FALLBACK_ERROR_MESSAGE, DEFAULT_ERROR_MESSAGE, DEFAULT_AVATAR_URL, DEFAULT_BRAND_COLOR, DEFAULT_WELCOME_MESSAGE, DEFAULT_EXAMPLE_QUESTIONS } from './constants';
|
|
2
|
+
export { DEFAULT_BASE_URL, API_PATH, getChatApiUrl, getConfigApiUrl, FALLBACK_ERROR_MESSAGE, DEFAULT_ERROR_MESSAGE, AUTH_ERROR_MESSAGE, DEFAULT_AVATAR_URL, DEFAULT_BRAND_COLOR, DEFAULT_WELCOME_MESSAGE, DEFAULT_EXAMPLE_QUESTIONS } from './constants';
|
|
3
3
|
export { fetchWidgetConfig } from './config';
|
|
4
|
+
export type { ConfigResult, ConfigErrorType } from './config';
|
|
4
5
|
export { streamChatMessage } from './streaming';
|
|
5
6
|
export type { StreamCallbacks, StreamMessageOptions } from './streaming';
|
|
6
7
|
export { formatContent } from './utils';
|
|
8
|
+
export { initWidgetAuth, getAccessToken, isAuthenticated, getSupabaseClient } from './auth';
|
|
7
9
|
export { initWidgetSentry, captureWidgetException } from './sentry';
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACX,WAAW,EACX,MAAM,EACN,OAAO,EACP,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,MAAM,SAAS,CAAC;AAGjB,OAAO,EACN,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACX,WAAW,EACX,MAAM,EACN,OAAO,EACP,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,MAAM,SAAS,CAAC;AAGjB,OAAO,EACN,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGzE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAG5F,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC"}
|