@createlex/onetapforms-sdk 1.1.5 → 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,260 +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
- clientSecret: 'your_client_secret', // Recommended for authenticated requests
39
- apiUrl: 'https://api.createlex.com',
40
- debug: true // Enable console logging
47
+ const onetap = new OneTapForms({
48
+ clientId: 'YOUR_CLIENT_ID',
49
+ clientSecret: 'YOUR_CLIENT_SECRET'
41
50
  });
42
- ```
43
-
44
- ### 2. Create a Request
45
51
 
46
- ```javascript
47
- await onetapforms.request({
48
- schemaId: 'job_application',
49
- purpose: 'Job application at YourCompany',
50
- returnUrl: 'https://yoursite.com/apply/callback',
52
+ await onetap.request({
53
+ purpose: 'Job Application',
51
54
  bundles: ['basic', 'contact'],
52
-
53
- // Called when QR code is ready (desktop users)
54
- onQRReady: (qrDataUrl) => {
55
- document.getElementById('qr-code').src = qrDataUrl;
55
+ onQRReady: (qrUrl) => {
56
+ // Show QR code to user
57
+ document.getElementById('qr').src = qrUrl;
56
58
  },
57
-
58
- // Called when user approves the request
59
- onComplete: ({ token, requestId }) => {
60
- // Exchange token for user data on your server
61
- exchangeTokenForData(token);
62
- },
63
-
64
- // Called if an error occurs
65
- onError: (error) => {
66
- 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
+ });
67
65
  }
68
66
  });
69
67
  ```
70
68
 
71
- ### 2.5. Encourage App Downloads (Optional but Recommended)
69
+ ---
72
70
 
73
- Help users discover OneTapForms to get faster form completion:
71
+ ## Free for Developers
74
72
 
75
- ```javascript
76
- // Show download prompt if user doesn't have the app
77
- if (!onetapforms.isAppLikelyInstalled()) {
78
- onetapforms.showDownloadPrompt({
79
- title: 'Complete Forms Faster!',
80
- message: 'Download OneTapForms to fill this form in seconds with Face ID/Touch ID.',
81
- buttonText: 'Download App'
82
- });
83
- }
73
+ **The SDK is completely free!** No fees, usage limits, or restrictions.
84
74
 
85
- // Or add a download button to your UI
86
- const downloadUrl = onetapforms.getAppDownloadUrl();
87
- // <a href={downloadUrl}>Download OneTapForms App</a>
88
- ```
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
89
80
 
90
- ### 3. Handle Mobile Redirect Callback
81
+ Revenue comes from end users who subscribe to OneTapForms ($9-29/month) to store their data securely.
91
82
 
92
- If using redirect mode on mobile, handle the callback:
83
+ ---
93
84
 
94
- ```javascript
95
- // On your callback page
96
- const result = onetapforms.handleCallback();
97
- if (result) {
98
- const { token, requestId } = result;
99
- // Exchange token for user data on your server
100
- exchangeTokenForData(token);
101
- }
102
- ```
85
+ ## Widget Mode Reference (Script Tag)
103
86
 
104
- ### 4. Exchange Token for Data (Server-Side)
87
+ ### Data Attributes
105
88
 
106
- **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:
107
102
 
108
103
  ```javascript
109
- // Node.js example (server-side)
110
- const response = await fetch('https://api.createlex.com/api/onetapforms/exchange', {
111
- method: 'POST',
112
- headers: {
113
- 'Content-Type': 'application/json',
114
- 'X-API-Key': 'your_api_key'
115
- },
116
- 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
117
108
  });
118
109
 
119
- const { data } = await response.json();
120
- // 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
+ });
121
115
  ```
122
116
 
123
- ## API Reference
117
+ ### Auto-Inject Token into Form
124
118
 
125
- ### `OneTapForms(config)`
119
+ Use `data-form-id` to automatically add the token to a form:
126
120
 
127
- Creates a new OneTapForms instance.
121
+ ```html
122
+ <form id="myForm" method="POST" action="/submit">
123
+ <input type="text" name="email" placeholder="Email">
128
124
 
129
- **Parameters:**
130
- - `config.clientId` (string, required): Your client ID
131
- - `config.clientSecret` (string, optional): Your client secret (recommended for authenticated requests)
132
- - `config.apiUrl` (string, optional): API URL (defaults to `https://api.createlex.com`)
133
- - `config.apiKey` (string, optional): API key for legacy auth (defaults to `clientId`)
134
- - `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>
135
132
 
136
- ### `request(options)`
133
+ <button type="submit">Submit</button>
134
+ </form>
137
135
 
138
- Creates a form completion request.
136
+ <!-- Token is automatically added as: -->
137
+ <!-- <input type="hidden" name="onetapforms_token" value="..."> -->
138
+ ```
139
139
 
140
- **Parameters:**
141
- - `options.schemaId` (string, required): Schema ID identifying the form structure
142
- - `options.purpose` (string, required): Purpose description shown to the user
143
- - `options.returnUrl` (string, required): URL to redirect to after completion
144
- - `options.bundles` (string[], optional): Data bundles to request
145
- - `options.fields` (string[], optional): Specific fields to request
146
- - `options.mode` ('auto' | 'redirect' | 'qr', optional): Request mode (defaults to 'auto')
147
- - `options.metadata` (object, optional): Additional metadata
148
- - `options.customization` (object, optional): Customization options
149
- - `customization.companyName` (string, optional)
150
- - `customization.logoUrl` (string, optional)
151
- - `options.onComplete` (function, optional): Callback when request is completed
152
- - `options.onError` (function, optional): Callback when an error occurs
153
- - `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
+ ```
154
180
 
155
- **Returns:** `Promise<void>`
181
+ ---
156
182
 
157
- ### `handleCallback()`
183
+ ## npm API Reference
158
184
 
159
- Handles callback from redirect flow. Call this when user returns to your site with token in URL.
185
+ ### Constructor
160
186
 
161
- **Returns:** `{ token: string, requestId: string } | null`
187
+ ```javascript
188
+ import { OneTapForms } from '@createlex/onetapforms-sdk';
162
189
 
163
- ### `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
+ ```
164
197
 
165
- Cancels active polling (useful for cleanup).
198
+ ### request(options)
166
199
 
167
- ### `exchangeToken(token)`
200
+ Create a form completion request.
168
201
 
169
- 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
+ ```
170
219
 
171
- **Parameters:**
172
- - `token` (string, required): Exchange token
220
+ ### handleCallback()
173
221
 
174
- **Returns:** `Promise<any>` - User data object
222
+ Handle redirect flow callback (mobile):
175
223
 
176
- ### `getAppDownloadUrl()`
224
+ ```javascript
225
+ const result = onetap.handleCallback();
226
+ if (result) {
227
+ const { token, requestId } = result;
228
+ // Exchange token on server
229
+ }
230
+ ```
177
231
 
178
- Returns the App Store URL for downloading the OneTapForms app. Use this to encourage users to download the app.
232
+ ### cancelPolling()
179
233
 
180
- **Returns:** `string` - App Store URL
234
+ Cancel active polling (cleanup):
181
235
 
182
- ### `showDownloadPrompt(options?)`
236
+ ```javascript
237
+ onetap.cancelPolling();
238
+ ```
183
239
 
184
- 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)
185
241
 
186
- **Parameters:**
187
- - `options.title` (string, optional): Custom title for the prompt
188
- - `options.message` (string, optional): Custom message
189
- - `options.buttonText` (string, optional): Custom button text
190
- - `options.onDismiss` (function, optional): Callback when user dismisses the prompt
242
+ Encourage app downloads:
191
243
 
192
- **Example:**
193
244
  ```javascript
194
- // Show download prompt to encourage app downloads
195
- onetapforms.showDownloadPrompt({
245
+ onetap.showDownloadPrompt({
196
246
  title: 'Complete Forms Faster!',
197
- message: 'Download OneTapForms to fill forms in seconds with Face ID.',
198
- buttonText: 'Download Now',
199
- onDismiss: () => console.log('User dismissed prompt')
247
+ message: 'Download OneTapForms for instant form completion.',
248
+ buttonText: 'Download App'
200
249
  });
201
250
  ```
202
251
 
203
- ### `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
+ ```
204
260
 
205
- Checks if the user likely has the OneTapForms app installed (iOS device detection).
261
+ ---
206
262
 
207
- **Returns:** `boolean` - True if on iOS device
263
+ ## Server-Side Token Exchange
208
264
 
209
- ## Request Modes
265
+ **Important:** Always exchange tokens server-side to protect your credentials.
210
266
 
211
- ### Auto Mode (Default)
212
- Automatically detects device type and uses appropriate flow:
213
- - Mobile devices Redirect flow
214
- - 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
+ });
215
278
 
216
- ### Redirect Mode
217
- Forces redirect flow (mobile). Opens OneTapForms app via Universal Link.
279
+ const { data } = await response.json();
280
+ // data contains: { name, email, phone, ... }
281
+ ```
218
282
 
219
- ### QR Mode
220
- Forces QR code flow (desktop). Generates QR code for user to scan.
283
+ ---
221
284
 
222
- ## Client Registration
285
+ ## Request Modes
223
286
 
224
- 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 |
225
292
 
226
- 1. Contact Createlex LLC at info@createlex.com
227
- 2. Provide your company name and allowed callback URLs
228
- 3. Receive your `clientId` and `clientSecret` credentials
293
+ ---
229
294
 
230
- **Note:** Client registration is free and only required for security and callback URL validation. There are no fees for developers.
295
+ ## Getting Started
231
296
 
232
- ## 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
233
301
 
234
- - ✅ **SDK is free** - No cost to integrate or use
235
- - ✅ **No usage limits** - Use as much as you need
236
- - ✅ **No developer fees** - Zero cost for website owners
237
- - 💰 **End users pay** - Your users subscribe to OneTapForms service ($9-29/month) to store their data securely
302
+ ---
238
303
 
239
- ### Win-Win Model
304
+ ## CDN URLs
240
305
 
241
- **For Developers:**
242
- - Free integration with no ongoing costs
243
- - Faster form completion = more conversions
244
- - Better UX = happier users
245
- - 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
246
309
 
247
- **For End Users:**
248
- - One-tap form completion
249
- - Secure biometric authentication
250
- - Pre-filled verified data
251
- - 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
252
312
 
253
- **For OneTapForms:**
254
- - Revenue from user subscriptions
255
- - 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
+ ```
256
316
 
257
- This model creates genuine value for everyone - developers get better results, users get convenience, and OneTapForms grows sustainably.
317
+ ---
258
318
 
259
319
  ## License
260
320
 
@@ -262,4 +322,5 @@ MIT - Free to use, modify, and distribute
262
322
 
263
323
  ## Support
264
324
 
265
- 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