@dataspike/docver-widget 0.1.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 ADDED
@@ -0,0 +1,226 @@
1
+ # DocVer-widget
2
+
3
+ ### Live Demo
4
+
5
+ Please check <a href="https://dash.dataspike.io/widget/demo" target="_blank">live demo</a>
6
+
7
+ ### Install
8
+
9
+ ```
10
+ yarn install @dataspike/docver-widget
11
+ ```
12
+ or
13
+ ```
14
+ npm i @dataspike/docver-widget
15
+ ```
16
+ or add static js file
17
+
18
+ ```
19
+ https://static.dataspike.io/scripts/widget-latest.js
20
+ ```
21
+ or use specific version
22
+ ```
23
+ https://static.dataspike.io/scripts/widget-{version}.js
24
+ ```
25
+ Actual version you can find in https://www.npmjs.com/package/@dataspike/docver-widget
26
+
27
+ How to use:
28
+
29
+ ```
30
+ import { DocsVerificationWidget } from @dataspike/docver-widget;
31
+ ....
32
+ DocsVerificationWidgetProps(props);
33
+ ```
34
+
35
+ Available props:
36
+
37
+ <table>
38
+ <tr>
39
+ <th>Prop name</th>
40
+ <th>Types</th>
41
+ <th>Description</th>
42
+ </tr>
43
+ <tr>
44
+ <td>id</td>
45
+ <td>string</td>
46
+ <td>Check
47
+ <a target="_blank"
48
+ href="https://docs.dataspike.io/api#tag/Verifications/operation/create-verification">
49
+ API documentation
50
+ </a>
51
+ </td>
52
+ </tr>
53
+ <tr>
54
+ <td>apiUrl</td>
55
+ <td>string</td>
56
+ <td>
57
+ <a target="_blank" href="https://docs.dataspike.io/api">
58
+ https://api.dataspike.io
59
+ </a>
60
+ </td>
61
+ </tr>
62
+ <tr>
63
+ <td>elementId</td>
64
+ <td>string</td>
65
+ <td>Id of element when widget will be rendered</td>
66
+ </tr>
67
+ <tr>
68
+ <td>onFinish</td>
69
+ <td>() => Promise&lt;void&gt;</td>
70
+ <td>Callback raised when user finish verification</td>
71
+ </tr>
72
+ <tr>
73
+ <td>onInit</td>
74
+ <td>(verificationStatus: 'completed' | 'expired' | 'active' | 'error', error?: unknown) => Promise&lt;void&gt;</td>
75
+ <td>Callback raised before verification started</td>
76
+ </tr>
77
+ <tr>
78
+ <td>theme</td>
79
+ <td>Check theme section</td>
80
+ <td>Custom styles</td>
81
+ </tr>
82
+ <tr>
83
+ <td>defaultLanguage</td>
84
+ <td>'en' | 'es' | 'pt' | 'ru' | 'de'</td>
85
+ <td>Default Language</td>
86
+ </tr>
87
+ </table>
88
+
89
+ ### Example:
90
+ ```
91
+ import { DocsVerificationWidget } from '@dataspike/docver-widget';
92
+
93
+ export const renderWidget = async () => {
94
+ if (container) {
95
+ DocsVerificationWidget({
96
+ id: 'VF57124F182867E0'
97
+ elementId: 'root',
98
+ apiUrl: 'https://api.dataspike.io',
99
+ });
100
+ }
101
+ };
102
+
103
+ renderWidget()
104
+ ```
105
+
106
+ Or
107
+
108
+ ```
109
+ <script type="module" defer src="https://static.dataspike.io/scripts/dataspike-latest.js"></script>
110
+ <script>
111
+ document.addEventListener('DOMContentLoaded', () => {
112
+ const renderWidget = async () => {
113
+ const container = window.document.querySelector('#root');
114
+ if (container) {
115
+ window.DocsVerificationWidget({
116
+ id: 'VF57124F182867E0',
117
+ elementId: 'root',
118
+ apiUrl: 'https://api.dataspike.io',
119
+ });
120
+ }
121
+ };
122
+
123
+ renderWidget()
124
+ });
125
+ </script>
126
+ ```
127
+ ### Html:
128
+ ```html
129
+ <!DOCTYPE html>
130
+ <html lang="en">
131
+ <head>
132
+ <meta charset="utf-8" />
133
+ </head>
134
+ <body>
135
+ <noscript>You need to enable JavaScript to run this app.</noscript>
136
+ <div id="root"></div>
137
+ </body>
138
+ </html>
139
+
140
+ ```
141
+
142
+ ### Theme:
143
+ In comment described default value:
144
+ ```typescript
145
+ export type Theme = {
146
+ palette?: Partial<{
147
+ textMain: string; // #000000
148
+ textLight: string; // #737390
149
+ primaryA1: string; // #6664E8
150
+ primaryA2: string; // #5A58DF
151
+ primaryA3: string; // #D0D0FC
152
+ primaryA4: string; // #E8E8FC
153
+ primaryA5: string; // #E0E0FA
154
+ primaryA6: string; // #E6EDFB
155
+ primaryA7: string; // #FFFFFF
156
+ secondaryA1: string; // #F6CDD9
157
+ secondaryA2: string; // #F6F0C0
158
+ secondaryA3: string; // #52C27F
159
+ secondaryA4: string; // #FF5050
160
+ secondaryA5: string; // #FFFCFD
161
+ secondaryA6: string; // #FABC46
162
+ secondaryA7: string; // #B25DF5
163
+ secondaryA8: string; // #EDECFC
164
+ secondaryA9: string; // #DEE1F2
165
+ secondaryA10: string; // #F6F8FE
166
+ }>;
167
+ typography?: Partial<{
168
+ fontFamily: string; // 'Funnel Display', Roboto, sans-serif
169
+ body1: {
170
+ fontFamily: string; // 'Funnel Display', Roboto, sans-serif
171
+ };
172
+ body2: {
173
+ fontFamily: string; // 'Funnel Display', Roboto, sans-serif
174
+ };
175
+ caption: {
176
+ fontFamily: string; // 'Funnel Display', Roboto, sans-serif
177
+ };
178
+ h1: Partial<{
179
+ fontFamily: string; // 'Funnel Display', Roboto, sans-serif
180
+ fontSize: string; // 50px
181
+ fontWeight: string; // 500
182
+ lineHeight: string; // 70px
183
+ letterSpacing: string; // -0.01em
184
+ }>;
185
+ h2: Partial<{
186
+ fontFamily: string; // 'Funnel Display', Roboto, sans-serif
187
+ fontSize: string; // 28px
188
+ fontWeight: string; // 500
189
+ lineHeight: string; // 40px
190
+ letterSpacing: string; // -0.01em
191
+ }>;
192
+ h3: Partial<{
193
+ fontFamily: string; // 'Funnel Display', Roboto, sans-serif
194
+ fontSize: string; // 20px
195
+ fontWeight: string; // 500
196
+ lineHeight: string; // 30px
197
+ letterSpacing: string; // -0.01em
198
+ }>;
199
+ text: Partial<{
200
+ fontSize: string; // 14px
201
+ lineHeight: string; // 22px
202
+ letterSpacing: string; // 0.002em
203
+ }>;
204
+ textBold: Partial<{
205
+ fontSize: string; // 14px
206
+ fontWeight: string; // 500
207
+ lineHeight: string; // 22px
208
+ letterSpacing: string; // 0.002em
209
+ }>;
210
+ smallText: Partial<{
211
+ fontSize: string; // 12px
212
+ lineHeight: string; // 18px
213
+ letterSpacing: string; // 0.002em
214
+ }>;
215
+ smallTextBold: Partial<{
216
+ fontSize: string; // 12px
217
+ fontWeight: string; // 500
218
+ lineHeight: string; // 18px
219
+ letterSpacing: string; // 0.002em
220
+ }>;
221
+ }>;
222
+ };
223
+ ```
224
+
225
+
226
+ If you have any question about integration, please [contact us](https://www.dataspike.io/contact-us).
package/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type { Theme } from './theme';
2
+
3
+ export type Props = {
4
+ id: string;
5
+ apiUrl: string;
6
+ elementId: string;
7
+ onFinish?: () => void | Promise<void>;
8
+ onInit?: (
9
+ verificationStatus: 'completed' | 'expired' | 'active' | 'error',
10
+ error?: unknown,
11
+ ) => void | Promise<void>;
12
+ settings?: unknown;
13
+ redirectUrl?: string;
14
+ logsUrl?: string;
15
+ theme?: Theme;
16
+ defaultLanguage?: 'en' | 'es' | 'pt' | 'ru' | 'de';
17
+ };
18
+
19
+ declare module '@dataspike/docver-widget' {
20
+ export type DocsVerificationWidgetProps = Props;
21
+ export const DocsVerificationWidget: (props: DocsVerificationWidgetProps) => void;
22
+ }