@flonkid/kyc 1.6.1 → 1.8.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.d.ts CHANGED
@@ -12,9 +12,15 @@ interface WidgetInitConfig {
12
12
  * Your project's publishable key (`pk_live_*` or `pk_sandbox_*`).
13
13
  * Found in Dashboard → Project Settings → API Keys.
14
14
  *
15
- * When used with `serverUrl`, enables instant branded loading screen
16
- * by fetching design tokens in parallel with session creation.
17
- * Recommended for the best user experience.
15
+ * Enables an instant branded loading screen: the brand color is resolved
16
+ * directly from the key (a Redis-cached read) in parallel with session
17
+ * setup, so the loader paints your color on first frame instead of waiting
18
+ * on the session. Works with both flows:
19
+ * - `serverUrl` (your backend creates the session), and
20
+ * - `sessionId` + `embedToken` (you pass a pre-created session).
21
+ *
22
+ * Without it, branding is resolved from the session and the loader shows
23
+ * the default color until that request returns. Recommended for the best UX.
18
24
  */
19
25
  publishableKey?: string;
20
26
  sessionId?: string;
@@ -74,18 +80,38 @@ interface VerificationResult {
74
80
  }
75
81
 
76
82
  declare class FlonkKYC {
77
- static readonly version = "1.6.0";
83
+ static readonly version = "1.8.0";
78
84
  private readonly widgetUrl;
79
85
  private readonly apiBase;
80
86
  constructor(options?: FlonkKYCOptions);
87
+ /**
88
+ * Warm the project's branding (colors) ahead of time so the widget paints the
89
+ * brand color on the first frame, with no branding round-trip at click time.
90
+ *
91
+ * Call it early — on page mount, route enter, or hover of the "verify" button
92
+ * — well before `init()`. The result is cached (module-level, 5-min TTL) and
93
+ * every subsequent `init()`/`open()` for the same key reads from it. Safe to
94
+ * call repeatedly; concurrent calls dedupe. Never throws.
95
+ *
96
+ * @example
97
+ * // in a layout effect, long before the user clicks "Verify"
98
+ * FlonkKYC.preloadBranding({ publishableKey: 'pk_live_...' });
99
+ */
100
+ static preloadBranding(opts: {
101
+ publishableKey?: string;
102
+ sessionId?: string;
103
+ apiBase?: string;
104
+ }): Promise<void>;
81
105
  /**
82
106
  * Open the KYC verification widget.
83
107
  *
84
- * Flows (pick one):
85
- * 1. `{ serverUrl, publishableKey }` — auto-create session via your backend (recommended).
86
- * `publishableKey` enables instant branded loader (~200-500ms faster).
87
- * 2. `{ sessionId, embedToken }` — server-to-server with pre-created session
88
- * 3. `{ publishableKey }` client-side only (legacy)
108
+ * Flows (pick one; add `publishableKey` to any for an instant branded loader):
109
+ * 1. `{ serverUrl }` — SDK auto-creates the session via your backend (recommended).
110
+ * 2. `{ sessionId, embedToken }` you created the session; pass its credentials.
111
+ * 3. `{ sessionId }` — **deprecated**: exchanges the sessionId for an embedToken
112
+ * via an extra round-trip. Prefer flow 2 by returning `embedToken` from your
113
+ * backend alongside `sessionId`.
114
+ * 4. `{ publishableKey }` — client-only; SDK mints a short-lived widget token.
89
115
  */
90
116
  init(config: WidgetInitConfig): Promise<WidgetInstance>;
91
117
  /**
@@ -110,6 +136,10 @@ declare class FlonkKYC {
110
136
  private initWithEmbedToken;
111
137
  /**
112
138
  * Flow 3: sessionId only — exchange for embedToken, then init.
139
+ *
140
+ * @deprecated Prefer flow 2 (`sessionId` + `embedToken`). Return the
141
+ * `embedToken` from your backend together with the `sessionId` to skip this
142
+ * extra token-exchange round-trip.
113
143
  */
114
144
  private initWithSession;
115
145
  /**
@@ -148,6 +178,23 @@ interface FlonkKYCProps extends FlonkKYCOptions {
148
178
  autoOpen?: boolean;
149
179
  }
150
180
  declare function FlonkKYCWidget({ widgetUrl, apiBase, autoOpen, publishableKey, serverUrl, sessionId, embedToken, clientMetadata, lang, overlayColor, allowManualUpload, requestHeaders, onSuccess, onError, onCancel, onReady, }: FlonkKYCProps): react_jsx_runtime.JSX.Element;
181
+ interface FlonkKYCBrandingPreloaderProps {
182
+ publishableKey?: string;
183
+ sessionId?: string;
184
+ apiBase?: string;
185
+ }
186
+ /**
187
+ * Invisible helper that warms the project's branding cache on mount, so the
188
+ * widget paints the brand color on the first frame when the user later opens it.
189
+ *
190
+ * Mount it high in the tree (e.g. an authenticated layout) so branding is ready
191
+ * long before the user reaches the verification screen. Renders nothing.
192
+ *
193
+ * @example
194
+ * // app/(authed)/layout.tsx
195
+ * <FlonkKYCBrandingPreloader publishableKey={process.env.NEXT_PUBLIC_FLONK_PK} />
196
+ */
197
+ declare function FlonkKYCBrandingPreloader({ publishableKey, sessionId, apiBase, }: FlonkKYCBrandingPreloaderProps): null;
151
198
 
152
199
  declare class FlonkError extends Error {
153
200
  readonly code: string;
@@ -158,4 +205,4 @@ declare class FlonkValidationError extends FlonkError {
158
205
  constructor(message: string);
159
206
  }
160
207
 
161
- export { type DocumentType, type EmbedInstance, FlonkError, FlonkKYC, type FlonkKYCOptions, type FlonkKYCProps, FlonkKYCWidget, FlonkValidationError, type PreviewColors, type VerificationResult, type WidgetEmbedConfig, type WidgetInitConfig, type WidgetInstance, type WidgetLanguage, type WidgetPreviewConfig };
208
+ export { type DocumentType, type EmbedInstance, FlonkError, FlonkKYC, FlonkKYCBrandingPreloader, type FlonkKYCBrandingPreloaderProps, type FlonkKYCOptions, type FlonkKYCProps, FlonkKYCWidget, FlonkValidationError, type PreviewColors, type VerificationResult, type WidgetEmbedConfig, type WidgetInitConfig, type WidgetInstance, type WidgetLanguage, type WidgetPreviewConfig };