@createlex/onetapforms-sdk 1.0.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/LICENSE +22 -0
- package/README.md +165 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +58 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/onetapforms.d.ts +27 -0
- package/dist/onetapforms.d.ts.map +1 -0
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Createlex LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# @createlex/onetapforms-sdk
|
|
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.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @createlex/onetapforms-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### 1. Initialize the SDK
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { OneTapForms } from '@createlex/onetapforms-sdk';
|
|
17
|
+
|
|
18
|
+
const onetapforms = new OneTapForms({
|
|
19
|
+
clientId: 'your_client_id',
|
|
20
|
+
apiUrl: 'https://api.createlex.com',
|
|
21
|
+
debug: true // Enable console logging
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 2. Create a Request
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
await onetapforms.request({
|
|
29
|
+
schemaId: 'job_application',
|
|
30
|
+
purpose: 'Job application at YourCompany',
|
|
31
|
+
returnUrl: 'https://yoursite.com/apply/callback',
|
|
32
|
+
bundles: ['basic', 'contact'],
|
|
33
|
+
|
|
34
|
+
// Called when QR code is ready (desktop users)
|
|
35
|
+
onQRReady: (qrDataUrl) => {
|
|
36
|
+
document.getElementById('qr-code').src = qrDataUrl;
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
// Called when user approves the request
|
|
40
|
+
onComplete: ({ token, requestId }) => {
|
|
41
|
+
// Exchange token for user data on your server
|
|
42
|
+
exchangeTokenForData(token);
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// Called if an error occurs
|
|
46
|
+
onError: (error) => {
|
|
47
|
+
console.error('OneTapForms error:', error);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 3. Handle Mobile Redirect Callback
|
|
53
|
+
|
|
54
|
+
If using redirect mode on mobile, handle the callback:
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
// On your callback page
|
|
58
|
+
const result = onetapforms.handleCallback();
|
|
59
|
+
if (result) {
|
|
60
|
+
const { token, requestId } = result;
|
|
61
|
+
// Exchange token for user data on your server
|
|
62
|
+
exchangeTokenForData(token);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 4. Exchange Token for Data (Server-Side)
|
|
67
|
+
|
|
68
|
+
**Important:** Always exchange tokens server-side to protect your API key.
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
// Node.js example (server-side)
|
|
72
|
+
const response = await fetch('https://api.createlex.com/api/onetapforms/exchange', {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
'Content-Type': 'application/json',
|
|
76
|
+
'X-API-Key': 'your_api_key'
|
|
77
|
+
},
|
|
78
|
+
body: JSON.stringify({ token })
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const { data } = await response.json();
|
|
82
|
+
// Use the user data to fill your form
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## API Reference
|
|
86
|
+
|
|
87
|
+
### `OneTapForms(config)`
|
|
88
|
+
|
|
89
|
+
Creates a new OneTapForms instance.
|
|
90
|
+
|
|
91
|
+
**Parameters:**
|
|
92
|
+
- `config.clientId` (string, required): Your client ID
|
|
93
|
+
- `config.apiUrl` (string, optional): API URL (defaults to `https://api.createlex.com`)
|
|
94
|
+
- `config.apiKey` (string, optional): API key (defaults to `clientId`)
|
|
95
|
+
- `config.debug` (boolean, optional): Enable debug logging (defaults to `false`)
|
|
96
|
+
|
|
97
|
+
### `request(options)`
|
|
98
|
+
|
|
99
|
+
Creates a form completion request.
|
|
100
|
+
|
|
101
|
+
**Parameters:**
|
|
102
|
+
- `options.schemaId` (string, required): Schema ID identifying the form structure
|
|
103
|
+
- `options.purpose` (string, required): Purpose description shown to the user
|
|
104
|
+
- `options.returnUrl` (string, required): URL to redirect to after completion
|
|
105
|
+
- `options.bundles` (string[], optional): Data bundles to request
|
|
106
|
+
- `options.fields` (string[], optional): Specific fields to request
|
|
107
|
+
- `options.mode` ('auto' | 'redirect' | 'qr', optional): Request mode (defaults to 'auto')
|
|
108
|
+
- `options.metadata` (object, optional): Additional metadata
|
|
109
|
+
- `options.customization` (object, optional): Customization options
|
|
110
|
+
- `customization.companyName` (string, optional)
|
|
111
|
+
- `customization.logoUrl` (string, optional)
|
|
112
|
+
- `options.onComplete` (function, optional): Callback when request is completed
|
|
113
|
+
- `options.onError` (function, optional): Callback when an error occurs
|
|
114
|
+
- `options.onQRReady` (function, optional): Callback when QR code is ready
|
|
115
|
+
|
|
116
|
+
**Returns:** `Promise<void>`
|
|
117
|
+
|
|
118
|
+
### `handleCallback()`
|
|
119
|
+
|
|
120
|
+
Handles callback from redirect flow. Call this when user returns to your site with token in URL.
|
|
121
|
+
|
|
122
|
+
**Returns:** `{ token: string, requestId: string } | null`
|
|
123
|
+
|
|
124
|
+
### `cancelPolling()`
|
|
125
|
+
|
|
126
|
+
Cancels active polling (useful for cleanup).
|
|
127
|
+
|
|
128
|
+
### `exchangeToken(token)`
|
|
129
|
+
|
|
130
|
+
Exchanges token for user data. **Note:** This should be called server-side, not in the browser.
|
|
131
|
+
|
|
132
|
+
**Parameters:**
|
|
133
|
+
- `token` (string, required): Exchange token
|
|
134
|
+
|
|
135
|
+
**Returns:** `Promise<any>` - User data object
|
|
136
|
+
|
|
137
|
+
## Request Modes
|
|
138
|
+
|
|
139
|
+
### Auto Mode (Default)
|
|
140
|
+
Automatically detects device type and uses appropriate flow:
|
|
141
|
+
- Mobile devices → Redirect flow
|
|
142
|
+
- Desktop devices → QR code flow
|
|
143
|
+
|
|
144
|
+
### Redirect Mode
|
|
145
|
+
Forces redirect flow (mobile). Opens OneTapForms app via Universal Link.
|
|
146
|
+
|
|
147
|
+
### QR Mode
|
|
148
|
+
Forces QR code flow (desktop). Generates QR code for user to scan.
|
|
149
|
+
|
|
150
|
+
## Client Registration
|
|
151
|
+
|
|
152
|
+
Before using the SDK, you must register as a client:
|
|
153
|
+
|
|
154
|
+
1. Contact Createlex LLC at info@createlex.com
|
|
155
|
+
2. Provide your company name and allowed callback URLs
|
|
156
|
+
3. Receive your `clientId` and `clientSecret` credentials
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT
|
|
161
|
+
|
|
162
|
+
## Support
|
|
163
|
+
|
|
164
|
+
For issues and questions, please visit: https://github.com/createlex/onetapforms-sdk/issues
|
|
165
|
+
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EACjB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// We'll use a dynamic import approach that works in both browser and Node
|
|
2
|
+
let OneTapFormsJS;
|
|
3
|
+
// Lazy load the JS implementation
|
|
4
|
+
function getOneTapFormsClass() {
|
|
5
|
+
if (!OneTapFormsJS) {
|
|
6
|
+
// In browser/build environment, this will be resolved at build time
|
|
7
|
+
// The bundled JS file exports OneTapForms as a class
|
|
8
|
+
if (typeof window !== 'undefined') {
|
|
9
|
+
// Browser environment - use global or import
|
|
10
|
+
const module = require('./onetapforms.js');
|
|
11
|
+
OneTapFormsJS = module.OneTapForms || module.default;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
// Node environment
|
|
15
|
+
const module = require('./onetapforms.js');
|
|
16
|
+
OneTapFormsJS = module.OneTapForms || module.default;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return OneTapFormsJS;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* OneTapForms SDK class for secure, biometric-authenticated form completion
|
|
23
|
+
*/
|
|
24
|
+
class OneTapForms {
|
|
25
|
+
constructor(config) {
|
|
26
|
+
const OneTapFormsClass = getOneTapFormsClass();
|
|
27
|
+
this.instance = new OneTapFormsClass(config);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a form completion request
|
|
31
|
+
*/
|
|
32
|
+
async request(options) {
|
|
33
|
+
return this.instance.request(options);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Cancel active polling (useful for cleanup)
|
|
37
|
+
*/
|
|
38
|
+
cancelPolling() {
|
|
39
|
+
return this.instance.cancelPolling();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Handle callback from redirect flow
|
|
43
|
+
* Call this when user returns to your site with token in URL
|
|
44
|
+
*/
|
|
45
|
+
handleCallback() {
|
|
46
|
+
return this.instance.handleCallback();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Exchange token for user data (server-side only!)
|
|
50
|
+
* This should be called from your backend, not the browser
|
|
51
|
+
*/
|
|
52
|
+
async exchangeToken(token) {
|
|
53
|
+
return this.instance.exchangeToken(token);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { OneTapForms, OneTapForms as default };
|
|
58
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/onetapforms.ts"],"sourcesContent":["import type { OneTapFormsConfig, RequestOptions, CompletionResult } from './types';\n\n// We'll use a dynamic import approach that works in both browser and Node\nlet OneTapFormsJS: any;\n\n// Lazy load the JS implementation\nfunction getOneTapFormsClass() {\n if (!OneTapFormsJS) {\n // In browser/build environment, this will be resolved at build time\n // The bundled JS file exports OneTapForms as a class\n if (typeof window !== 'undefined') {\n // Browser environment - use global or import\n const module = require('./onetapforms.js');\n OneTapFormsJS = module.OneTapForms || module.default;\n } else {\n // Node environment\n const module = require('./onetapforms.js');\n OneTapFormsJS = module.OneTapForms || module.default;\n }\n }\n return OneTapFormsJS;\n}\n\n/**\n * OneTapForms SDK class for secure, biometric-authenticated form completion\n */\nexport class OneTapForms {\n private instance: any;\n\n constructor(config: OneTapFormsConfig) {\n const OneTapFormsClass = getOneTapFormsClass();\n this.instance = new OneTapFormsClass(config);\n }\n\n /**\n * Create a form completion request\n */\n async request(options: RequestOptions): Promise<void> {\n return this.instance.request(options);\n }\n\n /**\n * Cancel active polling (useful for cleanup)\n */\n cancelPolling(): void {\n return this.instance.cancelPolling();\n }\n\n /**\n * Handle callback from redirect flow\n * Call this when user returns to your site with token in URL\n */\n handleCallback(): CompletionResult | null {\n return this.instance.handleCallback();\n }\n\n /**\n * Exchange token for user data (server-side only!)\n * This should be called from your backend, not the browser\n */\n async exchangeToken(token: string): Promise<any> {\n return this.instance.exchangeToken(token);\n }\n}\n\nexport default OneTapForms;\n"],"names":[],"mappings":"AAEA;AACA,IAAI,aAAkB;AAEtB;AACA,SAAS,mBAAmB,GAAA;IAC1B,IAAI,CAAC,aAAa,EAAE;;;AAGlB,QAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;;AAEjC,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAC1C,aAAa,GAAG,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,OAAO;QACtD;aAAO;;AAEL,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAC1C,aAAa,GAAG,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,OAAO;QACtD;IACF;AACA,IAAA,OAAO,aAAa;AACtB;AAEA;;AAEG;MACU,WAAW,CAAA;AAGtB,IAAA,WAAA,CAAY,MAAyB,EAAA;AACnC,QAAA,MAAM,gBAAgB,GAAG,mBAAmB,EAAE;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAC9C;AAEA;;AAEG;IACH,MAAM,OAAO,CAAC,OAAuB,EAAA;QACnC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC;IACvC;AAEA;;AAEG;IACH,aAAa,GAAA;AACX,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE;IACtC;AAEA;;;AAGG;IACH,cAAc,GAAA;AACZ,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE;IACvC;AAEA;;;AAGG;IACH,MAAM,aAAa,CAAC,KAAa,EAAA;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;IAC3C;AACD;;;;"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// We'll use a dynamic import approach that works in both browser and Node
|
|
6
|
+
let OneTapFormsJS;
|
|
7
|
+
// Lazy load the JS implementation
|
|
8
|
+
function getOneTapFormsClass() {
|
|
9
|
+
if (!OneTapFormsJS) {
|
|
10
|
+
// In browser/build environment, this will be resolved at build time
|
|
11
|
+
// The bundled JS file exports OneTapForms as a class
|
|
12
|
+
if (typeof window !== 'undefined') {
|
|
13
|
+
// Browser environment - use global or import
|
|
14
|
+
const module = require('./onetapforms.js');
|
|
15
|
+
OneTapFormsJS = module.OneTapForms || module.default;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// Node environment
|
|
19
|
+
const module = require('./onetapforms.js');
|
|
20
|
+
OneTapFormsJS = module.OneTapForms || module.default;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return OneTapFormsJS;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* OneTapForms SDK class for secure, biometric-authenticated form completion
|
|
27
|
+
*/
|
|
28
|
+
class OneTapForms {
|
|
29
|
+
constructor(config) {
|
|
30
|
+
const OneTapFormsClass = getOneTapFormsClass();
|
|
31
|
+
this.instance = new OneTapFormsClass(config);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a form completion request
|
|
35
|
+
*/
|
|
36
|
+
async request(options) {
|
|
37
|
+
return this.instance.request(options);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Cancel active polling (useful for cleanup)
|
|
41
|
+
*/
|
|
42
|
+
cancelPolling() {
|
|
43
|
+
return this.instance.cancelPolling();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Handle callback from redirect flow
|
|
47
|
+
* Call this when user returns to your site with token in URL
|
|
48
|
+
*/
|
|
49
|
+
handleCallback() {
|
|
50
|
+
return this.instance.handleCallback();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Exchange token for user data (server-side only!)
|
|
54
|
+
* This should be called from your backend, not the browser
|
|
55
|
+
*/
|
|
56
|
+
async exchangeToken(token) {
|
|
57
|
+
return this.instance.exchangeToken(token);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.OneTapForms = OneTapForms;
|
|
62
|
+
exports.default = OneTapForms;
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/onetapforms.ts"],"sourcesContent":["import type { OneTapFormsConfig, RequestOptions, CompletionResult } from './types';\n\n// We'll use a dynamic import approach that works in both browser and Node\nlet OneTapFormsJS: any;\n\n// Lazy load the JS implementation\nfunction getOneTapFormsClass() {\n if (!OneTapFormsJS) {\n // In browser/build environment, this will be resolved at build time\n // The bundled JS file exports OneTapForms as a class\n if (typeof window !== 'undefined') {\n // Browser environment - use global or import\n const module = require('./onetapforms.js');\n OneTapFormsJS = module.OneTapForms || module.default;\n } else {\n // Node environment\n const module = require('./onetapforms.js');\n OneTapFormsJS = module.OneTapForms || module.default;\n }\n }\n return OneTapFormsJS;\n}\n\n/**\n * OneTapForms SDK class for secure, biometric-authenticated form completion\n */\nexport class OneTapForms {\n private instance: any;\n\n constructor(config: OneTapFormsConfig) {\n const OneTapFormsClass = getOneTapFormsClass();\n this.instance = new OneTapFormsClass(config);\n }\n\n /**\n * Create a form completion request\n */\n async request(options: RequestOptions): Promise<void> {\n return this.instance.request(options);\n }\n\n /**\n * Cancel active polling (useful for cleanup)\n */\n cancelPolling(): void {\n return this.instance.cancelPolling();\n }\n\n /**\n * Handle callback from redirect flow\n * Call this when user returns to your site with token in URL\n */\n handleCallback(): CompletionResult | null {\n return this.instance.handleCallback();\n }\n\n /**\n * Exchange token for user data (server-side only!)\n * This should be called from your backend, not the browser\n */\n async exchangeToken(token: string): Promise<any> {\n return this.instance.exchangeToken(token);\n }\n}\n\nexport default OneTapForms;\n"],"names":[],"mappings":";;;;AAEA;AACA,IAAI,aAAkB;AAEtB;AACA,SAAS,mBAAmB,GAAA;IAC1B,IAAI,CAAC,aAAa,EAAE;;;AAGlB,QAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;;AAEjC,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAC1C,aAAa,GAAG,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,OAAO;QACtD;aAAO;;AAEL,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAC1C,aAAa,GAAG,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,OAAO;QACtD;IACF;AACA,IAAA,OAAO,aAAa;AACtB;AAEA;;AAEG;MACU,WAAW,CAAA;AAGtB,IAAA,WAAA,CAAY,MAAyB,EAAA;AACnC,QAAA,MAAM,gBAAgB,GAAG,mBAAmB,EAAE;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAC9C;AAEA;;AAEG;IACH,MAAM,OAAO,CAAC,OAAuB,EAAA;QACnC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC;IACvC;AAEA;;AAEG;IACH,aAAa,GAAA;AACX,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE;IACtC;AAEA;;;AAGG;IACH,cAAc,GAAA;AACZ,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE;IACvC;AAEA;;;AAGG;IACH,MAAM,aAAa,CAAC,KAAa,EAAA;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;IAC3C;AACD;;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OneTapFormsConfig, RequestOptions, CompletionResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* OneTapForms SDK class for secure, biometric-authenticated form completion
|
|
4
|
+
*/
|
|
5
|
+
export declare class OneTapForms {
|
|
6
|
+
private instance;
|
|
7
|
+
constructor(config: OneTapFormsConfig);
|
|
8
|
+
/**
|
|
9
|
+
* Create a form completion request
|
|
10
|
+
*/
|
|
11
|
+
request(options: RequestOptions): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Cancel active polling (useful for cleanup)
|
|
14
|
+
*/
|
|
15
|
+
cancelPolling(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Handle callback from redirect flow
|
|
18
|
+
* Call this when user returns to your site with token in URL
|
|
19
|
+
*/
|
|
20
|
+
handleCallback(): CompletionResult | null;
|
|
21
|
+
/**
|
|
22
|
+
* Exchange token for user data (server-side only!)
|
|
23
|
+
* This should be called from your backend, not the browser
|
|
24
|
+
*/
|
|
25
|
+
exchangeToken(token: string): Promise<any>;
|
|
26
|
+
}
|
|
27
|
+
export default OneTapForms;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onetapforms.d.ts","sourceRoot":"","sources":["../src/onetapforms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAuBnF;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAM;gBAEV,MAAM,EAAE,iBAAiB;IAKrC;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD;;OAEG;IACH,aAAa,IAAI,IAAI;IAIrB;;;OAGG;IACH,cAAc,IAAI,gBAAgB,GAAG,IAAI;IAIzC;;;OAGG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAGjD;AAED,eAAe,WAAW,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for initializing the OneTapForms SDK
|
|
3
|
+
*/
|
|
4
|
+
export interface OneTapFormsConfig {
|
|
5
|
+
/** Your client ID provided by Createlex LLC */
|
|
6
|
+
clientId: string;
|
|
7
|
+
/** API URL (defaults to https://api.createlex.com) */
|
|
8
|
+
apiUrl?: string;
|
|
9
|
+
/** API key (optional, defaults to clientId) */
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
/** Enable debug logging (defaults to false) */
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Options for creating a form completion request
|
|
16
|
+
*/
|
|
17
|
+
export interface RequestOptions {
|
|
18
|
+
/** Schema ID identifying the form structure */
|
|
19
|
+
schemaId: string;
|
|
20
|
+
/** Purpose description shown to the user */
|
|
21
|
+
purpose: string;
|
|
22
|
+
/** URL to redirect to after completion */
|
|
23
|
+
returnUrl: string;
|
|
24
|
+
/** Data bundles to request (e.g., ['basic', 'contact']) */
|
|
25
|
+
bundles?: string[];
|
|
26
|
+
/** Specific fields to request */
|
|
27
|
+
fields?: string[];
|
|
28
|
+
/** Request mode: 'auto' (detect device), 'redirect' (mobile), or 'qr' (desktop) */
|
|
29
|
+
mode?: 'auto' | 'redirect' | 'qr';
|
|
30
|
+
/** Additional metadata */
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
/** Customization options */
|
|
33
|
+
customization?: {
|
|
34
|
+
companyName?: string;
|
|
35
|
+
logoUrl?: string;
|
|
36
|
+
};
|
|
37
|
+
/** Callback when request is completed */
|
|
38
|
+
onComplete?: (result: CompletionResult) => void;
|
|
39
|
+
/** Callback when an error occurs */
|
|
40
|
+
onError?: (error: Error) => void;
|
|
41
|
+
/** Callback when QR code is ready (desktop flow) */
|
|
42
|
+
onQRReady?: (qrDataUrl: string) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Result returned when a form completion request is approved
|
|
46
|
+
*/
|
|
47
|
+
export interface CompletionResult {
|
|
48
|
+
/** Exchange token to retrieve user data (server-side) */
|
|
49
|
+
token: string;
|
|
50
|
+
/** Request ID for tracking */
|
|
51
|
+
requestId: string;
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IAClC,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,4BAA4B;IAC5B,aAAa,CAAC,EAAE;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,yCAAyC;IACzC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAChD,oCAAoC;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,oDAAoD;IACpD,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@createlex/onetapforms-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "OneTapForms SDK for secure, biometric-authenticated form completion",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "npm run build:types && npm run build:esm && npm run build:cjs",
|
|
16
|
+
"build:types": "tsc --emitDeclarationOnly --outDir dist --declarationMap false",
|
|
17
|
+
"build:esm": "FORMAT=es rollup -c rollup.config.js",
|
|
18
|
+
"build:cjs": "FORMAT=cjs rollup -c rollup.config.js",
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"test": "echo \"Error: no test specified\" && exit 0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"onetapforms",
|
|
24
|
+
"forms",
|
|
25
|
+
"biometric",
|
|
26
|
+
"authentication",
|
|
27
|
+
"sdk",
|
|
28
|
+
"face-id",
|
|
29
|
+
"touch-id"
|
|
30
|
+
],
|
|
31
|
+
"author": "Createlex LLC",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/createlex/onetapforms-sdk.git"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/createlex/onetapforms-sdk/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/createlex/onetapforms-sdk#readme",
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
43
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
44
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
45
|
+
"@types/node": "^22.0.0",
|
|
46
|
+
"rollup": "^4.9.0",
|
|
47
|
+
"typescript": "^5.7.2"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|