@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
- \_# @twilltac/compliance-sdk
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
- workspace: 'YOUR_WORKSPACE_KEY',
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 | 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.workspace` | `string` | Yes | Your Twilltac workspace identifier |
47
- | `options.data.authToken` | `string` | Yes | Authentication token for the plugin session |
48
- | `options.data.flow` | `string` | Yes | The plugin flow to load. One of `journey` or `handover` |
49
- | `options.data.sizing` | `string` | No | `'content'` (default) — plugin element grows to fit content. <br/>`'container'` — plugin fills its container height |
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
- | Event | Data | Description |
98
- | ----- | ---- | ----------- |
99
- | `flow.journey.started` | `void` | Emits when the user starts the journey and Initial Disclosure Document is generated. |
100
- | `flow.journey.section:started` | `SectionStartedEvent` | Emits when the user starts a section. |
101
- | `flow.journey.section:completed` | `SectionEndedEvent` | Emits when the user completes the question set and submits their recommendations. |
102
- | `flow.journey:completed` | `void` | Emits when the user completes the journey and summary page is presented. |
103
- | `session:expired` | `void` | Emits when the session has expired. This would typically trigger your auth flow followed by re-initialising the plugin. |
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 workspace = input.required<string>();
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
- workspace: this.workspace(),
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 workspace = input.required<string>();
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
- workspace: this.workspace(),
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
- workspace: string;
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({ workspace, flow, customerReference, offerReference, authToken, sizing }: ComplianceWidgetProps) {
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: { workspace, flow, customerReference, offerReference, authToken, sizing }
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
- }, [workspace, flow, customerReference, offerReference, authToken]);
280
+ }, [workspaceReference, flow, customerReference, offerReference, authToken]);
278
281
 
279
282
  return <div ref={containerRef} style={{ width: '100%', height: '600px' }} />;
280
283
  }
@@ -1 +1 @@
1
- 28376130533-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.workspace) {
279
- throw new Error("[CompliancePlugin] data.workspace is required.");
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.workspace) {
253
- throw new Error("[CompliancePlugin] data.workspace is required.");
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)) {
@@ -7,7 +7,8 @@ export declare enum PluginInitialisationSizing {
7
7
  CONTENT = "content"
8
8
  }
9
9
  export interface CompliancePluginInitialisationData {
10
- readonly workspace: string;
10
+ readonly workspaceSubdomain?: string;
11
+ readonly workspaceReference?: string;
11
12
  readonly flow: CompliancePluginFlow;
12
13
  readonly customerReference: string;
13
14
  readonly offerReference: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twilltac/compliance-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",