@twilltac/compliance-sdk 0.1.1 → 0.1.2
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 +31 -87
- package/build-revision.txt +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,12 +22,14 @@ const plugin = await createCompliancePlugin({
|
|
|
22
22
|
customerReference: 'YOUR_CUSTOMER_REFERENCE',
|
|
23
23
|
authToken: 'YOUR_AUTH_TOKEN'
|
|
24
24
|
}
|
|
25
|
+
}).catch((error) => {
|
|
26
|
+
console.error('The plugin failed to load', error);
|
|
25
27
|
});
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
## API Reference
|
|
29
31
|
|
|
30
|
-
### createCompliancePlugin(options)
|
|
32
|
+
### `createCompliancePlugin(options)`
|
|
31
33
|
|
|
32
34
|
Creates and initialises the compliance plugin within a container element.
|
|
33
35
|
|
|
@@ -48,71 +50,9 @@ The promise resolves when the plugin has successfully initialised. If initialisa
|
|
|
48
50
|
|
|
49
51
|
The plugin instance returned after successful initialisation. Use this to interact with the embedded compliance plugin.
|
|
50
52
|
|
|
51
|
-
##
|
|
53
|
+
## Framework Examples
|
|
52
54
|
|
|
53
|
-
###
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
import { createCompliancePlugin } from '@twilltac/compliance-sdk';
|
|
57
|
-
|
|
58
|
-
async function initCompliance() {
|
|
59
|
-
const container = document.getElementById('compliance-container');
|
|
60
|
-
|
|
61
|
-
if (!container) {
|
|
62
|
-
throw new Error('Container element not found');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
const plugin = await createCompliancePlugin({
|
|
67
|
-
containerElement: container,
|
|
68
|
-
data: {
|
|
69
|
-
workspace: 'YOUR_WORKSPACE_KEY',
|
|
70
|
-
customerReference: 'YOUR_CUSTOMER_REFERENCE',
|
|
71
|
-
authToken: 'YOUR_AUTH_TOKEN'
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
} catch (error) {
|
|
75
|
-
console.error('Failed to initialise compliance plugin:', error);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
initCompliance();
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### React Integration
|
|
83
|
-
|
|
84
|
-
```tsx
|
|
85
|
-
import { useEffect, useRef } from 'react';
|
|
86
|
-
import { createCompliancePlugin, CompliancePlugin } from '@twilltac/compliance-sdk';
|
|
87
|
-
|
|
88
|
-
interface ComplianceWidgetProps {
|
|
89
|
-
workspace: string;
|
|
90
|
-
customerReference: string;
|
|
91
|
-
authToken: string;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function ComplianceWidget({ workspace, customerReference, authToken }: ComplianceWidgetProps) {
|
|
95
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
96
|
-
const pluginRef = useRef<CompliancePlugin | null>(null);
|
|
97
|
-
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
if (!containerRef.current) return;
|
|
100
|
-
|
|
101
|
-
createCompliancePlugin({
|
|
102
|
-
containerElement: containerRef.current,
|
|
103
|
-
data: { workspace, customerReference, authToken }
|
|
104
|
-
})
|
|
105
|
-
.then((plugin) => {
|
|
106
|
-
pluginRef.current = plugin;
|
|
107
|
-
})
|
|
108
|
-
.catch(console.error);
|
|
109
|
-
}, [workspace, customerReference, authToken]);
|
|
110
|
-
|
|
111
|
-
return <div ref={containerRef} style={{ width: '100%', height: '600px' }} />;
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Angular Integration (RxJS)
|
|
55
|
+
### Angular + RxJS
|
|
116
56
|
|
|
117
57
|
```typescript
|
|
118
58
|
import { Component, ElementRef, input, viewChild } from '@angular/core';
|
|
@@ -162,7 +102,7 @@ export class ComplianceComponent {
|
|
|
162
102
|
}
|
|
163
103
|
```
|
|
164
104
|
|
|
165
|
-
### Angular
|
|
105
|
+
### Angular + Promises
|
|
166
106
|
|
|
167
107
|
```typescript
|
|
168
108
|
import { Component, ElementRef, afterNextRender, input, viewChild } from '@angular/core';
|
|
@@ -204,31 +144,37 @@ export class ComplianceComponent {
|
|
|
204
144
|
}
|
|
205
145
|
```
|
|
206
146
|
|
|
207
|
-
|
|
147
|
+
### React
|
|
208
148
|
|
|
209
|
-
|
|
149
|
+
```tsx
|
|
150
|
+
import { useEffect, useRef } from 'react';
|
|
151
|
+
import { createCompliancePlugin, CompliancePlugin } from '@twilltac/compliance-sdk';
|
|
210
152
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
min-height: 400px;
|
|
153
|
+
interface ComplianceWidgetProps {
|
|
154
|
+
workspace: string;
|
|
155
|
+
customerReference: string;
|
|
156
|
+
authToken: string;
|
|
216
157
|
}
|
|
217
|
-
```
|
|
218
158
|
|
|
219
|
-
|
|
159
|
+
function ComplianceWidget({ workspace, customerReference, authToken }: ComplianceWidgetProps) {
|
|
160
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
161
|
+
const pluginRef = useRef<CompliancePlugin | null>(null);
|
|
220
162
|
|
|
221
|
-
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
if (!containerRef.current) return;
|
|
222
165
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
});
|
|
166
|
+
createCompliancePlugin({
|
|
167
|
+
containerElement: containerRef.current,
|
|
168
|
+
data: { workspace, customerReference, authToken }
|
|
169
|
+
})
|
|
170
|
+
.then((plugin) => {
|
|
171
|
+
pluginRef.current = plugin;
|
|
172
|
+
})
|
|
173
|
+
.catch(console.error);
|
|
174
|
+
}, [workspace, customerReference, authToken]);
|
|
175
|
+
|
|
176
|
+
return <div ref={containerRef} style={{ width: '100%', height: '600px' }} />;
|
|
177
|
+
}
|
|
232
178
|
```
|
|
233
179
|
|
|
234
180
|
## Browser Support
|
|
@@ -236,8 +182,6 @@ createCompliancePlugin(options)
|
|
|
236
182
|
The SDK requires a modern browser with support for:
|
|
237
183
|
|
|
238
184
|
- ES2020+
|
|
239
|
-
- `postMessage` API
|
|
240
|
-
- `iframe` elements
|
|
241
185
|
|
|
242
186
|
## Support
|
|
243
187
|
|
package/build-revision.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
20267473081-1
|