@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 +234 -173
- package/dist/index.cjs +284 -0
- 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.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,260 +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
|
-
clientSecret: '
|
|
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
|
-
|
|
47
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
69
|
+
---
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
## Free for Developers
|
|
74
72
|
|
|
75
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
81
|
+
Revenue comes from end users who subscribe to OneTapForms ($9-29/month) to store their data securely.
|
|
91
82
|
|
|
92
|
-
|
|
83
|
+
---
|
|
93
84
|
|
|
94
|
-
|
|
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
|
-
###
|
|
87
|
+
### Data Attributes
|
|
105
88
|
|
|
106
|
-
|
|
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
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
120
|
-
|
|
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
|
-
|
|
117
|
+
### Auto-Inject Token into Form
|
|
124
118
|
|
|
125
|
-
|
|
119
|
+
Use `data-form-id` to automatically add the token to a form:
|
|
126
120
|
|
|
127
|
-
|
|
121
|
+
```html
|
|
122
|
+
<form id="myForm" method="POST" action="/submit">
|
|
123
|
+
<input type="text" name="email" placeholder="Email">
|
|
128
124
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
|
|
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
|
-
|
|
133
|
+
<button type="submit">Submit</button>
|
|
134
|
+
</form>
|
|
137
135
|
|
|
138
|
-
|
|
136
|
+
<!-- Token is automatically added as: -->
|
|
137
|
+
<!-- <input type="hidden" name="onetapforms_token" value="..."> -->
|
|
138
|
+
```
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
181
|
+
---
|
|
156
182
|
|
|
157
|
-
|
|
183
|
+
## npm API Reference
|
|
158
184
|
|
|
159
|
-
|
|
185
|
+
### Constructor
|
|
160
186
|
|
|
161
|
-
|
|
187
|
+
```javascript
|
|
188
|
+
import { OneTapForms } from '@createlex/onetapforms-sdk';
|
|
162
189
|
|
|
163
|
-
|
|
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
|
-
|
|
198
|
+
### request(options)
|
|
166
199
|
|
|
167
|
-
|
|
200
|
+
Create a form completion request.
|
|
168
201
|
|
|
169
|
-
|
|
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
|
-
|
|
172
|
-
- `token` (string, required): Exchange token
|
|
220
|
+
### handleCallback()
|
|
173
221
|
|
|
174
|
-
|
|
222
|
+
Handle redirect flow callback (mobile):
|
|
175
223
|
|
|
176
|
-
|
|
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
|
-
|
|
232
|
+
### cancelPolling()
|
|
179
233
|
|
|
180
|
-
|
|
234
|
+
Cancel active polling (cleanup):
|
|
181
235
|
|
|
182
|
-
|
|
236
|
+
```javascript
|
|
237
|
+
onetap.cancelPolling();
|
|
238
|
+
```
|
|
183
239
|
|
|
184
|
-
|
|
240
|
+
### showDownloadPrompt(options)
|
|
185
241
|
|
|
186
|
-
|
|
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
|
-
|
|
195
|
-
onetapforms.showDownloadPrompt({
|
|
245
|
+
onetap.showDownloadPrompt({
|
|
196
246
|
title: 'Complete Forms Faster!',
|
|
197
|
-
message: 'Download OneTapForms
|
|
198
|
-
buttonText: 'Download
|
|
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
|
-
###
|
|
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
|
-
|
|
261
|
+
---
|
|
206
262
|
|
|
207
|
-
|
|
263
|
+
## Server-Side Token Exchange
|
|
208
264
|
|
|
209
|
-
|
|
265
|
+
**Important:** Always exchange tokens server-side to protect your credentials.
|
|
210
266
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
217
|
-
|
|
279
|
+
const { data } = await response.json();
|
|
280
|
+
// data contains: { name, email, phone, ... }
|
|
281
|
+
```
|
|
218
282
|
|
|
219
|
-
|
|
220
|
-
Forces QR code flow (desktop). Generates QR code for user to scan.
|
|
283
|
+
---
|
|
221
284
|
|
|
222
|
-
##
|
|
285
|
+
## Request Modes
|
|
223
286
|
|
|
224
|
-
|
|
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
|
-
|
|
227
|
-
2. Provide your company name and allowed callback URLs
|
|
228
|
-
3. Receive your `clientId` and `clientSecret` credentials
|
|
293
|
+
---
|
|
229
294
|
|
|
230
|
-
|
|
295
|
+
## Getting Started
|
|
231
296
|
|
|
232
|
-
|
|
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
|
-
|
|
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
|
-
|
|
304
|
+
## CDN URLs
|
|
240
305
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
-
|
|
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
|
-
|
|
248
|
-
-
|
|
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
|
-
|
|
254
|
-
-
|
|
255
|
-
|
|
313
|
+
# Unminified (for debugging)
|
|
314
|
+
https://cdn.jsdelivr.net/npm/@createlex/onetapforms-sdk@latest/dist/onetapforms.umd.js
|
|
315
|
+
```
|
|
256
316
|
|
|
257
|
-
|
|
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
|
-
|
|
325
|
+
- Issues: https://github.com/createlex/onetapforms-sdk/issues
|
|
326
|
+
- Email: info@createlex.com
|