@twilltac/compliance-sdk 0.3.0 → 0.4.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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# @twilltac/compliance-sdk
|
|
2
2
|
|
|
3
3
|
SDK for embedding the Twilltac Compliance Plugin into your application. The plugin provides compliance functionality within an iframe, with secure communication between your host application and the plugin.
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@ const container = document.getElementById('compliance-container');
|
|
|
18
18
|
const plugin = await createCompliancePlugin({
|
|
19
19
|
containerElement: container,
|
|
20
20
|
data: {
|
|
21
|
-
|
|
21
|
+
workspaceReference: 'YOUR_WORKSPACE_REFERENCE',
|
|
22
22
|
flow: 'journey',
|
|
23
23
|
customerReference: 'YOUR_CUSTOMER_REFERENCE',
|
|
24
24
|
offerReference: 'YOUR_OFFER_REFERENCE',
|
|
@@ -38,15 +38,16 @@ Creates and initialises the compliance plugin within a container element.
|
|
|
38
38
|
|
|
39
39
|
**Parameters:**
|
|
40
40
|
|
|
41
|
-
| Name
|
|
42
|
-
|
|
|
43
|
-
| `options.containerElement`
|
|
44
|
-
| `options.data.customerReference`
|
|
45
|
-
| `options.data.offerReference`
|
|
46
|
-
| `options.data.
|
|
47
|
-
| `options.data.
|
|
48
|
-
| `options.data.
|
|
49
|
-
| `options.data.
|
|
41
|
+
| Name | Type | Required | Description |
|
|
42
|
+
| --------------------------------- | ------------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `options.containerElement` | `HTMLElement` | Yes | The DOM element where the plugin will be rendered |
|
|
44
|
+
| `options.data.customerReference` | `string` | Yes | Reference identifier for the customer |
|
|
45
|
+
| `options.data.offerReference` | `string` | Yes | Reference identifier for the compliance customer offer |
|
|
46
|
+
| `options.data.workspaceReference` | `string` | One of | Your Twilltac workspace reference. One of `workspaceReference` or `workspaceSubdomain` must be provided |
|
|
47
|
+
| `options.data.workspaceSubdomain` | `string` | One of | Your Twilltac workspace subdomain. One of `workspaceReference` or `workspaceSubdomain` must be provided |
|
|
48
|
+
| `options.data.authToken` | `string` | Yes | Authentication token for the plugin session |
|
|
49
|
+
| `options.data.flow` | `string` | Yes | The plugin flow to load. One of `journey` or `handover` |
|
|
50
|
+
| `options.data.sizing` | `string` | No | `'content'` (default) — plugin element grows to fit content. <br/>`'container'` — plugin fills its container height |
|
|
50
51
|
|
|
51
52
|
**Returns:** `Promise<CompliancePlugin>`
|
|
52
53
|
|
|
@@ -94,13 +95,14 @@ plugin.on('session:expired', () => {
|
|
|
94
95
|
#### Available events:
|
|
95
96
|
|
|
96
97
|
<!-- EVENTS_TABLE_START -->
|
|
97
|
-
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
| `flow.journey.
|
|
101
|
-
| `flow.journey.section:
|
|
102
|
-
| `flow.journey:completed` | `
|
|
103
|
-
| `
|
|
98
|
+
|
|
99
|
+
| Event | Data | Description |
|
|
100
|
+
| -------------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
101
|
+
| `flow.journey.started` | `void` | Emits when the user starts the journey and Initial Disclosure Document is generated. |
|
|
102
|
+
| `flow.journey.section:started` | `SectionStartedEvent` | Emits when the user starts a section. |
|
|
103
|
+
| `flow.journey.section:completed` | `SectionEndedEvent` | Emits when the user completes the question set and submits their recommendations. |
|
|
104
|
+
| `flow.journey:completed` | `void` | Emits when the user completes the journey and summary page is presented. |
|
|
105
|
+
| `session:expired` | `void` | Emits when the session has expired. This would typically trigger your auth flow followed by re-initialising the plugin. |
|
|
104
106
|
|
|
105
107
|
#### Type Definitions
|
|
106
108
|
|
|
@@ -122,6 +124,7 @@ interface SectionEndedEvent {
|
|
|
122
124
|
}[];
|
|
123
125
|
}
|
|
124
126
|
```
|
|
127
|
+
|
|
125
128
|
<!-- EVENTS_TABLE_END -->
|
|
126
129
|
|
|
127
130
|
## Framework Examples
|
|
@@ -139,7 +142,7 @@ import { from, switchMap } from 'rxjs';
|
|
|
139
142
|
template: `<div #container style="width: 100%; height: 600px;"></div>`
|
|
140
143
|
})
|
|
141
144
|
export class ComplianceComponent {
|
|
142
|
-
readonly
|
|
145
|
+
readonly workspaceReference = input.required<string>();
|
|
143
146
|
readonly flow = input.required<string>();
|
|
144
147
|
readonly customerReference = input.required<string>();
|
|
145
148
|
readonly offerReference = input.required<string>();
|
|
@@ -161,7 +164,7 @@ export class ComplianceComponent {
|
|
|
161
164
|
createCompliancePlugin({
|
|
162
165
|
containerElement: container.nativeElement,
|
|
163
166
|
data: {
|
|
164
|
-
|
|
167
|
+
workspaceReference: this.workspaceReference(),
|
|
165
168
|
flow: this.flow(),
|
|
166
169
|
customerReference: this.customerReference(),
|
|
167
170
|
offerReference: this.offerReference(),
|
|
@@ -196,7 +199,7 @@ import { createCompliancePlugin, CompliancePlugin } from '@twilltac/compliance-s
|
|
|
196
199
|
template: `<div #container style="width: 100%; height: 600px;"></div>`
|
|
197
200
|
})
|
|
198
201
|
export class ComplianceComponent {
|
|
199
|
-
readonly
|
|
202
|
+
readonly workspaceReference = input.required<string>();
|
|
200
203
|
readonly flow = input.required<string>();
|
|
201
204
|
readonly customerReference = input.required<string>();
|
|
202
205
|
readonly offerReference = input.required<string>();
|
|
@@ -221,7 +224,7 @@ export class ComplianceComponent {
|
|
|
221
224
|
this._plugin = await createCompliancePlugin({
|
|
222
225
|
containerElement: this._container().nativeElement,
|
|
223
226
|
data: {
|
|
224
|
-
|
|
227
|
+
workspaceReference: this.workspaceReference(),
|
|
225
228
|
flow: this.flow(),
|
|
226
229
|
customerReference: this.customerReference(),
|
|
227
230
|
offerReference: this.offerReference(),
|
|
@@ -243,7 +246,7 @@ import { useEffect, useRef } from 'react';
|
|
|
243
246
|
import { createCompliancePlugin, CompliancePlugin } from '@twilltac/compliance-sdk';
|
|
244
247
|
|
|
245
248
|
interface ComplianceWidgetProps {
|
|
246
|
-
|
|
249
|
+
workspaceReference: string;
|
|
247
250
|
flow: 'journey' | 'handover';
|
|
248
251
|
customerReference: string;
|
|
249
252
|
offerReference: string;
|
|
@@ -251,7 +254,7 @@ interface ComplianceWidgetProps {
|
|
|
251
254
|
sizing?: 'content' | 'container';
|
|
252
255
|
}
|
|
253
256
|
|
|
254
|
-
function ComplianceWidget({
|
|
257
|
+
function ComplianceWidget({ workspaceReference, flow, customerReference, offerReference, authToken, sizing }: ComplianceWidgetProps) {
|
|
255
258
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
256
259
|
const pluginRef = useRef<CompliancePlugin | null>(null);
|
|
257
260
|
|
|
@@ -263,7 +266,7 @@ function ComplianceWidget({ workspace, flow, customerReference, offerReference,
|
|
|
263
266
|
|
|
264
267
|
createCompliancePlugin({
|
|
265
268
|
containerElement: containerRef.current,
|
|
266
|
-
data: {
|
|
269
|
+
data: { workspaceReference, flow, customerReference, offerReference, authToken, sizing }
|
|
267
270
|
})
|
|
268
271
|
.then((plugin) => {
|
|
269
272
|
pluginRef.current = plugin;
|
|
@@ -274,7 +277,7 @@ function ComplianceWidget({ workspace, flow, customerReference, offerReference,
|
|
|
274
277
|
pluginRef.current?.destroy();
|
|
275
278
|
pluginRef.current = null;
|
|
276
279
|
};
|
|
277
|
-
}, [
|
|
280
|
+
}, [workspaceReference, flow, customerReference, offerReference, authToken]);
|
|
278
281
|
|
|
279
282
|
return <div ref={containerRef} style={{ width: '100%', height: '600px' }} />;
|
|
280
283
|
}
|
package/build-revision.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
29081303133-1
|
package/index.cjs
CHANGED
|
@@ -275,8 +275,8 @@ function validateOptions(options) {
|
|
|
275
275
|
if (!options.data) {
|
|
276
276
|
throw new Error("[CompliancePlugin] data is required.");
|
|
277
277
|
}
|
|
278
|
-
if (!options.data.
|
|
279
|
-
throw new Error("[CompliancePlugin] data.
|
|
278
|
+
if (!options.data.workspaceSubdomain && !options.data.workspaceReference) {
|
|
279
|
+
throw new Error("[CompliancePlugin] one of data.workspaceSubdomain or data.workspaceReference is required.");
|
|
280
280
|
}
|
|
281
281
|
const validFlows = Object.values(CompliancePluginFlow);
|
|
282
282
|
if (!options.data.flow || !validFlows.includes(options.data.flow)) {
|
package/index.js
CHANGED
|
@@ -249,8 +249,8 @@ function validateOptions(options) {
|
|
|
249
249
|
if (!options.data) {
|
|
250
250
|
throw new Error("[CompliancePlugin] data is required.");
|
|
251
251
|
}
|
|
252
|
-
if (!options.data.
|
|
253
|
-
throw new Error("[CompliancePlugin] data.
|
|
252
|
+
if (!options.data.workspaceSubdomain && !options.data.workspaceReference) {
|
|
253
|
+
throw new Error("[CompliancePlugin] one of data.workspaceSubdomain or data.workspaceReference is required.");
|
|
254
254
|
}
|
|
255
255
|
const validFlows = Object.values(CompliancePluginFlow);
|
|
256
256
|
if (!options.data.flow || !validFlows.includes(options.data.flow)) {
|
package/libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export declare enum PluginInitialisationSizing {
|
|
|
7
7
|
CONTENT = "content"
|
|
8
8
|
}
|
|
9
9
|
export interface CompliancePluginInitialisationData {
|
|
10
|
-
readonly
|
|
10
|
+
readonly workspaceSubdomain?: string;
|
|
11
|
+
readonly workspaceReference?: string;
|
|
11
12
|
readonly flow: CompliancePluginFlow;
|
|
12
13
|
readonly customerReference: string;
|
|
13
14
|
readonly offerReference: string;
|