@soyio/soyio-widget 2.11.2 → 2.12.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 +115 -1
- package/dist/index.d.ts +306 -25
- package/dist/index.js +328 -324
- package/dist/index.umd.cjs +16 -16
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -253,7 +253,7 @@ The **`auth_request`** is a process where, using a previously created `auth_requ
|
|
|
253
253
|
|
|
254
254
|
// Widget configuration
|
|
255
255
|
const widgetConfig = {
|
|
256
|
-
request: "
|
|
256
|
+
request: "authentication_request",
|
|
257
257
|
configProps: {
|
|
258
258
|
authRequestId: "<auth request id>",
|
|
259
259
|
customColor: "<custom color>",
|
|
@@ -498,3 +498,117 @@ To use the `SoyioTypes` in your project, import it directly from the `@soyio/soy
|
|
|
498
498
|
```javascript
|
|
499
499
|
import type { SoyioTypes } from "@soyio/soyio-widget";
|
|
500
500
|
```
|
|
501
|
+
|
|
502
|
+
## Server Side Rendering (SSR)
|
|
503
|
+
|
|
504
|
+
This package is not directly compatible with SSR because of `post-robot`, but there are workarounds that allow you to use it without disrupting the build process. Below are examples on popular SSR frameworks.
|
|
505
|
+
|
|
506
|
+
### Next.js
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
```tsx
|
|
510
|
+
'use client'
|
|
511
|
+
|
|
512
|
+
import { useMemo, useEffect, useState } from "react";
|
|
513
|
+
|
|
514
|
+
export default function PrivacyCenterBox() {
|
|
515
|
+
const privacyCenterOptions = useMemo(() => ({
|
|
516
|
+
companyId: 'com_lalala',
|
|
517
|
+
// ... other options
|
|
518
|
+
onEvent: () => {}
|
|
519
|
+
}), []);
|
|
520
|
+
|
|
521
|
+
const [privacyCenter, setPrivacyCenter] = useState(null);
|
|
522
|
+
|
|
523
|
+
useEffect(() => {
|
|
524
|
+
async function mountPrivacyCenter() {
|
|
525
|
+
if (privacyCenter) return;
|
|
526
|
+
|
|
527
|
+
const { PrivacyCenterBox } = await import('@soyio/soyio-widget');
|
|
528
|
+
const privacyCenterBox = new PrivacyCenterBox(privacyCenterOptions);
|
|
529
|
+
privacyCenterBox.mount("#privacy-center-box");
|
|
530
|
+
|
|
531
|
+
setPrivacyCenter(privacyCenterBox);
|
|
532
|
+
}
|
|
533
|
+
mountPrivacyCenter();
|
|
534
|
+
|
|
535
|
+
return () => privacyCenter?.unmount();
|
|
536
|
+
}, [privacyCenterOptions, privacyCenter]);
|
|
537
|
+
|
|
538
|
+
return (
|
|
539
|
+
<div>
|
|
540
|
+
<h1>Hello World</h1>
|
|
541
|
+
<div id="privacy-center-box"></div>
|
|
542
|
+
</div>
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Gatsby
|
|
549
|
+
|
|
550
|
+
```tsx
|
|
551
|
+
// PrivacyCenterBox.tsx
|
|
552
|
+
|
|
553
|
+
import React, { useEffect, useState, useMemo } from "react";
|
|
554
|
+
|
|
555
|
+
export default function PrivacyCenterBox({ onReady }) {
|
|
556
|
+
const [privacyCenter, setPrivacyCenter] = useState(null);
|
|
557
|
+
|
|
558
|
+
const privacyCenterOptions = useMemo(() => ({
|
|
559
|
+
// other options...
|
|
560
|
+
companyId: process.env.SOYIO_COMPANY_ID || 'com_lalala',
|
|
561
|
+
onEvent: () => {}
|
|
562
|
+
}), [onReady]);
|
|
563
|
+
|
|
564
|
+
useEffect(() => {
|
|
565
|
+
async function mountPrivacyCenter() {
|
|
566
|
+
if (privacyCenter) return;
|
|
567
|
+
|
|
568
|
+
const { PrivacyCenterBox } = await import('@soyio/soyio-widget');
|
|
569
|
+
const privacyCenterBox = new PrivacyCenterBox(privacyCenterOptions);
|
|
570
|
+
privacyCenterBox.mount("#privacy-center-box");
|
|
571
|
+
|
|
572
|
+
setPrivacyCenter(privacyCenterBox);
|
|
573
|
+
}
|
|
574
|
+
mountPrivacyCenter();
|
|
575
|
+
|
|
576
|
+
return () => privacyCenter?.unmount();
|
|
577
|
+
}, [privacyCenterOptions, privacyCenter]);
|
|
578
|
+
|
|
579
|
+
return (<div id="privacy-center-box"></div>)
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
Then use `React.lazy` and `React.Suspense` when declaring that component elsewhere.
|
|
585
|
+
|
|
586
|
+
```tsx
|
|
587
|
+
// AnotherComponent.tsx
|
|
588
|
+
|
|
589
|
+
import React, { useState, useCallback, useEffect } from "react";
|
|
590
|
+
|
|
591
|
+
const PrivacyCenterBox = React.lazy(() => import('yourPathTo/PrivacyCenterBox'));
|
|
592
|
+
|
|
593
|
+
export default function PrivacyCenterContainer() {
|
|
594
|
+
const [isClient, setIsClient] = useState(false);
|
|
595
|
+
|
|
596
|
+
useEffect(() => setIsClient(true), []);
|
|
597
|
+
|
|
598
|
+
const onReady = useCallback(() => setIsPrivacyCenterLoading(false), []);
|
|
599
|
+
|
|
600
|
+
return (
|
|
601
|
+
<div>
|
|
602
|
+
{isClient &&
|
|
603
|
+
<React.Suspense fallback={
|
|
604
|
+
<div>
|
|
605
|
+
Loading...
|
|
606
|
+
</div>
|
|
607
|
+
}>
|
|
608
|
+
<PrivacyCenterBox onReady={onReady} />
|
|
609
|
+
</React.Suspense>
|
|
610
|
+
}
|
|
611
|
+
</div>
|
|
612
|
+
)
|
|
613
|
+
}
|
|
614
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,275 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
declare type AuthRequestConfig = {
|
|
2
|
+
request: 'authentication_request';
|
|
3
|
+
configProps: AuthRequestProps;
|
|
4
|
+
onEvent: (data: EventData) => void;
|
|
5
|
+
isSandbox?: boolean;
|
|
6
|
+
developmentUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
declare type AuthRequestProps = {
|
|
10
|
+
authRequestId: `authreq_${string}`;
|
|
11
|
+
customColor?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare type BaseConfig = {
|
|
15
|
+
onEvent: (event: Record<string, unknown>) => void;
|
|
16
|
+
onReady?: () => void;
|
|
17
|
+
isSandbox?: boolean;
|
|
18
|
+
appearance?: SoyioAppearance;
|
|
19
|
+
developmentUrl?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
declare abstract class BaseIframeBox<T extends BaseConfig> {
|
|
23
|
+
protected iframe: HTMLIFrameElement | null;
|
|
24
|
+
protected skeleton: ISkeletonView | null;
|
|
25
|
+
protected readonly options: T;
|
|
26
|
+
protected readonly appearance: SoyioAppearance | null;
|
|
27
|
+
protected readonly tooltipManager: _TooltipManager;
|
|
28
|
+
readonly defaultIframeCSSConfig: IframeCSSConfig;
|
|
29
|
+
protected Skeleton: SkeletonConstructor | null;
|
|
30
|
+
private readonly defaultUniqueId;
|
|
31
|
+
abstract readonly defaultIframePrefix: string;
|
|
32
|
+
constructor(options: T);
|
|
33
|
+
static generateUniqueId(): string;
|
|
34
|
+
get uniqueIdentifier(): string;
|
|
35
|
+
abstract iframeUrl(): string;
|
|
36
|
+
get iframeIdentifier(): string;
|
|
37
|
+
protected handleHeightChange(height: number): void;
|
|
38
|
+
protected handleIframeReady(): Promise<void>;
|
|
39
|
+
protected handleTooltipChange(tooltipState: ITooltipStateChangeEvent): void;
|
|
40
|
+
protected setupListeners(): Promise<void>;
|
|
41
|
+
mount(selector: string): Promise<this>;
|
|
42
|
+
unmount(): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare const CLOSED_EVENT = "WIDGET_CLOSED";
|
|
46
|
+
|
|
47
|
+
export declare class ConsentBox extends BaseIframeBox<ConsentConfig> {
|
|
48
|
+
readonly defaultIframePrefix = "consent-box";
|
|
49
|
+
readonly defaultIframeCSSConfig: IframeCSSConfig;
|
|
50
|
+
private state;
|
|
51
|
+
constructor(options: ConsentConfig);
|
|
52
|
+
get uniqueIdentifier(): string;
|
|
53
|
+
iframeUrl(): string;
|
|
54
|
+
protected handleStateChange(newState: ConsentState): void;
|
|
55
|
+
protected setupListeners(): Promise<void>;
|
|
56
|
+
getState(): Readonly<ConsentState>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare type ConsentCheckboxChangeEvent = {
|
|
60
|
+
eventName: 'CONSENT_CHECKBOX_CHANGE';
|
|
61
|
+
isSelected: boolean;
|
|
62
|
+
actionToken?: string;
|
|
63
|
+
identifier: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
declare type ConsentConfig = BaseConfig & {
|
|
67
|
+
consentTemplateId: `constpl_${string}`;
|
|
68
|
+
actionToken?: string;
|
|
69
|
+
entityId?: `ent_${string}`;
|
|
70
|
+
context?: string;
|
|
71
|
+
optionalReconsentBehavior?: 'notice' | 'askAgain' | 'hide';
|
|
72
|
+
mandatoryReconsentBehavior?: 'notice' | 'askAgain';
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
declare type ConsentEvent = ConsentCheckboxChangeEvent;
|
|
76
|
+
|
|
77
|
+
declare type ConsentState = {
|
|
78
|
+
isSelected: boolean;
|
|
79
|
+
actionToken: string | null;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
declare type CSSProperties = {
|
|
83
|
+
appearance?: string;
|
|
84
|
+
accentColor?: string;
|
|
85
|
+
backgroundColor?: string;
|
|
86
|
+
border?: string;
|
|
87
|
+
borderBottom?: string;
|
|
88
|
+
borderBottomColor?: string;
|
|
89
|
+
borderBottomLeftRadius?: string;
|
|
90
|
+
borderBottomRightRadius?: string;
|
|
91
|
+
borderBottomStyle?: string;
|
|
92
|
+
borderBottomWidth?: string;
|
|
93
|
+
borderColor?: string;
|
|
94
|
+
borderLeft?: string;
|
|
95
|
+
borderLeftColor?: string;
|
|
96
|
+
borderLeftStyle?: string;
|
|
97
|
+
borderLeftWidth?: string;
|
|
98
|
+
borderRadius?: string;
|
|
99
|
+
borderRight?: string;
|
|
100
|
+
borderRightColor?: string;
|
|
101
|
+
borderRightStyle?: string;
|
|
102
|
+
borderRightWidth?: string;
|
|
103
|
+
borderStyle?: string;
|
|
104
|
+
borderTop?: string;
|
|
105
|
+
borderTopColor?: string;
|
|
106
|
+
borderTopLeftRadius?: string;
|
|
107
|
+
borderTopRightRadius?: string;
|
|
108
|
+
borderTopStyle?: string;
|
|
109
|
+
borderTopWidth?: string;
|
|
110
|
+
borderWidth?: string;
|
|
111
|
+
boxShadow?: string;
|
|
112
|
+
color?: string;
|
|
113
|
+
cursor?: string;
|
|
114
|
+
fill?: string;
|
|
115
|
+
fillOpacity?: number;
|
|
116
|
+
fontFamily?: string;
|
|
117
|
+
fontSize?: string;
|
|
118
|
+
fontVariant?: string;
|
|
119
|
+
fontWeight?: string | number;
|
|
120
|
+
height?: string;
|
|
121
|
+
letterSpacing?: string;
|
|
122
|
+
lineHeight?: string | number;
|
|
123
|
+
margin?: string;
|
|
124
|
+
marginBottom?: string;
|
|
125
|
+
marginLeft?: string;
|
|
126
|
+
marginRight?: string;
|
|
127
|
+
marginTop?: string;
|
|
128
|
+
opacity?: number;
|
|
129
|
+
outline?: string;
|
|
130
|
+
outlineOffset?: string;
|
|
131
|
+
padding?: string;
|
|
132
|
+
paddingBottom?: string;
|
|
133
|
+
paddingLeft?: string;
|
|
134
|
+
paddingRight?: string;
|
|
135
|
+
paddingTop?: string;
|
|
136
|
+
mozOsxFontSmoothing?: 'auto' | 'grayscale' | 'unset';
|
|
137
|
+
WebkitAppearance?: string;
|
|
138
|
+
webkitFontSmoothing?: 'auto' | 'antialiased' | 'subpixel-antialiased';
|
|
139
|
+
webkitTextFillColor?: string;
|
|
140
|
+
width?: string;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
declare type DisclosureRequestConfig = {
|
|
144
|
+
request: 'disclosure';
|
|
145
|
+
configProps: DisclosureRequestProps;
|
|
146
|
+
onEvent: (data: EventData) => void;
|
|
147
|
+
isSandbox?: boolean;
|
|
148
|
+
developmentUrl?: string;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
declare type DisclosureRequestProps = NewDisclosureRequestProps | ExistingDisclosureRequestProps;
|
|
152
|
+
|
|
153
|
+
declare type EventData = {
|
|
154
|
+
eventName: 'IDENTITY_VALIDATED' | 'IDENTITY_AUTHENTICATED' | 'IDENTITY_SIGNATURE' | 'DENIED_CAMERA_PERMISSION' | 'REJECTED_SIGNATURE' | 'DISCLOSURE_REQUEST_SUCCESSFUL' | 'UNEXPECTED_ERROR' | 'AUTH_REQUEST_SUCCESSFUL' | typeof CLOSED_EVENT;
|
|
155
|
+
identityId: `id_${string}`;
|
|
156
|
+
userReference?: string;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
declare type ExistingDisclosureRequestProps = {
|
|
160
|
+
companyId?: never;
|
|
161
|
+
templateId?: never;
|
|
162
|
+
disclosureRequestId: `dreq_${string}`;
|
|
163
|
+
userReference?: never;
|
|
164
|
+
userEmail?: never;
|
|
165
|
+
forceError?: ForceErrors;
|
|
166
|
+
customColor?: string;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
declare type ForceErrors = 'facial_validation_error' | 'document_validation_error' | 'unknown_error' | 'expiration_error' | 'camera_permission_error';
|
|
170
|
+
|
|
171
|
+
declare interface IBaseEventData {
|
|
172
|
+
identifier: string;
|
|
173
|
+
eventName: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare type IframeCSSConfig = {
|
|
177
|
+
minWidth?: string;
|
|
178
|
+
maxWidth?: string;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
declare interface ISkeletonView {
|
|
182
|
+
mount(container: HTMLElement): void;
|
|
183
|
+
hide(): void;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
declare interface ITooltipStateChangeEvent extends IBaseEventData {
|
|
187
|
+
eventName: 'TOOLTIP_STATE_CHANGE';
|
|
188
|
+
text: string;
|
|
189
|
+
coordinates: {
|
|
190
|
+
x: number;
|
|
191
|
+
y: number;
|
|
192
|
+
};
|
|
193
|
+
isVisible: boolean;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
declare type NewDisclosureRequestProps = {
|
|
197
|
+
companyId: `com_${string}`;
|
|
198
|
+
templateId: `dtpl_${string}`;
|
|
199
|
+
disclosureRequestId?: never;
|
|
200
|
+
userReference: string;
|
|
201
|
+
userEmail?: string;
|
|
202
|
+
forceError?: ForceErrors;
|
|
203
|
+
customColor?: string;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export declare class PrivacyCenterBox extends BaseIframeBox<PrivacyCenterConfig> {
|
|
207
|
+
readonly defaultIframePrefix = "privacy-center";
|
|
208
|
+
protected readonly _uniqueIdentifier = "privacy-center";
|
|
209
|
+
readonly defaultIframeCSSConfig: IframeCSSConfig;
|
|
210
|
+
get uniqueIdentifier(): string;
|
|
211
|
+
iframeUrl(): string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
declare type PrivacyCenterConfig = BaseConfig & {
|
|
215
|
+
companyId: `com_${string}`;
|
|
216
|
+
subjectId?: `ent_${string}`;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
declare type Request_2 = 'disclosure' | 'signature' | 'authentication';
|
|
220
|
+
|
|
221
|
+
declare type RequestConfig = DisclosureRequestConfig | SignatureRequestConfig | AuthRequestConfig;
|
|
222
|
+
|
|
223
|
+
declare type SignatureAttemptProps = {
|
|
224
|
+
signatureAttemptId: `sa_${string}`;
|
|
225
|
+
forceError?: ForceErrors;
|
|
226
|
+
customColor?: string;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
declare type SignatureRequestConfig = {
|
|
230
|
+
request: 'signature';
|
|
231
|
+
configProps: SignatureAttemptProps;
|
|
232
|
+
onEvent: (data: EventData) => void;
|
|
233
|
+
isSandbox?: boolean;
|
|
234
|
+
developmentUrl?: string;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
declare type SkeletonConstructor = new (id: string) => ISkeletonView;
|
|
238
|
+
|
|
239
|
+
declare interface SoyioAppearance {
|
|
240
|
+
theme?: SoyioTheme;
|
|
241
|
+
variables?: SoyioAppearanceVariables;
|
|
242
|
+
rules?: SoyioRule;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
declare interface SoyioAppearanceVariables {
|
|
246
|
+
fontFamily?: string;
|
|
247
|
+
fontSizeBase?: string;
|
|
248
|
+
borderRadius?: string;
|
|
249
|
+
borderWidth?: string;
|
|
250
|
+
borderStyle?: string;
|
|
251
|
+
colorPrimary?: string;
|
|
252
|
+
colorSecondary?: string;
|
|
253
|
+
colorBackground?: string;
|
|
254
|
+
colorText?: string;
|
|
255
|
+
colorTextSecondary?: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
declare type SoyioBaseRule = '.MainContainer' | '.Button' | '.Checkbox' | '.CheckboxInput' | '.CheckboxLabel';
|
|
259
|
+
|
|
260
|
+
declare type SoyioElementState = '--checked';
|
|
261
|
+
|
|
262
|
+
declare type SoyioPseudoClass = ':hover' | ':focus' | ':active' | ':disabled' | ':autofill' | ':focus-visible';
|
|
263
|
+
|
|
264
|
+
declare type SoyioPseudoElement = '::placeholder' | '::selection';
|
|
265
|
+
|
|
266
|
+
declare type SoyioRule = {
|
|
267
|
+
[K in SoyioRuleKey]?: CSSProperties;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
declare type SoyioRuleKey = `${SoyioBaseRule}${SoyioElementState | SoyioPseudoClass | SoyioPseudoElement | ''}`;
|
|
271
|
+
|
|
272
|
+
declare type SoyioTheme = 'soyio';
|
|
25
273
|
|
|
26
274
|
declare namespace SoyioTypes {
|
|
27
275
|
export {
|
|
@@ -45,9 +293,42 @@ declare namespace SoyioTypes {
|
|
|
45
293
|
}
|
|
46
294
|
export { SoyioTypes }
|
|
47
295
|
|
|
296
|
+
declare namespace SoyioTypes_2 {
|
|
297
|
+
export {
|
|
298
|
+
ForceErrors,
|
|
299
|
+
Request_2 as Request,
|
|
300
|
+
NewDisclosureRequestProps,
|
|
301
|
+
ExistingDisclosureRequestProps,
|
|
302
|
+
DisclosureRequestProps,
|
|
303
|
+
SignatureAttemptProps,
|
|
304
|
+
AuthRequestProps,
|
|
305
|
+
EventData,
|
|
306
|
+
DisclosureRequestConfig,
|
|
307
|
+
SignatureRequestConfig,
|
|
308
|
+
AuthRequestConfig,
|
|
309
|
+
RequestConfig
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
declare class SoyioWidget {
|
|
314
|
+
#private;
|
|
315
|
+
private onEvent;
|
|
316
|
+
constructor(options: SoyioTypes_2.RequestConfig);
|
|
317
|
+
}
|
|
48
318
|
export { SoyioWidget }
|
|
49
319
|
export default SoyioWidget;
|
|
50
320
|
|
|
51
|
-
export
|
|
321
|
+
export declare class _TooltipManager {
|
|
322
|
+
private tooltipElement;
|
|
323
|
+
private tooltipContent;
|
|
324
|
+
private readonly tooltipClass;
|
|
325
|
+
private hideTimeout;
|
|
326
|
+
constructor();
|
|
327
|
+
private createTooltipElement;
|
|
328
|
+
private setupGlobalListeners;
|
|
329
|
+
show(text: string, x: number, y: number): void;
|
|
330
|
+
hide(): void;
|
|
331
|
+
destroy(): void;
|
|
332
|
+
}
|
|
52
333
|
|
|
53
334
|
export { }
|