@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 +234 -172
- package/dist/index.cjs +289 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.esm.js +283 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/onetapforms.js +5 -3
- package/dist/onetapforms.umd.js +2698 -0
- package/dist/onetapforms.umd.js.map +1 -0
- package/dist/onetapforms.umd.min.js +2 -0
- package/dist/onetapforms.umd.min.js.map +1 -0
- package/dist/types.d.ts +4 -4
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -1,259 +1,320 @@
|
|
|
1
1
|
# @createlex/onetapforms-sdk
|
|
2
2
|
|
|
3
|
-
OneTapForms SDK for secure, biometric-authenticated form completion.
|
|
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
|
-
##
|
|
5
|
+
## Quick Start (30 seconds)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Choose the installation method that matches your skill level:
|
|
8
8
|
|
|
9
|
-
###
|
|
9
|
+
### Option 1: Script Tag (Easiest - No Build Tools Required)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Perfect for HTML websites, WordPress, or any site where you can add a script tag:
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
37
|
-
clientId: '
|
|
38
|
-
|
|
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
|
-
|
|
46
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
69
|
+
---
|
|
71
70
|
|
|
72
|
-
|
|
71
|
+
## Free for Developers
|
|
73
72
|
|
|
74
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
81
|
+
Revenue comes from end users who subscribe to OneTapForms ($9-29/month) to store their data securely.
|
|
90
82
|
|
|
91
|
-
|
|
83
|
+
---
|
|
92
84
|
|
|
93
|
-
|
|
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
|
-
###
|
|
87
|
+
### Data Attributes
|
|
104
88
|
|
|
105
|
-
|
|
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
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
119
|
-
|
|
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
|
-
|
|
117
|
+
### Auto-Inject Token into Form
|
|
123
118
|
|
|
124
|
-
|
|
119
|
+
Use `data-form-id` to automatically add the token to a form:
|
|
125
120
|
|
|
126
|
-
|
|
121
|
+
```html
|
|
122
|
+
<form id="myForm" method="POST" action="/submit">
|
|
123
|
+
<input type="text" name="email" placeholder="Email">
|
|
127
124
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
-
|
|
131
|
-
-
|
|
132
|
-
-
|
|
133
|
-
|
|
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
|
-
|
|
133
|
+
<button type="submit">Submit</button>
|
|
134
|
+
</form>
|
|
136
135
|
|
|
137
|
-
|
|
136
|
+
<!-- Token is automatically added as: -->
|
|
137
|
+
<!-- <input type="hidden" name="onetapforms_token" value="..."> -->
|
|
138
|
+
```
|
|
138
139
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
181
|
+
---
|
|
155
182
|
|
|
156
|
-
|
|
183
|
+
## npm API Reference
|
|
157
184
|
|
|
158
|
-
|
|
185
|
+
### Constructor
|
|
159
186
|
|
|
160
|
-
|
|
187
|
+
```javascript
|
|
188
|
+
import { OneTapForms } from '@createlex/onetapforms-sdk';
|
|
161
189
|
|
|
162
|
-
|
|
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
|
-
|
|
198
|
+
### request(options)
|
|
165
199
|
|
|
166
|
-
|
|
200
|
+
Create a form completion request.
|
|
167
201
|
|
|
168
|
-
|
|
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
|
-
|
|
171
|
-
- `token` (string, required): Exchange token
|
|
220
|
+
### handleCallback()
|
|
172
221
|
|
|
173
|
-
|
|
222
|
+
Handle redirect flow callback (mobile):
|
|
174
223
|
|
|
175
|
-
|
|
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
|
-
|
|
232
|
+
### cancelPolling()
|
|
178
233
|
|
|
179
|
-
|
|
234
|
+
Cancel active polling (cleanup):
|
|
180
235
|
|
|
181
|
-
|
|
236
|
+
```javascript
|
|
237
|
+
onetap.cancelPolling();
|
|
238
|
+
```
|
|
182
239
|
|
|
183
|
-
|
|
240
|
+
### showDownloadPrompt(options)
|
|
184
241
|
|
|
185
|
-
|
|
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
|
-
|
|
194
|
-
onetapforms.showDownloadPrompt({
|
|
245
|
+
onetap.showDownloadPrompt({
|
|
195
246
|
title: 'Complete Forms Faster!',
|
|
196
|
-
message: 'Download OneTapForms
|
|
197
|
-
buttonText: 'Download
|
|
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
|
-
###
|
|
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
|
-
|
|
261
|
+
---
|
|
205
262
|
|
|
206
|
-
|
|
263
|
+
## Server-Side Token Exchange
|
|
207
264
|
|
|
208
|
-
|
|
265
|
+
**Important:** Always exchange tokens server-side to protect your credentials.
|
|
209
266
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
216
|
-
|
|
279
|
+
const { data } = await response.json();
|
|
280
|
+
// data contains: { name, email, phone, ... }
|
|
281
|
+
```
|
|
217
282
|
|
|
218
|
-
|
|
219
|
-
Forces QR code flow (desktop). Generates QR code for user to scan.
|
|
283
|
+
---
|
|
220
284
|
|
|
221
|
-
##
|
|
285
|
+
## Request Modes
|
|
222
286
|
|
|
223
|
-
|
|
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
|
-
|
|
226
|
-
2. Provide your company name and allowed callback URLs
|
|
227
|
-
3. Receive your `clientId` and `clientSecret` credentials
|
|
293
|
+
---
|
|
228
294
|
|
|
229
|
-
|
|
295
|
+
## Getting Started
|
|
230
296
|
|
|
231
|
-
|
|
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
|
-
|
|
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
|
-
|
|
304
|
+
## CDN URLs
|
|
239
305
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
-
|
|
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
|
-
|
|
247
|
-
-
|
|
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
|
-
|
|
253
|
-
-
|
|
254
|
-
|
|
313
|
+
# Unminified (for debugging)
|
|
314
|
+
https://cdn.jsdelivr.net/npm/@createlex/onetapforms-sdk@latest/dist/onetapforms.umd.js
|
|
315
|
+
```
|
|
255
316
|
|
|
256
|
-
|
|
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
|
-
|
|
325
|
+
- Issues: https://github.com/createlex/onetapforms-sdk/issues
|
|
326
|
+
- Email: info@createlex.com
|