@twilltac/compliance-sdk 0.1.0 → 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 +34 -92
- package/build-revision.txt +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,16 +18,18 @@ const container = document.getElementById('compliance-container');
|
|
|
18
18
|
const plugin = await createCompliancePlugin({
|
|
19
19
|
containerElement: container,
|
|
20
20
|
data: {
|
|
21
|
-
workspace: '
|
|
22
|
-
customerReference: '
|
|
23
|
-
authToken: '
|
|
21
|
+
workspace: 'YOUR_WORKSPACE_KEY',
|
|
22
|
+
customerReference: 'YOUR_CUSTOMER_REFERENCE',
|
|
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,73 +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: 'acme-corp',
|
|
70
|
-
customerReference: 'cust_abc123',
|
|
71
|
-
authToken: 'eyJhbGciOiJIUzI1NiIs...'
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
console.log('Compliance plugin initialised successfully');
|
|
76
|
-
} catch (error) {
|
|
77
|
-
console.error('Failed to initialise compliance plugin:', error);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
initCompliance();
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### React Integration
|
|
85
|
-
|
|
86
|
-
```tsx
|
|
87
|
-
import { useEffect, useRef } from 'react';
|
|
88
|
-
import { createCompliancePlugin, CompliancePlugin } from '@twilltac/compliance-sdk';
|
|
89
|
-
|
|
90
|
-
interface ComplianceWidgetProps {
|
|
91
|
-
workspace: string;
|
|
92
|
-
customerReference: string;
|
|
93
|
-
authToken: string;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function ComplianceWidget({ workspace, customerReference, authToken }: ComplianceWidgetProps) {
|
|
97
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
98
|
-
const pluginRef = useRef<CompliancePlugin | null>(null);
|
|
99
|
-
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
if (!containerRef.current) return;
|
|
102
|
-
|
|
103
|
-
createCompliancePlugin({
|
|
104
|
-
containerElement: containerRef.current,
|
|
105
|
-
data: { workspace, customerReference, authToken }
|
|
106
|
-
})
|
|
107
|
-
.then((plugin) => {
|
|
108
|
-
pluginRef.current = plugin;
|
|
109
|
-
})
|
|
110
|
-
.catch(console.error);
|
|
111
|
-
}, [workspace, customerReference, authToken]);
|
|
112
|
-
|
|
113
|
-
return <div ref={containerRef} style={{ width: '100%', height: '600px' }} />;
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Angular Integration (RxJS)
|
|
55
|
+
### Angular + RxJS
|
|
118
56
|
|
|
119
57
|
```typescript
|
|
120
58
|
import { Component, ElementRef, input, viewChild } from '@angular/core';
|
|
@@ -164,7 +102,7 @@ export class ComplianceComponent {
|
|
|
164
102
|
}
|
|
165
103
|
```
|
|
166
104
|
|
|
167
|
-
### Angular
|
|
105
|
+
### Angular + Promises
|
|
168
106
|
|
|
169
107
|
```typescript
|
|
170
108
|
import { Component, ElementRef, afterNextRender, input, viewChild } from '@angular/core';
|
|
@@ -206,31 +144,37 @@ export class ComplianceComponent {
|
|
|
206
144
|
}
|
|
207
145
|
```
|
|
208
146
|
|
|
209
|
-
|
|
147
|
+
### React
|
|
210
148
|
|
|
211
|
-
|
|
149
|
+
```tsx
|
|
150
|
+
import { useEffect, useRef } from 'react';
|
|
151
|
+
import { createCompliancePlugin, CompliancePlugin } from '@twilltac/compliance-sdk';
|
|
212
152
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
min-height: 400px;
|
|
153
|
+
interface ComplianceWidgetProps {
|
|
154
|
+
workspace: string;
|
|
155
|
+
customerReference: string;
|
|
156
|
+
authToken: string;
|
|
218
157
|
}
|
|
219
|
-
```
|
|
220
158
|
|
|
221
|
-
|
|
159
|
+
function ComplianceWidget({ workspace, customerReference, authToken }: ComplianceWidgetProps) {
|
|
160
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
161
|
+
const pluginRef = useRef<CompliancePlugin | null>(null);
|
|
222
162
|
|
|
223
|
-
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
if (!containerRef.current) return;
|
|
224
165
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
});
|
|
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
|
+
}
|
|
234
178
|
```
|
|
235
179
|
|
|
236
180
|
## Browser Support
|
|
@@ -238,8 +182,6 @@ createCompliancePlugin(options)
|
|
|
238
182
|
The SDK requires a modern browser with support for:
|
|
239
183
|
|
|
240
184
|
- ES2020+
|
|
241
|
-
- `postMessage` API
|
|
242
|
-
- `iframe` elements
|
|
243
185
|
|
|
244
186
|
## Support
|
|
245
187
|
|
package/build-revision.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
20267473081-1
|