@coristen/widget 0.1.0 → 0.1.1

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 CHANGED
@@ -11,10 +11,18 @@ import { CoristenWidget } from "@coristen/widget"
11
11
  import "@coristen/widget/styles.css"
12
12
 
13
13
  export default function App() {
14
- return <CoristenWidget identity="/api/coristen/identity" />
14
+ return <CoristenWidget apiKey="coristen_pk_..." />
15
15
  }
16
16
  ```
17
17
 
18
+ Public websites use `apiKey`; visitors are remembered in that browser. For an
19
+ authenticated app, use an identity route instead so conversations follow the
20
+ signed-in customer:
21
+
22
+ ```tsx
23
+ <CoristenWidget identity="/api/coristen/identity" />
24
+ ```
25
+
18
26
  Create the route with the server-only helper:
19
27
 
20
28
  ```ts
@@ -26,4 +34,6 @@ export const { GET } = coristenIdentity(async (request) => {
26
34
  })
27
35
  ```
28
36
 
29
- Set `CORISTEN_KEY` on the server. The widget renders only for a verified signed-in customer; there is no anonymous fallback. Use `apiUrl="http://localhost:3000"` while developing Coristen locally.
37
+ Set `CORISTEN_KEY` on the server when using identity mode. Identity mode renders
38
+ only for a verified signed-in customer; it never falls back to anonymous access.
39
+ Use `apiUrl="http://localhost:3000"` while developing Coristen locally.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,24 @@
1
1
  import type { WidgetSettings } from "./api";
2
- export type CoristenWidgetProps = {
3
- identity: string;
2
+ type CoristenWidgetOptions = {
4
3
  apiUrl?: string;
5
4
  defaultOpen?: boolean;
6
5
  fontSize?: string;
7
6
  appearance?: WidgetAppearance;
7
+ onReady?: () => void;
8
+ onError?: (error: Error) => void;
8
9
  };
10
+ export type CoristenWidgetProps = CoristenWidgetOptions & ({
11
+ apiKey: string;
12
+ identity?: never;
13
+ } | {
14
+ identity: string;
15
+ apiKey?: never;
16
+ });
9
17
  export type WidgetAppearance = Partial<Pick<WidgetSettings, "brandColor" | "position" | "theme" | "tintedGrayscale" | "accentEnabled" | "accentHeader" | "accentSendIcon" | "radius" | "bubbleIcon" | "bubbleColor" | "bubbleShowText" | "bubbleText" | "bubbleIconPosition" | "showPoweredBy">>;
10
- export declare function CoristenWidget({ identity, apiUrl, defaultOpen, fontSize, appearance, }: CoristenWidgetProps): import("react").JSX.Element | null;
18
+ export declare function CoristenWidget({ identity, apiKey, apiUrl, defaultOpen, fontSize, appearance, onReady, onError, }: CoristenWidgetProps): import("react").JSX.Element | null;
11
19
  export type { WidgetSettings } from "./api";
12
20
  export declare const coristenWidget: {
21
+ open(): void;
22
+ close(): void;
13
23
  reset(): void;
14
24
  };