@createlex/onetapforms-sdk 1.1.4 → 1.2.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/README.md CHANGED
@@ -1,259 +1,320 @@
1
1
  # @createlex/onetapforms-sdk
2
2
 
3
- OneTapForms SDK for secure, biometric-authenticated form completion. This SDK enables websites to offer instant form completion through Face ID/Touch ID authentication on iOS devices.
3
+ OneTapForms SDK for secure, biometric-authenticated form completion. Enable instant form completion through Face ID/Touch ID authentication on iOS devices.
4
4
 
5
- ## 🆓 Free for Developers
5
+ ## Quick Start (30 seconds)
6
6
 
7
- **The SDK is completely free to use!** There are no fees, usage limits, or restrictions for developers integrating OneTapForms into their websites.
7
+ Choose the installation method that matches your skill level:
8
8
 
9
- ### Why Developers Love OneTapForms
9
+ ### Option 1: Script Tag (Easiest - No Build Tools Required)
10
10
 
11
- Integrating OneTapForms benefits your business directly:
11
+ Perfect for HTML websites, WordPress, or any site where you can add a script tag:
12
12
 
13
- - ⚡ **Faster Form Completion** - Users fill forms in seconds instead of minutes
14
- - 📈 **Higher Conversion Rates** - Reduce form abandonment with one-tap completion
15
- - 🎯 **Better User Experience** - Eliminate typing errors and friction
16
- - 🔒 **Verified Data** - Receive pre-verified, accurate user information
17
- - 💰 **No Cost to You** - Free SDK, zero integration fees
13
+ ```html
14
+ <!-- 1. Add the script to your page -->
15
+ <script src="https://cdn.jsdelivr.net/npm/@createlex/onetapforms-sdk@latest/dist/onetapforms.umd.min.js"></script>
18
16
 
19
- **Encourage your users to download the OneTapForms app** - it helps them complete your forms faster, which means more completed applications, signups, and conversions for you!
17
+ <!-- 2. Add a button with data attributes -->
18
+ <button
19
+ data-onetapforms
20
+ data-client-id="YOUR_CLIENT_ID"
21
+ data-purpose="Complete your profile"
22
+ data-bundles="basic,contact">
23
+ Fill with OneTapForms
24
+ </button>
20
25
 
21
- Revenue comes from end users who subscribe to the OneTapForms service ($9-29/month) to securely store their profile data. Your users pay for the convenience, not you.
26
+ <!-- 3. Handle the result -->
27
+ <script>
28
+ document.querySelector('[data-onetapforms]')
29
+ .addEventListener('onetapforms:complete', function(e) {
30
+ console.log('Token:', e.detail.token);
31
+ // Send token to your server to get user data
32
+ });
33
+ </script>
34
+ ```
35
+
36
+ That's it! The SDK automatically shows a QR modal when the button is clicked.
22
37
 
23
- ## Installation
38
+ ### Option 2: npm Install (For React, Vue, Next.js, etc.)
24
39
 
25
40
  ```bash
26
41
  npm install @createlex/onetapforms-sdk
27
42
  ```
28
43
 
29
- ## Quick Start
30
-
31
- ### 1. Initialize the SDK
32
-
33
44
  ```javascript
34
45
  import { OneTapForms } from '@createlex/onetapforms-sdk';
35
46
 
36
- const onetapforms = new OneTapForms({
37
- clientId: 'your_client_id',
38
- apiUrl: 'https://api.createlex.com',
39
- debug: true // Enable console logging
47
+ const onetap = new OneTapForms({
48
+ clientId: 'YOUR_CLIENT_ID',
49
+ clientSecret: 'YOUR_CLIENT_SECRET'
40
50
  });
41
- ```
42
-
43
- ### 2. Create a Request
44
51
 
45
- ```javascript
46
- await onetapforms.request({
47
- schemaId: 'job_application',
48
- purpose: 'Job application at YourCompany',
49
- returnUrl: 'https://yoursite.com/apply/callback',
52
+ await onetap.request({
53
+ purpose: 'Job Application',
50
54
  bundles: ['basic', 'contact'],
51
-
52
- // Called when QR code is ready (desktop users)
53
- onQRReady: (qrDataUrl) => {
54
- document.getElementById('qr-code').src = qrDataUrl;
55
+ onQRReady: (qrUrl) => {
56
+ // Show QR code to user
57
+ document.getElementById('qr').src = qrUrl;
55
58
  },
56
-
57
- // Called when user approves the request
58
- onComplete: ({ token, requestId }) => {
59
- // Exchange token for user data on your server
60
- exchangeTokenForData(token);
61
- },
62
-
63
- // Called if an error occurs
64
- onError: (error) => {
65
- console.error('OneTapForms error:', error);
59
+ onComplete: ({ token }) => {
60
+ // Exchange token for data on your server
61
+ fetch('/api/exchange', {
62
+ method: 'POST',
63
+ body: JSON.stringify({ token })
64
+ });
66
65
  }
67
66
  });
68
67
  ```
69
68
 
70
- ### 2.5. Encourage App Downloads (Optional but Recommended)
69
+ ---
71
70
 
72
- Help users discover OneTapForms to get faster form completion:
71
+ ## Free for Developers
73
72
 
74
- ```javascript
75
- // Show download prompt if user doesn't have the app
76
- if (!onetapforms.isAppLikelyInstalled()) {
77
- onetapforms.showDownloadPrompt({
78
- title: 'Complete Forms Faster!',
79
- message: 'Download OneTapForms to fill this form in seconds with Face ID/Touch ID.',
80
- buttonText: 'Download App'
81
- });
82
- }
73
+ **The SDK is completely free!** No fees, usage limits, or restrictions.
83
74
 
84
- // Or add a download button to your UI
85
- const downloadUrl = onetapforms.getAppDownloadUrl();
86
- // <a href={downloadUrl}>Download OneTapForms App</a>
87
- ```
75
+ - **Faster Form Completion** - Users fill forms in seconds
76
+ - **Higher Conversion Rates** - Reduce form abandonment
77
+ - **Better UX** - No typing errors
78
+ - **Verified Data** - Pre-verified user information
79
+ - **Zero Cost** - Free SDK, free integration
88
80
 
89
- ### 3. Handle Mobile Redirect Callback
81
+ Revenue comes from end users who subscribe to OneTapForms ($9-29/month) to store their data securely.
90
82
 
91
- If using redirect mode on mobile, handle the callback:
83
+ ---
92
84
 
93
- ```javascript
94
- // On your callback page
95
- const result = onetapforms.handleCallback();
96
- if (result) {
97
- const { token, requestId } = result;
98
- // Exchange token for user data on your server
99
- exchangeTokenForData(token);
100
- }
101
- ```
85
+ ## Widget Mode Reference (Script Tag)
102
86
 
103
- ### 4. Exchange Token for Data (Server-Side)
87
+ ### Data Attributes
104
88
 
105
- **Important:** Always exchange tokens server-side to protect your API key.
89
+ | Attribute | Required | Description |
90
+ |-----------|----------|-------------|
91
+ | `data-onetapforms` | Yes | Marks element as OneTapForms trigger |
92
+ | `data-client-id` | Yes | Your client ID |
93
+ | `data-client-secret` | No | Your client secret |
94
+ | `data-purpose` | No | Purpose shown to user (default: "Complete form") |
95
+ | `data-bundles` | No | Comma-separated bundles (default: "basic") |
96
+ | `data-form-id` | No | Auto-inject token into this form |
97
+ | `data-api-url` | No | Custom API URL |
98
+
99
+ ### Events
100
+
101
+ Listen for these custom events on your button/element:
106
102
 
107
103
  ```javascript
108
- // Node.js example (server-side)
109
- const response = await fetch('https://api.createlex.com/api/onetapforms/exchange', {
110
- method: 'POST',
111
- headers: {
112
- 'Content-Type': 'application/json',
113
- 'X-API-Key': 'your_api_key'
114
- },
115
- body: JSON.stringify({ token })
104
+ // Success - user approved the request
105
+ element.addEventListener('onetapforms:complete', (e) => {
106
+ const { token, requestId } = e.detail;
107
+ // Send token to your server
116
108
  });
117
109
 
118
- const { data } = await response.json();
119
- // Use the user data to fill your form
110
+ // Error - something went wrong
111
+ element.addEventListener('onetapforms:error', (e) => {
112
+ const { error } = e.detail;
113
+ console.error('Failed:', error.message);
114
+ });
120
115
  ```
121
116
 
122
- ## API Reference
117
+ ### Auto-Inject Token into Form
123
118
 
124
- ### `OneTapForms(config)`
119
+ Use `data-form-id` to automatically add the token to a form:
125
120
 
126
- Creates a new OneTapForms instance.
121
+ ```html
122
+ <form id="myForm" method="POST" action="/submit">
123
+ <input type="text" name="email" placeholder="Email">
127
124
 
128
- **Parameters:**
129
- - `config.clientId` (string, required): Your client ID
130
- - `config.clientSecret` (string, optional): Your client secret (recommended for authenticated requests)
131
- - `config.apiUrl` (string, optional): API URL (defaults to `https://api.createlex.com`)
132
- - `config.apiKey` (string, optional): API key for legacy auth (defaults to `clientId`)
133
- - `config.debug` (boolean, optional): Enable debug logging (defaults to `false`)
125
+ <button
126
+ type="button"
127
+ data-onetapforms
128
+ data-client-id="YOUR_ID"
129
+ data-form-id="myForm">
130
+ Autofill with OneTapForms
131
+ </button>
134
132
 
135
- ### `request(options)`
133
+ <button type="submit">Submit</button>
134
+ </form>
136
135
 
137
- Creates a form completion request.
136
+ <!-- Token is automatically added as: -->
137
+ <!-- <input type="hidden" name="onetapforms_token" value="..."> -->
138
+ ```
138
139
 
139
- **Parameters:**
140
- - `options.schemaId` (string, required): Schema ID identifying the form structure
141
- - `options.purpose` (string, required): Purpose description shown to the user
142
- - `options.returnUrl` (string, required): URL to redirect to after completion
143
- - `options.bundles` (string[], optional): Data bundles to request
144
- - `options.fields` (string[], optional): Specific fields to request
145
- - `options.mode` ('auto' | 'redirect' | 'qr', optional): Request mode (defaults to 'auto')
146
- - `options.metadata` (object, optional): Additional metadata
147
- - `options.customization` (object, optional): Customization options
148
- - `customization.companyName` (string, optional)
149
- - `customization.logoUrl` (string, optional)
150
- - `options.onComplete` (function, optional): Callback when request is completed
151
- - `options.onError` (function, optional): Callback when an error occurs
152
- - `options.onQRReady` (function, optional): Callback when QR code is ready
140
+ ### Complete HTML Example
141
+
142
+ ```html
143
+ <!DOCTYPE html>
144
+ <html>
145
+ <head>
146
+ <title>Job Application</title>
147
+ </head>
148
+ <body>
149
+ <h1>Apply Now</h1>
150
+
151
+ <form id="applicationForm" action="/apply" method="POST">
152
+ <input name="name" placeholder="Full Name">
153
+ <input name="email" placeholder="Email">
154
+ <input name="phone" placeholder="Phone">
155
+
156
+ <button
157
+ type="button"
158
+ data-onetapforms
159
+ data-client-id="your_client_id"
160
+ data-purpose="Job application at ACME Corp"
161
+ data-bundles="basic,contact"
162
+ data-form-id="applicationForm"
163
+ style="background: #007AFF; color: white; padding: 12px 24px; border: none; border-radius: 8px; cursor: pointer;">
164
+ Fill with OneTapForms
165
+ </button>
166
+
167
+ <button type="submit">Submit Application</button>
168
+ </form>
169
+
170
+ <script src="https://cdn.jsdelivr.net/npm/@createlex/onetapforms-sdk@latest/dist/onetapforms.umd.min.js"></script>
171
+ <script>
172
+ document.querySelector('[data-onetapforms]').addEventListener('onetapforms:complete', function(e) {
173
+ alert('Form ready! Token received.');
174
+ // Token is auto-injected into the form - submit when ready
175
+ });
176
+ </script>
177
+ </body>
178
+ </html>
179
+ ```
153
180
 
154
- **Returns:** `Promise<void>`
181
+ ---
155
182
 
156
- ### `handleCallback()`
183
+ ## npm API Reference
157
184
 
158
- Handles callback from redirect flow. Call this when user returns to your site with token in URL.
185
+ ### Constructor
159
186
 
160
- **Returns:** `{ token: string, requestId: string } | null`
187
+ ```javascript
188
+ import { OneTapForms } from '@createlex/onetapforms-sdk';
161
189
 
162
- ### `cancelPolling()`
190
+ const onetap = new OneTapForms({
191
+ clientId: 'your_client_id', // Required
192
+ clientSecret: 'your_secret', // Recommended
193
+ apiUrl: 'https://api.createlex.com', // Optional
194
+ debug: true // Optional: enable logging
195
+ });
196
+ ```
163
197
 
164
- Cancels active polling (useful for cleanup).
198
+ ### request(options)
165
199
 
166
- ### `exchangeToken(token)`
200
+ Create a form completion request.
167
201
 
168
- Exchanges token for user data. **Note:** This should be called server-side, not in the browser.
202
+ ```javascript
203
+ await onetap.request({
204
+ // Content
205
+ purpose: 'Complete your profile', // Required
206
+ bundles: ['basic', 'contact'], // Optional
207
+ fields: ['name', 'email'], // Optional
208
+
209
+ // Mode
210
+ mode: 'auto', // 'auto' | 'qr' | 'redirect'
211
+ returnUrl: 'https://...', // For redirect mode
212
+
213
+ // Callbacks
214
+ onQRReady: (qrDataUrl) => {}, // QR code ready (desktop)
215
+ onComplete: ({ token }) => {}, // User approved
216
+ onError: (error) => {} // Error occurred
217
+ });
218
+ ```
169
219
 
170
- **Parameters:**
171
- - `token` (string, required): Exchange token
220
+ ### handleCallback()
172
221
 
173
- **Returns:** `Promise<any>` - User data object
222
+ Handle redirect flow callback (mobile):
174
223
 
175
- ### `getAppDownloadUrl()`
224
+ ```javascript
225
+ const result = onetap.handleCallback();
226
+ if (result) {
227
+ const { token, requestId } = result;
228
+ // Exchange token on server
229
+ }
230
+ ```
176
231
 
177
- Returns the App Store URL for downloading the OneTapForms app. Use this to encourage users to download the app.
232
+ ### cancelPolling()
178
233
 
179
- **Returns:** `string` - App Store URL
234
+ Cancel active polling (cleanup):
180
235
 
181
- ### `showDownloadPrompt(options?)`
236
+ ```javascript
237
+ onetap.cancelPolling();
238
+ ```
182
239
 
183
- Shows a modal prompt encouraging users to download the OneTapForms app. This helps developers get faster form completion and better conversion rates.
240
+ ### showDownloadPrompt(options)
184
241
 
185
- **Parameters:**
186
- - `options.title` (string, optional): Custom title for the prompt
187
- - `options.message` (string, optional): Custom message
188
- - `options.buttonText` (string, optional): Custom button text
189
- - `options.onDismiss` (function, optional): Callback when user dismisses the prompt
242
+ Encourage app downloads:
190
243
 
191
- **Example:**
192
244
  ```javascript
193
- // Show download prompt to encourage app downloads
194
- onetapforms.showDownloadPrompt({
245
+ onetap.showDownloadPrompt({
195
246
  title: 'Complete Forms Faster!',
196
- message: 'Download OneTapForms to fill forms in seconds with Face ID.',
197
- buttonText: 'Download Now',
198
- onDismiss: () => console.log('User dismissed prompt')
247
+ message: 'Download OneTapForms for instant form completion.',
248
+ buttonText: 'Download App'
199
249
  });
200
250
  ```
201
251
 
202
- ### `isAppLikelyInstalled()`
252
+ ### getAppDownloadUrl()
253
+
254
+ Get App Store URL:
255
+
256
+ ```javascript
257
+ const url = onetap.getAppDownloadUrl();
258
+ // 'https://apps.apple.com/app/onetapforms'
259
+ ```
203
260
 
204
- Checks if the user likely has the OneTapForms app installed (iOS device detection).
261
+ ---
205
262
 
206
- **Returns:** `boolean` - True if on iOS device
263
+ ## Server-Side Token Exchange
207
264
 
208
- ## Request Modes
265
+ **Important:** Always exchange tokens server-side to protect your credentials.
209
266
 
210
- ### Auto Mode (Default)
211
- Automatically detects device type and uses appropriate flow:
212
- - Mobile devices Redirect flow
213
- - Desktop devices → QR code flow
267
+ ```javascript
268
+ // Node.js example
269
+ const response = await fetch('https://api.createlex.com/api/onetapforms/exchange', {
270
+ method: 'POST',
271
+ headers: {
272
+ 'Content-Type': 'application/json',
273
+ 'X-Client-ID': 'your_client_id',
274
+ 'X-Client-Secret': 'your_client_secret'
275
+ },
276
+ body: JSON.stringify({ token })
277
+ });
214
278
 
215
- ### Redirect Mode
216
- Forces redirect flow (mobile). Opens OneTapForms app via Universal Link.
279
+ const { data } = await response.json();
280
+ // data contains: { name, email, phone, ... }
281
+ ```
217
282
 
218
- ### QR Mode
219
- Forces QR code flow (desktop). Generates QR code for user to scan.
283
+ ---
220
284
 
221
- ## Client Registration
285
+ ## Request Modes
222
286
 
223
- Before using the SDK, you must register as a client:
287
+ | Mode | When to Use | Behavior |
288
+ |------|-------------|----------|
289
+ | `auto` (default) | Most cases | Mobile = redirect, Desktop = QR |
290
+ | `qr` | Desktop only | Shows QR code modal |
291
+ | `redirect` | Mobile only | Opens OneTapForms app |
224
292
 
225
- 1. Contact Createlex LLC at info@createlex.com
226
- 2. Provide your company name and allowed callback URLs
227
- 3. Receive your `clientId` and `clientSecret` credentials
293
+ ---
228
294
 
229
- **Note:** Client registration is free and only required for security and callback URL validation. There are no fees for developers.
295
+ ## Getting Started
230
296
 
231
- ## Pricing Model
297
+ 1. **Get Credentials**: Email info@createlex.com to receive your `clientId` and `clientSecret` (free)
298
+ 2. **Install SDK**: Via script tag or npm
299
+ 3. **Add Button**: With data attributes or JavaScript
300
+ 4. **Handle Token**: Exchange on your server for user data
232
301
 
233
- - ✅ **SDK is free** - No cost to integrate or use
234
- - ✅ **No usage limits** - Use as much as you need
235
- - ✅ **No developer fees** - Zero cost for website owners
236
- - 💰 **End users pay** - Your users subscribe to OneTapForms service ($9-29/month) to store their data securely
302
+ ---
237
303
 
238
- ### Win-Win Model
304
+ ## CDN URLs
239
305
 
240
- **For Developers:**
241
- - Free integration with no ongoing costs
242
- - Faster form completion = more conversions
243
- - Better UX = happier users
244
- - Verified data = less errors
306
+ ```
307
+ # Latest version (recommended for development)
308
+ https://cdn.jsdelivr.net/npm/@createlex/onetapforms-sdk@latest/dist/onetapforms.umd.min.js
245
309
 
246
- **For End Users:**
247
- - One-tap form completion
248
- - Secure biometric authentication
249
- - Pre-filled verified data
250
- - Works across all OneTapForms-enabled sites
310
+ # Specific version (recommended for production)
311
+ https://cdn.jsdelivr.net/npm/@createlex/onetapforms-sdk@1.2.0/dist/onetapforms.umd.min.js
251
312
 
252
- **For OneTapForms:**
253
- - Revenue from user subscriptions
254
- - Network effects as more sites integrate
313
+ # Unminified (for debugging)
314
+ https://cdn.jsdelivr.net/npm/@createlex/onetapforms-sdk@latest/dist/onetapforms.umd.js
315
+ ```
255
316
 
256
- This model creates genuine value for everyone - developers get better results, users get convenience, and OneTapForms grows sustainably.
317
+ ---
257
318
 
258
319
  ## License
259
320
 
@@ -261,4 +322,5 @@ MIT - Free to use, modify, and distribute
261
322
 
262
323
  ## Support
263
324
 
264
- For issues and questions, please visit: https://github.com/createlex/onetapforms-sdk/issues
325
+ - Issues: https://github.com/createlex/onetapforms-sdk/issues
326
+ - Email: info@createlex.com