@kwik-id/sdk-react 0.1.0-alpha.3

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 (86) hide show
  1. package/README.md +311 -0
  2. package/dist/assets/animations/id_scan.json.d.ts +3250 -0
  3. package/dist/assets/animations/selfie.json.d.ts +3269 -0
  4. package/dist/assets/image-processor.worker-B6Di_lR_.js +1 -0
  5. package/dist/components/themed-photo-back-svg.d.ts +4 -0
  6. package/dist/components/themed-photo-back-svg.d.ts.map +1 -0
  7. package/dist/components/themed-welcome-svg.d.ts +4 -0
  8. package/dist/components/themed-welcome-svg.d.ts.map +1 -0
  9. package/dist/context/kwik-id-context.d.ts +125 -0
  10. package/dist/context/kwik-id-context.d.ts.map +1 -0
  11. package/dist/hooks/index.d.ts +16 -0
  12. package/dist/hooks/index.d.ts.map +1 -0
  13. package/dist/hooks/kwik-id-context.d.ts +53 -0
  14. package/dist/hooks/kwik-id-context.d.ts.map +1 -0
  15. package/dist/hooks/use-camera.d.ts +64 -0
  16. package/dist/hooks/use-camera.d.ts.map +1 -0
  17. package/dist/hooks/use-face-detection.d.ts +68 -0
  18. package/dist/hooks/use-face-detection.d.ts.map +1 -0
  19. package/dist/hooks/use-handoff.d.ts +19 -0
  20. package/dist/hooks/use-handoff.d.ts.map +1 -0
  21. package/dist/hooks/use-kwik-id.d.ts +27 -0
  22. package/dist/hooks/use-kwik-id.d.ts.map +1 -0
  23. package/dist/hooks/use-liveness.d.ts +73 -0
  24. package/dist/hooks/use-liveness.d.ts.map +1 -0
  25. package/dist/hooks/use-quality.d.ts +59 -0
  26. package/dist/hooks/use-quality.d.ts.map +1 -0
  27. package/dist/hooks/use-verification.d.ts +80 -0
  28. package/dist/hooks/use-verification.d.ts.map +1 -0
  29. package/dist/index.d.ts +39 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +8383 -0
  32. package/dist/services/api.service.d.ts +136 -0
  33. package/dist/services/api.service.d.ts.map +1 -0
  34. package/dist/services/index.d.ts +2 -0
  35. package/dist/services/index.d.ts.map +1 -0
  36. package/dist/utils/image-compression.d.ts +25 -0
  37. package/dist/utils/image-compression.d.ts.map +1 -0
  38. package/dist/utils/image-quality.d.ts +37 -0
  39. package/dist/utils/image-quality.d.ts.map +1 -0
  40. package/dist/utils/image-worker.d.ts +14 -0
  41. package/dist/utils/image-worker.d.ts.map +1 -0
  42. package/dist/utils/index.d.ts +4 -0
  43. package/dist/utils/index.d.ts.map +1 -0
  44. package/dist/utils/upload-manager.d.ts +69 -0
  45. package/dist/utils/upload-manager.d.ts.map +1 -0
  46. package/dist/views/consent-step.d.ts +9 -0
  47. package/dist/views/consent-step.d.ts.map +1 -0
  48. package/dist/views/document-upload-step.d.ts +10 -0
  49. package/dist/views/document-upload-step.d.ts.map +1 -0
  50. package/dist/views/handoff-choice-view.d.ts +7 -0
  51. package/dist/views/handoff-choice-view.d.ts.map +1 -0
  52. package/dist/views/handoff-qr-view.d.ts +10 -0
  53. package/dist/views/handoff-qr-view.d.ts.map +1 -0
  54. package/dist/views/kid-branding.d.ts +3 -0
  55. package/dist/views/kid-branding.d.ts.map +1 -0
  56. package/dist/views/kwik-id.d.ts +50 -0
  57. package/dist/views/kwik-id.d.ts.map +1 -0
  58. package/dist/views/kyc-form.d.ts +2 -0
  59. package/dist/views/kyc-form.d.ts.map +1 -0
  60. package/dist/views/kyc-modal-flow.d.ts +10 -0
  61. package/dist/views/kyc-modal-flow.d.ts.map +1 -0
  62. package/dist/views/kyc-substeps/camera-capture.d.ts +11 -0
  63. package/dist/views/kyc-substeps/camera-capture.d.ts.map +1 -0
  64. package/dist/views/kyc-substeps/document-type-selection.d.ts +8 -0
  65. package/dist/views/kyc-substeps/document-type-selection.d.ts.map +1 -0
  66. package/dist/views/kyc-substeps/intro-step.d.ts +6 -0
  67. package/dist/views/kyc-substeps/intro-step.d.ts.map +1 -0
  68. package/dist/views/kyc-substeps/photo-confirmation.d.ts +10 -0
  69. package/dist/views/kyc-substeps/photo-confirmation.d.ts.map +1 -0
  70. package/dist/views/kyc-substeps/prepare-id-back.d.ts +8 -0
  71. package/dist/views/kyc-substeps/prepare-id-back.d.ts.map +1 -0
  72. package/dist/views/kyc-substeps/prepare-id-front.d.ts +8 -0
  73. package/dist/views/kyc-substeps/prepare-id-front.d.ts.map +1 -0
  74. package/dist/views/kyc-substeps/prepare-selfie.d.ts +6 -0
  75. package/dist/views/kyc-substeps/prepare-selfie.d.ts.map +1 -0
  76. package/dist/views/kyc-substeps/selfie-confirmation.d.ts +8 -0
  77. package/dist/views/kyc-substeps/selfie-confirmation.d.ts.map +1 -0
  78. package/dist/views/selfie-step.d.ts +10 -0
  79. package/dist/views/selfie-step.d.ts.map +1 -0
  80. package/dist/views/step-indicator.d.ts +13 -0
  81. package/dist/views/step-indicator.d.ts.map +1 -0
  82. package/dist/views/verification-step.d.ts +13 -0
  83. package/dist/views/verification-step.d.ts.map +1 -0
  84. package/dist/workers/image-processor.worker.d.ts +19 -0
  85. package/dist/workers/image-processor.worker.d.ts.map +1 -0
  86. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,311 @@
1
+ # @kwik-id/sdk-react
2
+
3
+ React SDK for [KwikID](https://kwik-id.com) identity verification. Drop-in components and hooks for adding KYC verification to your React application.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @kwik-id/sdk-react
9
+ # or
10
+ pnpm add @kwik-id/sdk-react
11
+ # or
12
+ yarn add @kwik-id/sdk-react
13
+ ```
14
+
15
+ **Peer dependencies:** `react >= 18`, `react-dom >= 18`, `framer-motion >= 10`, `lucide-react >= 0.300`
16
+
17
+ ## Quick Start
18
+
19
+ The fastest way to add verification is the `<KwikID>` component — a complete, pre-built verification flow.
20
+
21
+ ### 1. Create a session on your backend
22
+
23
+ Use [`@kwik-id/sdk-node`](https://www.npmjs.com/package/@kwik-id/sdk-node) to create a session server-side:
24
+
25
+ ```ts
26
+ // Backend (Express, Next.js API route, etc.)
27
+ import { KwikIDNode } from "@kwik-id/sdk-node";
28
+
29
+ const kwikId = new KwikIDNode({ apiKey: process.env.KWIKID_API_KEY! });
30
+
31
+ app.post("/api/create-session", async (req, res) => {
32
+ const session = await kwikId.createSession({
33
+ referenceId: req.user.id,
34
+ userName: req.user.name,
35
+ });
36
+ res.json({ clientSecret: session.token });
37
+ });
38
+ ```
39
+
40
+ ### 2. Use the KwikID component in your frontend
41
+
42
+ ```tsx
43
+ import { KwikID } from "@kwik-id/sdk-react";
44
+
45
+ function VerificationPage() {
46
+ const [clientSecret, setClientSecret] = useState<string | null>(null);
47
+
48
+ useEffect(() => {
49
+ fetch("/api/create-session", { method: "POST" })
50
+ .then((res) => res.json())
51
+ .then((data) => setClientSecret(data.clientSecret));
52
+ }, []);
53
+
54
+ if (!clientSecret) return <div>Loading...</div>;
55
+
56
+ return (
57
+ <KwikID
58
+ config={{
59
+ clientSecret,
60
+ appName: "My App",
61
+ theme: { primary: "#2563EB", accent: "#FBBF24" },
62
+ onSubmitted: ({ jobId }) => {
63
+ // Fires immediately when documents are uploaded and background
64
+ // processing begins. Save the jobId to track status via webhooks.
65
+ console.log("Submitted for review, jobId:", jobId);
66
+ },
67
+ onComplete: (data) => {
68
+ // Fires when the user dismisses the result screen (clicks "Done").
69
+ // Use this to redirect or clean up.
70
+ console.log("User dismissed verification modal", data);
71
+ },
72
+ onError: (error) => {
73
+ console.error("Verification error:", error);
74
+ },
75
+ }}
76
+ />
77
+ );
78
+ }
79
+ ```
80
+
81
+ That's it — the component handles the full flow: document selection, camera capture, quality checks, face detection, liveness, and submission. The modal opens automatically when the component renders.
82
+
83
+ ## Configuration
84
+
85
+ ### `KwikIDConfig`
86
+
87
+ | Prop | Type | Required | Description |
88
+ | -------------- | ------------------------ | -------- | -------------------------------------------------------------------------------------------------------------- |
89
+ | `clientSecret` | `string` | Yes | Session token from your backend |
90
+ | `appName` | `string` | No | App name shown in the header (falls back to org name) |
91
+ | `baseUrl` | `string` | No | API base URL (defaults to production) |
92
+ | `theme` | `KwikIDTheme` | No | Custom theme colors |
93
+ | `showLogo` | `boolean` | No | Show org logo in header (default: `true`) |
94
+ | `onSubmitted` | `({ jobId }) => void` | No | Called immediately when documents are uploaded and background processing begins. Use this to save the `jobId`. |
95
+ | `onComplete` | `(data) => void` | No | Called when the user dismisses the result screen (clicks "Done") |
96
+ | `onError` | `(error: Error) => void` | No | Called on errors |
97
+
98
+ ### `KwikIDTheme`
99
+
100
+ ```ts
101
+ {
102
+ primary?: string; // Primary brand color (hex, e.g. "#2563EB")
103
+ accent?: string; // Accent color (hex)
104
+ background?: string; // Background color (hex)
105
+ foreground?: string; // Foreground/text color (hex)
106
+ }
107
+ ```
108
+
109
+ ## Components
110
+
111
+ ### `<KwikID>` — Drop-in Verification
112
+
113
+ The all-in-one component. Renders a complete verification flow with document selection, camera capture, quality feedback, liveness detection, and submission.
114
+
115
+ ```tsx
116
+ <KwikID config={{ clientSecret, appName: "My App" }} />
117
+ ```
118
+
119
+ ### `<KYCModalFlow>` — Modal Verification
120
+
121
+ Renders the verification flow inside a modal dialog with step indicators.
122
+
123
+ ```tsx
124
+ import { KYCModalFlow } from "@kwik-id/sdk-react";
125
+ ```
126
+
127
+ ### `<KwikIDProvider>` — Context Provider
128
+
129
+ For custom integrations, wrap your components with the provider to access SDK state via hooks.
130
+
131
+ ```tsx
132
+ import { KwikIDProvider, useKwikID } from "@kwik-id/sdk-react";
133
+
134
+ function App() {
135
+ return (
136
+ <KwikIDProvider config={{ clientSecret, appName: "My App" }} clientSecret={clientSecret}>
137
+ <CustomVerificationFlow />
138
+ </KwikIDProvider>
139
+ );
140
+ }
141
+
142
+ function CustomVerificationFlow() {
143
+ const {
144
+ sdk,
145
+ isSDKReady,
146
+ qualityResult,
147
+ detectedFace,
148
+ analyzeQuality,
149
+ detectFace,
150
+ submitVerification,
151
+ } = useKwikID();
152
+
153
+ // Build your own UI using SDK state and actions
154
+ }
155
+ ```
156
+
157
+ ### Individual Steps
158
+
159
+ Build custom flows by composing individual step components:
160
+
161
+ ```tsx
162
+ import {
163
+ CameraCapture,
164
+ ConsentStep,
165
+ DocumentTypeSelection,
166
+ IntroStep,
167
+ PhotoConfirmation,
168
+ PrepareIDBack,
169
+ PrepareIDFront,
170
+ PrepareSelfie,
171
+ SelfieConfirmation,
172
+ } from "@kwik-id/sdk-react";
173
+ ```
174
+
175
+ ### Cross-Device Handoff
176
+
177
+ Let desktop users continue verification on their phone:
178
+
179
+ ```tsx
180
+ import { HandoffChoiceView, HandoffQRView, useHandoff } from "@kwik-id/sdk-react";
181
+ ```
182
+
183
+ ## Hooks
184
+
185
+ For advanced custom integrations, use hooks directly:
186
+
187
+ ### `useKwikId(config)`
188
+
189
+ Core hook that manages the full SDK lifecycle.
190
+
191
+ ```tsx
192
+ const { sdk, state, status, submit, captures, events } = useKwikId({
193
+ clientSecret,
194
+ baseUrl: "https://api.kwik-id.com",
195
+ });
196
+ ```
197
+
198
+ ### `useCamera(options)`
199
+
200
+ Camera access and frame capture.
201
+
202
+ ```tsx
203
+ const { videoRef, stream, start, stop, capture } = useCamera({
204
+ facingMode: "environment",
205
+ width: 1280,
206
+ height: 720,
207
+ });
208
+ ```
209
+
210
+ ### `useQuality(options)`
211
+
212
+ Real-time image quality analysis.
213
+
214
+ ```tsx
215
+ const { analyze, result, isAcceptable } = useQuality({
216
+ minBrightness: 0.3,
217
+ maxBrightness: 0.9,
218
+ });
219
+ ```
220
+
221
+ ### `useFaceDetection(options)`
222
+
223
+ Face detection and alignment feedback.
224
+
225
+ ```tsx
226
+ const { detect, face, alignment, isAligned } = useFaceDetection();
227
+ ```
228
+
229
+ ### `useLiveness(options)`
230
+
231
+ Passive and active liveness detection.
232
+
233
+ ```tsx
234
+ const { check, result, isLive } = useLiveness();
235
+ ```
236
+
237
+ ### `useVerification(options)`
238
+
239
+ Full verification workflow state machine.
240
+
241
+ ```tsx
242
+ const { step, next, back, submit, isComplete } = useVerification({
243
+ clientSecret,
244
+ onComplete: (data) => console.log("Done", data),
245
+ });
246
+ ```
247
+
248
+ ### `useHandoff()`
249
+
250
+ Cross-device handoff (QR code transfer from desktop to mobile).
251
+
252
+ ```tsx
253
+ const { startHandoff, handoffState, handoffUrl } = useHandoff();
254
+ ```
255
+
256
+ ## Utilities
257
+
258
+ ```tsx
259
+ import {
260
+ // Check image sharpness
261
+ UploadManager, // Manage file uploads
262
+ // Compress images before upload
263
+ analyzeImageQuality,
264
+ // Check image brightness
265
+ checkBlur,
266
+ // Analyze image quality from a frame
267
+ checkLuminance,
268
+ compressImage,
269
+ } from "@kwik-id/sdk-react";
270
+ ```
271
+
272
+ ## TypeScript
273
+
274
+ All types are exported for full TypeScript support:
275
+
276
+ ```tsx
277
+ import type {
278
+ AlignmentResult,
279
+ DetectedFace,
280
+ DocumentData,
281
+ KYCFormData,
282
+ KwikIdConfig,
283
+ KwikIdTheme,
284
+ PassiveLivenessResult,
285
+ QualityResult,
286
+ SDKState,
287
+ SDKStatus,
288
+ SelfieData,
289
+ VerificationResult,
290
+ } from "@kwik-id/sdk-react";
291
+ ```
292
+
293
+ ## Supported Document Types
294
+
295
+ - National ID Card
296
+ - Passport
297
+ - Driver's License
298
+ - Voter's Card
299
+
300
+ ## Browser Support
301
+
302
+ - Chrome 80+
303
+ - Firefox 78+
304
+ - Safari 14+
305
+ - Edge 80+
306
+
307
+ Camera access requires HTTPS in production (except `localhost` for development).
308
+
309
+ ## License
310
+
311
+ MIT