@commentkit/comment-kit 1.5.1 → 2.0.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/CHANGELOG.md +281 -582
- package/README.md +334 -154
- package/SECURITY.md +47 -46
- package/dist/node/THIRD_PARTY_NOTICES.txt +56 -0
- package/dist/node/browser.js +17 -0
- package/dist/node/cli/api.js +226 -0
- package/dist/node/cli/bin.js +18 -0
- package/dist/node/cli/credentials.js +268 -0
- package/dist/node/cli/doctor.js +725 -0
- package/dist/node/cli/format.js +54 -0
- package/dist/node/cli/init.js +372 -0
- package/dist/node/cli/main.js +519 -0
- package/dist/node/cli/mcp.js +114 -0
- package/dist/node/cli/open.js +20 -0
- package/dist/node/plugins/astro-B5y1Gtbf.js +31 -0
- package/dist/node/plugins/astro.js +26 -0
- package/dist/node/plugins/git-BIXLbL3f.js +92 -0
- package/dist/node/plugins/jsx-Bg4BdSph.js +7958 -0
- package/dist/node/plugins/next.js +48 -0
- package/dist/node/plugins/options-THop1K92.js +71 -0
- package/dist/node/plugins/transform-CKiAuSbk.js +1155 -0
- package/dist/node/plugins/vite-BdAYUW10.js +74 -0
- package/dist/node/plugins/vite.js +1 -0
- package/dist/node/plugins/webpack-R2U2DLlY.js +35 -0
- package/dist/node/plugins/webpack-loader.cjs +21 -0
- package/dist/node/plugins/webpack-loader.js +18 -0
- package/dist/node/plugins/webpack.js +1 -0
- package/dist/node/shared/endpoint.js +26 -0
- package/dist/node/shared/format.js +63 -0
- package/dist/node/types/astro.d.ts +11 -0
- package/dist/node/types/next.d.ts +34 -0
- package/dist/node/types/options.d.ts +59 -0
- package/dist/node/types/vite.d.ts +11 -0
- package/dist/node/types/webpack-loader.d.ts +22 -0
- package/dist/node/types/webpack.d.ts +27 -0
- package/dist/npm/THIRD_PARTY_NOTICES.txt +6 -6
- package/dist/npm/chunks/AgentSend-DxRJIYiz.js +68 -0
- package/dist/npm/chunks/Checklist-CnlfeSbc.js +282 -0
- package/dist/npm/chunks/Composer-B1bBVszY.js +725 -0
- package/dist/npm/chunks/Guest-vvNPz8h-.js +267 -0
- package/dist/npm/chunks/MarkupEditor-VCOXh9d2.js +338 -0
- package/dist/npm/chunks/Panel-F37vIL1K.js +1206 -0
- package/dist/npm/chunks/Settings-BGoZS2iV.js +231 -0
- package/dist/npm/chunks/Shortcuts-B2OMvczr.js +62 -0
- package/dist/npm/chunks/StyleEditor-CJ_d8Huf.js +46 -0
- package/dist/npm/chunks/StylePanel-yQzHHlY7.js +199 -0
- package/dist/npm/chunks/TaskFields-fmy6_HtK.js +289 -0
- package/dist/npm/chunks/ThreadCard-D51slKST.js +1113 -0
- package/dist/npm/chunks/Viewer-BOBadqmC.js +111 -0
- package/dist/npm/chunks/{agent-CqDO3JMA.js → agent-C1OQzBAm.js} +20 -21
- package/dist/npm/chunks/{anchor-OCQnjp_6.js → anchor-BsQNVkHj.js} +109 -87
- package/dist/npm/chunks/{ar-BQ9K9Oqf.js → ar-CAJ3XT8e.js} +73 -20
- package/dist/npm/chunks/card-bits-CAnzrqx3.js +53 -0
- package/dist/npm/chunks/{client-dZeNdizE.js → client-kNAo2TTG.js} +292 -285
- package/dist/npm/chunks/{colors-CAjY4jxf.js → colors-CWAn_swA.js} +1 -2
- package/dist/npm/chunks/confetti-CkBdSu19.js +49 -0
- package/dist/npm/chunks/context-B8UAzve0.js +20 -0
- package/dist/npm/chunks/context-BuMl7A07.js +48 -0
- package/dist/npm/chunks/{de-CcPi8xdC.js → de-Dl18G48t.js} +64 -19
- package/dist/npm/chunks/dialog-GO04oC3D.js +3 -0
- package/dist/npm/chunks/dpop-U48QIQd7.js +96 -0
- package/dist/npm/chunks/drafts-B0ctr1g9.js +21 -0
- package/dist/npm/chunks/{es-DXgkjDCG.js → es-Dxk79lS9.js} +64 -19
- package/dist/npm/chunks/extension-CKFpPWmi.js +62 -0
- package/dist/npm/chunks/{extension-BFkXOmX5.js → extension-E81hWyiT.js} +21 -14
- package/dist/npm/chunks/files-DyD5BZgp.js +114 -0
- package/dist/npm/chunks/{fr-IjJaUbWh.js → fr-8BebGKYD.js} +121 -76
- package/dist/npm/chunks/{hi-BhKQK2MU.js → hi-BIN6Yy_p.js} +65 -20
- package/dist/npm/chunks/{html2canvas-pro.esm-lgs6tb4C.js → html2canvas-pro.esm-B7b8p5Wr.js} +608 -528
- package/dist/npm/chunks/i18n-DOBt8e9U.js +936 -0
- package/dist/npm/chunks/identify-CN-3xzqL.js +106 -0
- package/dist/npm/chunks/{it-DKiSCkiD.js → it-Cr6EwpPQ.js} +83 -38
- package/dist/npm/chunks/{ja-BI1WagDg.js → ja-Iy3s5aur.js} +62 -17
- package/dist/npm/chunks/late-words-B2bmZceJ.js +12 -0
- package/dist/npm/chunks/live-CelVeZfP.js +85 -0
- package/dist/npm/chunks/locale-D8Q4Q2Nt.js +26 -0
- package/dist/npm/chunks/{lock-C82sC17d.js → lock-B1JLlOhz.js} +0 -1
- package/dist/npm/chunks/{nl-CJw3VUQ5.js → nl-B84WHqqe.js} +65 -20
- package/dist/npm/chunks/page-key-DepmJzC1.js +62 -0
- package/dist/npm/chunks/{pick-dDDLxCDI.js → pick-yTyqtxN0.js} +46 -46
- package/dist/npm/chunks/pkce-ChKGSW_4.js +8 -0
- package/dist/npm/chunks/placement-BF_HOUDD.js +74 -0
- package/dist/npm/chunks/privacy-BWUGlHw5.js +57 -0
- package/dist/npm/chunks/{pt-BR-CjBolC5g.js → pt-BR-DOkdlfoe.js} +64 -19
- package/dist/npm/chunks/{realtime-D22tI_AS.js → realtime-C79zF50C.js} +16 -15
- package/dist/npm/chunks/report-CrIqQZDI.js +44 -0
- package/dist/npm/chunks/{rolldown-runtime-Y_bBpyJl.js → rolldown-runtime-QGRDbDUS.js} +1 -2
- package/dist/npm/chunks/show-BgVC8gWY.js +97 -0
- package/dist/npm/chunks/signin-Dd1rb2BP.js +75 -0
- package/dist/npm/chunks/{source-BQS2_xfB.js → source-pXVve2Cx.js} +2 -3
- package/dist/npm/chunks/src-BTMy4Gyc.js +208 -0
- package/dist/npm/chunks/start-DtVlpt7p.js +1878 -0
- package/dist/npm/chunks/states-sfTbjZz8.js +3 -0
- package/dist/npm/chunks/upload-MgPYqPyE.js +42 -0
- package/dist/npm/chunks/uploads-D49mywwz.js +1146 -0
- package/dist/npm/chunks/wrap-Bl0gbnFa.js +69 -0
- package/dist/npm/chunks/{zh-CN-BrZGx2S0.js → zh-CN-Z5fQCb7G.js} +63 -18
- package/dist/npm/element.js +59 -23
- package/dist/npm/headless.js +7 -3
- package/dist/npm/index.js +3 -3
- package/dist/npm/react.js +19 -13
- package/dist/npm/svelte.js +29 -14
- package/dist/npm/types/adapters/react.d.ts +4 -1
- package/dist/npm/types/adapters/svelte.d.ts +4 -1
- package/dist/npm/types/adapters/vue.d.ts +35 -2
- package/dist/npm/types/anchor/index.d.ts +19 -0
- package/dist/npm/types/capture/privacy.d.ts +14 -0
- package/dist/npm/types/core/api.d.ts +20 -1
- package/dist/npm/types/core/auth.d.ts +47 -14
- package/dist/npm/types/core/client.d.ts +60 -4
- package/dist/npm/types/core/page-key.d.ts +42 -0
- package/dist/npm/types/core/types.d.ts +87 -4
- package/dist/npm/types/element.d.ts +17 -7
- package/dist/npm/types/headless.d.ts +2 -1
- package/dist/npm/types/index.d.ts +16 -6
- package/dist/npm/vue.js +45 -11
- package/package.json +95 -21
- package/dist/npm/chunks/AgentSend-DjFZSC0S.js +0 -64
- package/dist/npm/chunks/Checklist-BEz4IZdT.js +0 -259
- package/dist/npm/chunks/Composer-D1wbmdjF.js +0 -681
- package/dist/npm/chunks/Guest-CtyRy8Kz.js +0 -170
- package/dist/npm/chunks/MarkupEditor-CPH4yKx4.js +0 -334
- package/dist/npm/chunks/Panel-DSoUAlbQ.js +0 -863
- package/dist/npm/chunks/Settings-C_qV4n7J.js +0 -206
- package/dist/npm/chunks/Shortcuts-ChnaribX.js +0 -60
- package/dist/npm/chunks/StyleEditor-DqZd6C5o.js +0 -44
- package/dist/npm/chunks/StylePanel-DMC3riYK.js +0 -199
- package/dist/npm/chunks/TaskFields-BfjjllMx.js +0 -272
- package/dist/npm/chunks/ThreadCard-DmKAelSL.js +0 -1026
- package/dist/npm/chunks/Viewer-mw69qSI5.js +0 -110
- package/dist/npm/chunks/card-bits-C7bIk5KX.js +0 -126
- package/dist/npm/chunks/confetti-DKeKR7-6.js +0 -41
- package/dist/npm/chunks/drafts-CpQdHhcK.js +0 -51
- package/dist/npm/chunks/extension-Gvei3opb.js +0 -54
- package/dist/npm/chunks/i18n-DAJGndZ2.js +0 -904
- package/dist/npm/chunks/live-MvvBdoGd.js +0 -34
- package/dist/npm/chunks/report-DoDVi1qT.js +0 -28
- package/dist/npm/chunks/src-C_oUnL0i.js +0 -150
- package/dist/npm/chunks/start-C5-rebEU.js +0 -1783
- package/dist/npm/chunks/upload-CzPAjktW.js +0 -42
- package/dist/npm/chunks/uploads-tpLjiJdH.js +0 -541
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const PRIVATE_CAPTURE_SELECTOR: string;
|
|
2
|
+
/** Form controls: what someone typed or chose. Never in anchors; in strict mode never in screenshots either. */
|
|
3
|
+
export declare const FORM_CONTROLS = "input,textarea,select";
|
|
4
|
+
/** Strict mode: every form control and every editable region. */
|
|
5
|
+
export declare const STRICT = "input,textarea,select,[contenteditable]:not([contenteditable=\"false\" i])";
|
|
6
|
+
/** Called with `[...config.privacy.redact_selectors, ...options.redact]` and the stricter of `config.privacy.mode` and `options.privacy` (ui/privacy.ts). Invalid selectors are left out. */
|
|
7
|
+
export declare function configurePrivacy(redact?: string[], privacy?: "standard" | "strict"): void;
|
|
8
|
+
/** Strict mode: set by the dashboard or init({ privacy: "strict" }) (via configurePrivacy), or passed for one capture. */
|
|
9
|
+
export declare const isStrict: (privacy?: "standard" | "strict") => boolean;
|
|
10
|
+
/** Everything private: the built-in policy, strict mode's form controls and editable regions, and `extra` selectors. */
|
|
11
|
+
export declare function privateSelector(extra?: string[], strict?: boolean): string;
|
|
12
|
+
/** Is the element (or anything around it, out through shadow roots) private? Fails closed. */
|
|
13
|
+
export declare function isCaptureRedacted(element: Element, selector?: string): boolean;
|
|
14
|
+
export declare function isValidSelector(selector: string): boolean;
|
|
@@ -11,17 +11,28 @@ export interface ApiRequest {
|
|
|
11
11
|
onETag?(etag: string | null): void;
|
|
12
12
|
/** Skip the Authorization header (public endpoints). */
|
|
13
13
|
anonymous?: boolean;
|
|
14
|
+
/** Send a DPoP proof even without a session (POST /guest/start, /guest/finish). */
|
|
15
|
+
proof?: boolean;
|
|
14
16
|
signal?: AbortSignal;
|
|
15
17
|
}
|
|
16
18
|
export type TokenProvider = {
|
|
17
19
|
accessToken(): Promise<string | null>;
|
|
18
20
|
/** Called once on a 401; returns true if a fresh token is now available. */
|
|
19
21
|
recover(): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* A DPoP proof for one request (AuthManager.proof): with it, a token goes as `Authorization: DPoP` with a
|
|
24
|
+
* new proof on every attempt; without it (a provider of plain bearer tokens), as `Bearer`.
|
|
25
|
+
*/
|
|
26
|
+
proof?(method: string, url: string, token?: string | null): Promise<string>;
|
|
27
|
+
/** Sees every answer (AuthManager.seen); true: sign the request again and send it once more (DPoP nonce or clock). */
|
|
28
|
+
seen?(response: Response, code?: string): boolean;
|
|
20
29
|
};
|
|
30
|
+
/** Each attempt, answer body included, gets this long; then it counts as a lost connection (GETs and idempotent writes are tried again). */
|
|
31
|
+
export declare const REQUEST_TIMEOUT_MS = 30000;
|
|
21
32
|
/**
|
|
22
33
|
* Thin fetch wrapper for /api/v1: JSON in/out, problem+json errors as
|
|
23
34
|
* CommentKitError, one silent re-auth on 401, and bounded retries with
|
|
24
|
-
* backoff for transient failures (network, 429, 5xx).
|
|
35
|
+
* backoff for transient failures (network, timeout, 429, 5xx).
|
|
25
36
|
*/
|
|
26
37
|
export declare class ApiClient {
|
|
27
38
|
private readonly baseUrl;
|
|
@@ -32,3 +43,11 @@ export declare class ApiClient {
|
|
|
32
43
|
request<T>(path: string, options?: ApiRequest): Promise<T>;
|
|
33
44
|
url(path: string, query?: ApiRequest["query"]): string;
|
|
34
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* A signal that aborts after `ms`, or as soon as the caller's `signal` does. The same everywhere (no
|
|
48
|
+
* AbortSignal.any or AbortSignal.timeout needed); `done()` stops the timer and the listener.
|
|
49
|
+
*/
|
|
50
|
+
export declare function deadline(ms: number, signal?: AbortSignal): {
|
|
51
|
+
signal: AbortSignal;
|
|
52
|
+
done(): void;
|
|
53
|
+
};
|
|
@@ -5,13 +5,20 @@ export interface PendingGuest {
|
|
|
5
5
|
}
|
|
6
6
|
export interface Tokens {
|
|
7
7
|
access_token: string;
|
|
8
|
-
|
|
8
|
+
/** Missing for a session the page cannot renew (an extension handoff: it lasts `expires_in`, an hour). */
|
|
9
|
+
refresh_token?: string;
|
|
9
10
|
expires_in: number;
|
|
10
11
|
}
|
|
11
12
|
export type SignInResult = "signed_in" | "popup_blocked" | "cancelled" | "failed" | "redirecting";
|
|
12
13
|
export type AuthMode = "auto" | "popup" | "redirect";
|
|
13
14
|
/** Token, exchange and revoke requests are aborted after this long; the storage lock's lease (lock.ts HOLD_MS) is longer. */
|
|
14
15
|
export declare const TOKEN_TIMEOUT_MS = 10000;
|
|
16
|
+
/**
|
|
17
|
+
* Client email links carry `#ck_signin=<secret>` in the fragment (older links `?ck_signin=`): single use,
|
|
18
|
+
* 72 hours, one website (the backend's ClientSignInLinks). The sign-in window (`/widget/guest`) checks it;
|
|
19
|
+
* this only keeps out what can't be one.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SIGNIN_PARAM = "ck_signin";
|
|
15
22
|
/**
|
|
16
23
|
* Widget sign-in: a popup on the CommentKit domain (credentials never touch
|
|
17
24
|
* this page), PKCE, short-lived access tokens and a rotating refresh token.
|
|
@@ -22,22 +29,47 @@ export declare const TOKEN_TIMEOUT_MS = 10000;
|
|
|
22
29
|
* revokes the whole session server-side.
|
|
23
30
|
*/
|
|
24
31
|
export declare class AuthManager {
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
private readonly origin;
|
|
28
|
-
private access;
|
|
32
|
+
/** The refresh token, when the DPoP key lives in memory only (no IndexedDB): never stored, so the session ends with the page. */
|
|
33
|
+
private held;
|
|
29
34
|
private refreshing;
|
|
35
|
+
/** The session has no refresh token (an extension handoff): it lives in memory only and is renewed by `renew`. */
|
|
36
|
+
private handoff;
|
|
37
|
+
private renewing;
|
|
30
38
|
private listeners;
|
|
31
39
|
private remember;
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
constructor(
|
|
41
|
+
/** @internal */
|
|
42
|
+
endpoint: string,
|
|
43
|
+
/** @internal */
|
|
44
|
+
projectKey: string,
|
|
45
|
+
/** @internal */
|
|
46
|
+
origin?: string);
|
|
47
|
+
/**
|
|
48
|
+
* Signed out in another tab (it removed the shared refresh token): this tab forgets its access token
|
|
49
|
+
* too and says so. A rotation by another tab writes a new token, which this tab simply reads next time.
|
|
50
|
+
*/
|
|
51
|
+
private readonly onStorage;
|
|
52
|
+
destroy(): void;
|
|
34
53
|
get storageKey(): string;
|
|
54
|
+
/** A valid access token, or a refresh token to get one (a session without one ends with its access token). */
|
|
35
55
|
hasSession(): boolean;
|
|
36
|
-
|
|
56
|
+
/** `ended`: the session ran out or the server refused to renew it (not a sign-out here or in another tab). */
|
|
57
|
+
onChange(listener: (signedIn: boolean, ended?: boolean) => void): () => void;
|
|
37
58
|
/** A valid access token, refreshing if needed. null when signed out. */
|
|
38
59
|
accessToken(): Promise<string | null>;
|
|
39
60
|
recover(): Promise<boolean>;
|
|
40
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Keeps a client email link's `?ck_signin=` value for the next sign-in, in memory only. The value was
|
|
63
|
+
* already taken off the address bar (activation.ts takeSignInParam, run first by the CDN loader and by
|
|
64
|
+
* init()), so it never reaches the page's analytics, a bookmark or a Referer. True when it is usable.
|
|
65
|
+
*/
|
|
66
|
+
takeSignInLink(value: string | null): boolean;
|
|
67
|
+
/** A client email link is waiting to be used by the next sign-in. */
|
|
68
|
+
hasSignInLink(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Must be called from a user gesture (click) so the popup is allowed. The sign-in code (signin.ts) is
|
|
71
|
+
* a lazy chunk, fetched ahead while the widget shows someone signed out (client.loadSession).
|
|
72
|
+
*/
|
|
41
73
|
signIn(options?: {
|
|
42
74
|
share?: string | null;
|
|
43
75
|
mode?: AuthMode;
|
|
@@ -49,11 +81,11 @@ export declare class AuthManager {
|
|
|
49
81
|
* Returns true when a session was created. Removes the params from the URL.
|
|
50
82
|
*/
|
|
51
83
|
completeRedirect(): Promise<boolean>;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Also deletes this browser's DPoP key (core/dpop.ts, loaded by the session's first request): the next
|
|
86
|
+
* sign-in makes a new one.
|
|
87
|
+
*/
|
|
55
88
|
signOut(): Promise<void>;
|
|
56
|
-
private awaitCode;
|
|
57
89
|
/**
|
|
58
90
|
* One refresh at a time across this site's tabs (they share the refresh token, and the server treats a
|
|
59
91
|
* second use of a rotated token as theft). The token is read again once the lock is held: another tab
|
|
@@ -81,10 +113,11 @@ export declare class AuthManager {
|
|
|
81
113
|
/** Start a normal session from tokens the API issued (POST /guest/verify). Ends the pending token. */
|
|
82
114
|
adopt(tokens: Tokens): void;
|
|
83
115
|
private store;
|
|
84
|
-
/** Only the policy's storage holds the token; the other one is always emptied. */
|
|
116
|
+
/** Only the policy's storage holds the token; the other one is always emptied. With a key in memory only, neither. */
|
|
85
117
|
private write;
|
|
86
118
|
/** [where the policy keeps the token, the other one]. */
|
|
87
119
|
private stores;
|
|
120
|
+
/** `ended`: the session ran out or was refused, rather than signed out (onChange). */
|
|
88
121
|
private clear;
|
|
89
122
|
private readRefresh;
|
|
90
123
|
private emit;
|
|
@@ -11,12 +11,31 @@ export interface LinkPreview {
|
|
|
11
11
|
description: string | null;
|
|
12
12
|
}
|
|
13
13
|
export declare const SDK_VERSION: string;
|
|
14
|
+
export declare const DEFAULT_ENDPOINT = "https://commentkit.dev";
|
|
15
|
+
/** Page keys (core/page-key.ts): what the client needs of them. */
|
|
16
|
+
export interface PageKeys {
|
|
17
|
+
/** The key of an address: the server's key for that page once one was learnt. */
|
|
18
|
+
of(address: string): string;
|
|
19
|
+
/** The server answered `key` for the page at `address`. */
|
|
20
|
+
learn?(address: string, key: string | undefined): void;
|
|
21
|
+
/** This page's address as it is sent (page.url, page_url): core/page-key.ts pageUrl. */
|
|
22
|
+
url?(): string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* This page's address as the API gets it (page.url, page_url): core/page-key.ts pageUrl once installed (without
|
|
26
|
+
* CommentKit's own parameters, the fragment only as a hash route, capped at the API's length), else as it is.
|
|
27
|
+
*/
|
|
28
|
+
export declare const currentPageUrl: () => string;
|
|
29
|
+
/** Most threads loadPageThreads reads for one page (100 per request). */
|
|
30
|
+
export declare const MAX_PAGE_THREADS = 500;
|
|
14
31
|
export interface ClientState {
|
|
15
32
|
config: WidgetConfig | null;
|
|
16
33
|
session: Session | null;
|
|
17
34
|
/** Threads on the current page, newest activity first. */
|
|
18
35
|
threads: Thread[];
|
|
19
36
|
loadingThreads: boolean;
|
|
37
|
+
/** The page has more open threads than `threads` holds (more than MAX_PAGE_THREADS). */
|
|
38
|
+
moreThreads: boolean;
|
|
20
39
|
/** Show feedback from every branch, not only the one this build came from. */
|
|
21
40
|
allBranches: boolean;
|
|
22
41
|
unread: number;
|
|
@@ -38,6 +57,13 @@ export interface ClientState {
|
|
|
38
57
|
/** Team members here right now, by name: only filled in for team members (the team presence channel). */
|
|
39
58
|
team: Person[];
|
|
40
59
|
}
|
|
60
|
+
/** A state with nothing loaded yet (also the inert stand-in's, for server rendering). */
|
|
61
|
+
export declare function blankState(): ClientState;
|
|
62
|
+
/**
|
|
63
|
+
* The session as the host page sees it (event payloads, `session()`): without the person's email
|
|
64
|
+
* address, which the page's own scripts and analytics have no need for. The widget keeps it (Settings).
|
|
65
|
+
*/
|
|
66
|
+
export declare function publicSession(session: Session | null): Session | null;
|
|
41
67
|
type Listener<K extends keyof CommentKitEvents> = (payload: CommentKitEvents[K]) => void;
|
|
42
68
|
/** The `code` of the error an edit gets when someone else changed the thread or message first (HTTP 412). */
|
|
43
69
|
export declare const EDIT_CONFLICT = "edit_conflict";
|
|
@@ -66,17 +92,38 @@ export declare class CommentKitClient {
|
|
|
66
92
|
private unreadKnown;
|
|
67
93
|
/** Conversations read by allMessages, page by page, so a refresh reads only what is new. */
|
|
68
94
|
private conversations;
|
|
95
|
+
/** Events whose listener threw already (logged once each). */
|
|
96
|
+
private failedEvents;
|
|
97
|
+
/** The latest loadPageThreads call, and the page its threads are for. */
|
|
98
|
+
private pageLoad;
|
|
99
|
+
/** The page key the threads in the state are for. */
|
|
100
|
+
private threadsPage;
|
|
101
|
+
/** Threads created, changed or removed here (null: not on this page) while a page load was under way: kept over its answer. */
|
|
102
|
+
private changed;
|
|
69
103
|
constructor(options: CommentKitOptions);
|
|
70
104
|
/** Where CommentKit's own static files live (emoji images), on the same server as the API. */
|
|
71
105
|
get assets(): string;
|
|
72
106
|
/** The widget's own crash, sent to CommentKit with the SDK version (see core/report.ts). */
|
|
73
107
|
reportCrash(error: unknown, kind?: "crash" | "start"): void;
|
|
74
108
|
on<K extends keyof CommentKitEvents>(event: K, listener: Listener<K>): () => void;
|
|
109
|
+
/**
|
|
110
|
+
* Tells the page's listeners. Each runs on its own: one that throws is logged (once per event) and
|
|
111
|
+
* changes nothing here, neither the other listeners, CommentKit's state, nor its crash reports.
|
|
112
|
+
* Sessions reach the page without the email address (publicSession).
|
|
113
|
+
*/
|
|
75
114
|
emit<K extends keyof CommentKitEvents>(event: K, payload: CommentKitEvents[K]): void;
|
|
115
|
+
/** Fetch the sign-in code ahead, so a click on "Sign in" opens the window at once (popup blockers allow only a short wait). */
|
|
116
|
+
prefetchSignIn(): void;
|
|
76
117
|
loadConfig(): Promise<WidgetConfig>;
|
|
77
118
|
loadSession(): Promise<Session | null>;
|
|
119
|
+
/** Never rejects: anything that goes wrong (the window, the code exchange, reading the session) is "failed". */
|
|
78
120
|
signIn(share?: string | null): Promise<SignInResult>;
|
|
79
121
|
signOut(): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* The page's open threads: follows `next_cursor` up to MAX_PAGE_THREADS (`moreThreads` says when there
|
|
124
|
+
* are more). On another page the previous page's threads are cleared at once. An answer that arrives
|
|
125
|
+
* after a newer call, or after the address changed (fast single-page navigation), is ignored.
|
|
126
|
+
*/
|
|
80
127
|
loadPageThreads(pageUrl?: string): Promise<Thread[]>;
|
|
81
128
|
/** The branch lists are limited to: this build's branch, unless "All branches" is on. */
|
|
82
129
|
branchFilter(): string | undefined;
|
|
@@ -146,7 +193,7 @@ export declare class CommentKitClient {
|
|
|
146
193
|
allMessages(threadId: string, options?: {
|
|
147
194
|
refresh?: boolean;
|
|
148
195
|
}): Promise<Message[]>;
|
|
149
|
-
/** A message changed here: forget the conversation holding it, so the next read is complete. */
|
|
196
|
+
/** A message changed here: forget the conversation holding it, so the next read is complete. Returns that thread's id, if known. */
|
|
150
197
|
private forgetConversationOf;
|
|
151
198
|
reply(threadId: string, body: string, options?: {
|
|
152
199
|
replyTo?: string | null;
|
|
@@ -162,7 +209,12 @@ export declare class CommentKitClient {
|
|
|
162
209
|
editMessage(id: string, body: string, options?: {
|
|
163
210
|
mentionIds?: number[];
|
|
164
211
|
}): Promise<Message>;
|
|
165
|
-
/**
|
|
212
|
+
/**
|
|
213
|
+
* An edit or delete. On a conflict the ETag is forgotten and `reload` (if any) reads the latest version.
|
|
214
|
+
* These writes carry no Idempotency-Key, so a lost answer (timeout, dropped connection) is not retried
|
|
215
|
+
* and the server may have applied it anyway: `reload` reads the real state before the error is shown,
|
|
216
|
+
* and a manual retry then starts from it.
|
|
217
|
+
*/
|
|
166
218
|
private edit;
|
|
167
219
|
deleteMessage(id: string): Promise<void>;
|
|
168
220
|
react(messageId: string, emoji: string, on: boolean): Promise<void>;
|
|
@@ -227,11 +279,15 @@ export declare class CommentKitClient {
|
|
|
227
279
|
/** Try the live connection again now, after it dropped. */
|
|
228
280
|
reconnectRealtime(): void;
|
|
229
281
|
refreshThread(id: string): Promise<void>;
|
|
282
|
+
/**
|
|
283
|
+
* This page's key (core/page-key.ts), compared instead of addresses everywhere: the key computed here, or
|
|
284
|
+
* the server's own key for this page once an answer showed it differs (the project's own list of
|
|
285
|
+
* parameters that do not change the page, which the widget cannot know).
|
|
286
|
+
*/
|
|
287
|
+
pageKey(address?: string): string;
|
|
230
288
|
private upsert;
|
|
231
289
|
destroy(): void;
|
|
232
290
|
}
|
|
233
291
|
/** Remember the reader's theme on this device (null forgets it). */
|
|
234
292
|
export declare function saveTheme(theme: ClientState["theme"]): void;
|
|
235
|
-
/** Page identity: origin + path + query + hash routes, without our own params. */
|
|
236
|
-
export declare function currentPageUrl(): string;
|
|
237
293
|
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A page's key: its stable identity, the same for every address of one page. The server keys feedback and
|
|
3
|
+
* sign-offs by it (contract/openapi-v1.yaml, `Thread.page.key`) and the widget compares pages by it, never
|
|
4
|
+
* by the raw address, so `/pricing`, `/pricing/` and `/pricing?utm_source=x` are one page. These are the
|
|
5
|
+
* spec's built-in rules, in its order; test/page-key.test.ts runs the backend's own table against them.
|
|
6
|
+
*
|
|
7
|
+
* A project can list more parameters that do not change the page. GET /widget/config sends that list
|
|
8
|
+
* (`pages.ignored_query_params`) and the widget applies it (pageKeys.ignore), so its key is right before any
|
|
9
|
+
* comment exists on the page. Older servers leave it out; and whenever the two still disagree, the client
|
|
10
|
+
* trusts the key the server answers for the current page (client.pageKey).
|
|
11
|
+
*/
|
|
12
|
+
/** Tracking parameters every project drops, besides any `utm_*` and CommentKit's own `ck` and `ck_*`. */
|
|
13
|
+
export declare const TRACKING: string[];
|
|
14
|
+
/**
|
|
15
|
+
* The page key of an address. `ignored`: the project's own "query parameters that do not change the
|
|
16
|
+
* page" (a trailing `*` matches every name starting with the rest), when known. Never throws.
|
|
17
|
+
*/
|
|
18
|
+
export declare function pageKey(address: string, ignored?: readonly string[]): string;
|
|
19
|
+
/**
|
|
20
|
+
* `href` without the query parameters whose name (as written) `names` matches, edited as written: every other
|
|
21
|
+
* pair stays byte for byte, in its order (URLSearchParams would re-encode them, `?ids=1,2` → `ids=1%2C2`, and
|
|
22
|
+
* the server keeps pairs as written, so the page's key would no longer match). A query left empty goes with
|
|
23
|
+
* its `?`. The fragment is never touched.
|
|
24
|
+
*/
|
|
25
|
+
export declare const withoutParams: (href: string, names: RegExp) => string;
|
|
26
|
+
/**
|
|
27
|
+
* This page's address as the API gets it (page.url, page_url): without CommentKit's own parameters (also the
|
|
28
|
+
* redirect sign-in ones: a host router, Inertia for one, can write them back after they were taken off), the
|
|
29
|
+
* fragment only as a hash route, at most PAGE_URL_MAX characters (the API's limit on `page.url`).
|
|
30
|
+
*/
|
|
31
|
+
export declare const pageUrl: () => string;
|
|
32
|
+
/** What the client uses (client.ts usePageKeys): keys, with what the server answered for a page winning. */
|
|
33
|
+
export declare const pageKeys: {
|
|
34
|
+
url: typeof pageUrl;
|
|
35
|
+
of(address: string): string;
|
|
36
|
+
learn(address: string, key: string | undefined): void;
|
|
37
|
+
/**
|
|
38
|
+
* The project's list from the widget config. Anything that is not a list of names counts as none (an older
|
|
39
|
+
* server). A different list forgets the keys learnt so far: they were learnt against the old one.
|
|
40
|
+
*/
|
|
41
|
+
ignore(list: unknown): void;
|
|
42
|
+
};
|
|
@@ -82,6 +82,11 @@ export interface Message {
|
|
|
82
82
|
author: Person;
|
|
83
83
|
body: string;
|
|
84
84
|
source: string;
|
|
85
|
+
/**
|
|
86
|
+
* "team": a team-only reply, which only the project's team members receive (shown as such). Guests and
|
|
87
|
+
* reviewers only ever get "everyone". Older servers leave it out.
|
|
88
|
+
*/
|
|
89
|
+
visibility?: "everyone" | "team";
|
|
85
90
|
reply_to?: {
|
|
86
91
|
id: string;
|
|
87
92
|
author: Person;
|
|
@@ -168,6 +173,11 @@ export interface Thread {
|
|
|
168
173
|
labels?: Label[];
|
|
169
174
|
page: {
|
|
170
175
|
url: string;
|
|
176
|
+
/**
|
|
177
|
+
* The page's key: compare pages by this, never by `url` (`/pricing?utm_source=x` and `/pricing/` are
|
|
178
|
+
* `/pricing`). See `pageKey` in `@commentkit/comment-kit/headless`. Older servers leave it out.
|
|
179
|
+
*/
|
|
180
|
+
key?: string;
|
|
171
181
|
path: string;
|
|
172
182
|
title: string | null;
|
|
173
183
|
environment: Environment;
|
|
@@ -200,8 +210,8 @@ export interface Thread {
|
|
|
200
210
|
}
|
|
201
211
|
/**
|
|
202
212
|
* A realtime change ping. Ids only: the widget fetches the thread again over HTTP. `actor` (and `by`, on
|
|
203
|
-
* newer servers) say who made the change ("user:1", "guest:9"); `
|
|
204
|
-
* on. Any of them can be missing on older servers.
|
|
213
|
+
* newer servers) say who made the change ("user:1", "guest:9"); `page_key` says which page the thread is
|
|
214
|
+
* on (`page_path` is the older, coarser form). Any of them can be missing on older servers.
|
|
205
215
|
*/
|
|
206
216
|
export interface FeedbackPing {
|
|
207
217
|
type: string;
|
|
@@ -210,6 +220,8 @@ export interface FeedbackPing {
|
|
|
210
220
|
actor?: string | null;
|
|
211
221
|
by?: string | null;
|
|
212
222
|
page_path?: string | null;
|
|
223
|
+
/** The page key of the thread's page (`Thread.page.key`); null for tasks without a page. */
|
|
224
|
+
page_key?: string | null;
|
|
213
225
|
}
|
|
214
226
|
export interface Capabilities {
|
|
215
227
|
comment: boolean;
|
|
@@ -241,6 +253,14 @@ export interface WidgetConfig {
|
|
|
241
253
|
name: string;
|
|
242
254
|
};
|
|
243
255
|
enabled: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Why `enabled` is false: "project_paused" (the project's kill switch: visitors from a link see a short
|
|
258
|
+
* note), "version_blocked" (CommentKit switched this SDK version off: the widget stays silent until it
|
|
259
|
+
* is switched back on) or "not_live" (the website is being tried out before a plan is chosen and this is
|
|
260
|
+
* not a local address: silent for visitors, a signed-in team member sees a short note). Null when enabled;
|
|
261
|
+
* older servers leave it out.
|
|
262
|
+
*/
|
|
263
|
+
disabled_reason?: "project_paused" | "version_blocked" | "not_live" | null;
|
|
244
264
|
read_only: boolean;
|
|
245
265
|
environment: Environment;
|
|
246
266
|
local_only_for_members: boolean;
|
|
@@ -262,9 +282,28 @@ export interface WidgetConfig {
|
|
|
262
282
|
};
|
|
263
283
|
privacy: {
|
|
264
284
|
redact_selectors: string[];
|
|
285
|
+
/**
|
|
286
|
+
* Set in the dashboard ("Hide everything people type in screenshots"): "strict" hides every form value and
|
|
287
|
+
* editable region in screenshots. The widget applies the stricter of this and init({ privacy }). Older servers leave it out.
|
|
288
|
+
*/
|
|
289
|
+
mode?: "standard" | "strict";
|
|
290
|
+
/** The website's own privacy notice (https), shown to its guests next to CommentKit's. Null or absent when none. */
|
|
291
|
+
notice_url?: string | null;
|
|
265
292
|
};
|
|
293
|
+
/**
|
|
294
|
+
* `upload_types`: the file types (MIME) this website accepts as attachments, when it limits them (for
|
|
295
|
+
* example images only); absent means every type the API allows.
|
|
296
|
+
*/
|
|
266
297
|
limits: {
|
|
267
298
|
max_upload_bytes: number;
|
|
299
|
+
upload_types?: string[];
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* How this website identifies a page: its own query parameters that do not change the page (lower-cased; a
|
|
303
|
+
* trailing `*` matches every name starting with the rest), on top of the built-in tracking ones. Older servers leave it out.
|
|
304
|
+
*/
|
|
305
|
+
pages?: {
|
|
306
|
+
ignored_query_params: string[];
|
|
268
307
|
};
|
|
269
308
|
/** First read of a page only: proves a real widget load when reporting the widget's own crash. */
|
|
270
309
|
reporting?: {
|
|
@@ -334,8 +373,15 @@ export interface CommentKitOptions {
|
|
|
334
373
|
theme?: "auto" | "light" | "dark";
|
|
335
374
|
/** Where the launcher sits. Defaults to the dashboard setting. */
|
|
336
375
|
position?: Position;
|
|
337
|
-
/** CSS selectors whose content is never captured in screenshots. */
|
|
376
|
+
/** CSS selectors whose content is never captured in screenshots, nor in the text a comment keeps to find its spot. */
|
|
338
377
|
redact?: string[];
|
|
378
|
+
/**
|
|
379
|
+
* "standard" (default): passwords, payment, contact and identity fields (name, username, birthday,
|
|
380
|
+
* organization) and `redact` are left out of screenshots, and what anyone typed in a form is never kept
|
|
381
|
+
* with a comment. "strict": every form control's value and every editable region are left out of
|
|
382
|
+
* screenshots too.
|
|
383
|
+
*/
|
|
384
|
+
privacy?: "standard" | "strict";
|
|
339
385
|
/**
|
|
340
386
|
* Interface language, e.g. "fr" or "pt-BR". Defaults to the page's <html lang>,
|
|
341
387
|
* then the browser language. Built in: en, es, fr, de, pt-BR, it, nl, ja, zh-CN,
|
|
@@ -350,20 +396,57 @@ export interface CommentKitOptions {
|
|
|
350
396
|
/**
|
|
351
397
|
* Single-key shortcuts while the widget is shown: C to comment, J / K for next or previous,
|
|
352
398
|
* E to resolve, ? for the list. Default true. Set false when your app has its own shortcuts
|
|
353
|
-
* (WCAG 2.1.4). Esc and Cmd/Ctrl+Shift+K keep working.
|
|
399
|
+
* (WCAG 2.1.4). Esc and Cmd/Ctrl+Shift+K keep working (see `toggleShortcut`).
|
|
354
400
|
*/
|
|
355
401
|
shortcuts?: boolean;
|
|
402
|
+
/**
|
|
403
|
+
* Cmd/Ctrl+Shift+K shows the widget, and while it is shown opens the inbox. Default true. Set false
|
|
404
|
+
* when your site uses that combination itself; show the widget with `show()` or `comment()` instead.
|
|
405
|
+
* While the widget is hidden the key also reaches your page's own handlers.
|
|
406
|
+
*/
|
|
407
|
+
toggleShortcut?: boolean;
|
|
356
408
|
/**
|
|
357
409
|
* Turn parts of the comment tools off on this site. Each one defaults to on (screenshots also
|
|
358
410
|
* follow the dashboard setting). `text: false` stops selected text from becoming a quoted comment.
|
|
411
|
+
* `style` ("Adjust style": suggested CSS changes) and `checklist` are only ever offered to team
|
|
412
|
+
* members who can triage; set either to false to turn it off for them too.
|
|
359
413
|
*/
|
|
360
414
|
tools?: {
|
|
361
415
|
screenshots?: boolean;
|
|
362
416
|
markup?: boolean;
|
|
363
417
|
text?: boolean;
|
|
364
418
|
attachments?: boolean;
|
|
419
|
+
style?: boolean;
|
|
420
|
+
checklist?: boolean;
|
|
365
421
|
};
|
|
422
|
+
/**
|
|
423
|
+
* Sign the reviewer in from your website's own login ("Sign in from your website" in CommentKit, under
|
|
424
|
+
* Settings, For developers). Your **server** signs a short-lived token (HS256 JWT, at most 10 minutes) for
|
|
425
|
+
* the user who is signed in to your site, with the website's identity secret; the page passes it here.
|
|
426
|
+
* Give a function to fetch a fresh token: it is called again whenever the CommentKit session ends.
|
|
427
|
+
* Never put the identity secret in the page. The token is never stored, logged or put in a URL.
|
|
428
|
+
*
|
|
429
|
+
* With an identity the widget shows for that person, on production too, already signed in. A CommentKit
|
|
430
|
+
* team member who is signed in on this browser stays signed in as themselves. When the token is refused
|
|
431
|
+
* the widget emits `error` (with the API's code) and offers the normal sign-in.
|
|
432
|
+
*
|
|
433
|
+
* ```js
|
|
434
|
+
* // Node: the token for the signed-in user (npm install jsonwebtoken)
|
|
435
|
+
* app.get("/commentkit-token", requireLogin, (req, res) => {
|
|
436
|
+
* const now = Math.floor(Date.now() / 1000);
|
|
437
|
+
* res.type("text").send(jwt.sign({ sub: String(req.user.id), email: req.user.email, name: req.user.name, aud: "pk_live_…", iat: now, exp: now + 300 },
|
|
438
|
+
* process.env.COMMENTKIT_IDENTITY_SECRET, { algorithm: "HS256" }));
|
|
439
|
+
* });
|
|
440
|
+
* // In the page:
|
|
441
|
+
* init({ project: "pk_live_…", identity: () => fetch("/commentkit-token").then((r) => r.text()) });
|
|
442
|
+
* ```
|
|
443
|
+
*
|
|
444
|
+
* See https://commentkit.dev/docs/identify
|
|
445
|
+
*/
|
|
446
|
+
identity?: IdentitySource;
|
|
366
447
|
}
|
|
448
|
+
/** A host-app sign-in token (`CommentKitOptions.identity`), or a function giving one (or a Promise of one). */
|
|
449
|
+
export type IdentitySource = string | (() => string | Promise<string>);
|
|
367
450
|
export interface CommentKitEvents {
|
|
368
451
|
ready: {
|
|
369
452
|
session: Session | null;
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* theme, position, auth, endpoint, deployment-url, hide-on-production="false", shortcuts="false". Changing project
|
|
5
|
-
* restarts the widget.
|
|
6
|
-
*/
|
|
7
|
-
export declare class CommentKitElement extends HTMLElement {
|
|
1
|
+
/** Importing this file on the server (SSR, Node) must not fail: there is no HTMLElement to extend there. */
|
|
2
|
+
declare const Base: typeof HTMLElement;
|
|
3
|
+
export declare class CommentKitElement extends Base {
|
|
8
4
|
static observedAttributes: string[];
|
|
9
5
|
private kit;
|
|
6
|
+
/** The settings `kit` was started with, to restart only when one really changed. */
|
|
7
|
+
private started;
|
|
10
8
|
attributeChangedCallback(_name: string, before: string | null, after: string | null): void;
|
|
11
9
|
connectedCallback(): void;
|
|
10
|
+
private options;
|
|
11
|
+
/**
|
|
12
|
+
* Sign your site's user in with a token from your server (init()'s `identity`). Resolves false when the
|
|
13
|
+
* token was refused or the element is not started (not in the page, or no project); never rejects.
|
|
14
|
+
*/
|
|
15
|
+
identify(token: string): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Sign the reviewer out of CommentKit on this browser, for example when they log out of your website.
|
|
18
|
+
* Does nothing when the element is not started; never rejects.
|
|
19
|
+
*/
|
|
20
|
+
signOut(): Promise<void>;
|
|
12
21
|
disconnectedCallback(): void;
|
|
13
22
|
}
|
|
23
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/** Headless client for custom UIs, extensions and tests. No UI, no globals. */
|
|
2
1
|
export { CommentKitClient, currentPageUrl, EDIT_CONFLICT, SDK_VERSION } from "./core/client.js";
|
|
2
|
+
export { pageKey } from "./core/page-key.js";
|
|
3
3
|
export { ApiClient } from "./core/api.js";
|
|
4
4
|
export { AuthManager } from "./core/auth.js";
|
|
5
5
|
export { createAnchor, resolveAnchor, stableSelector } from "./anchor/index.js";
|
|
6
|
+
export { configurePrivacy } from "./capture/privacy.js";
|
|
6
7
|
export type * from "./core/types.js";
|
|
7
8
|
export { CommentKitError } from "./core/types.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommentKitClient, SDK_VERSION } from "./core/client.js";
|
|
2
2
|
import { type CommentKitEvents, type CommentKitOptions, type Session } from "./core/types.js";
|
|
3
|
-
export type { Anchor, Attachment, Capabilities, CaptureInput, ChecklistItem, CommentKitEvents, CommentKitOptions, Environment, InboxItem, MarkupShape, Message, Page, Person, Position, Reaction, Session, StyleChange, StyleProperty, Thread, TaskInput, ThreadPriority, ThreadStatus, WidgetConfig, } from "./core/types.js";
|
|
3
|
+
export type { Anchor, Attachment, Capabilities, CaptureInput, ChecklistItem, CommentKitEvents, CommentKitOptions, Environment, IdentitySource, InboxItem, MarkupShape, Message, Page, Person, Position, Reaction, Session, StyleChange, StyleProperty, Thread, TaskInput, ThreadPriority, ThreadStatus, WidgetConfig, } from "./core/types.js";
|
|
4
4
|
export { CommentKitError } from "./core/types.js";
|
|
5
5
|
export { SDK_VERSION };
|
|
6
6
|
export interface CommentKit {
|
|
@@ -15,13 +15,23 @@ export interface CommentKit {
|
|
|
15
15
|
* `comment(false)` stops it. Listen to the `mode` event to follow it.
|
|
16
16
|
*/
|
|
17
17
|
comment(on?: boolean): Promise<void>;
|
|
18
|
-
/** Open the sign-in window. Call from a click handler. */
|
|
18
|
+
/** Open the sign-in window. Call from a click handler. Resolves false when it did not sign in; never rejects. */
|
|
19
19
|
signIn(): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Sign the reviewer in from your website's own login, with a token your server made for them (see
|
|
22
|
+
* `CommentKitOptions.identity`), for example right after they log in to your site. Shows the widget
|
|
23
|
+
* when it is not shown yet. Resolves true when they are signed in, false when the token was refused
|
|
24
|
+
* (the `error` event says why); never rejects. A CommentKit team member signed in here stays signed in.
|
|
25
|
+
*/
|
|
26
|
+
identify(token: string): Promise<boolean>;
|
|
20
27
|
signOut(): Promise<void>;
|
|
21
|
-
/** Current person, if signed in. */
|
|
28
|
+
/** Current person, if signed in (without their email address). */
|
|
22
29
|
session(): Session | null;
|
|
23
30
|
on<K extends keyof CommentKitEvents>(event: K, listener: (payload: CommentKitEvents[K]) => void): () => void;
|
|
24
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Release this handle: its listeners are removed, and when it was the last one (every init() call returns
|
|
33
|
+
* its own handle), the widget and everything CommentKit added to the page are removed too.
|
|
34
|
+
*/
|
|
25
35
|
destroy(): void;
|
|
26
36
|
readonly client: CommentKitClient;
|
|
27
37
|
}
|
|
@@ -31,7 +41,7 @@ export interface CommentKit {
|
|
|
31
41
|
* import { init } from "@commentkit/comment-kit";
|
|
32
42
|
* init({ project: "pk_live_…" });
|
|
33
43
|
*
|
|
34
|
-
* Safe to call more than once:
|
|
35
|
-
* Never throws into the host page.
|
|
44
|
+
* Safe to call more than once: each call returns its own handle onto the same widget, which stays
|
|
45
|
+
* until the last handle is destroyed. Never throws into the host page.
|
|
36
46
|
*/
|
|
37
47
|
export declare function init(input: CommentKitOptions): CommentKit;
|