cgs-compliance-sdk 2.0.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 +278 -0
- package/dist/compliance/index.js +1478 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/compliance/index.mjs +1475 -0
- package/dist/compliance/index.mjs.map +1 -0
- package/dist/geolocation/index.js +784 -0
- package/dist/geolocation/index.js.map +1 -0
- package/dist/geolocation/index.mjs +777 -0
- package/dist/geolocation/index.mjs.map +1 -0
- package/dist/index.js +1810 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1790 -0
- package/dist/index.mjs.map +1 -0
- package/dist/risk-profile/index.js +548 -0
- package/dist/risk-profile/index.js.map +1 -0
- package/dist/risk-profile/index.mjs +546 -0
- package/dist/risk-profile/index.mjs.map +1 -0
- package/package.json +78 -0
package/README.md
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# cgs-compliance-sdk - Unified CGS Compliance SDK
|
|
2
|
+
|
|
3
|
+
> Comprehensive TypeScript SDK for CGS Compliance Platform - Geolocation, Risk Profiling, and Compliance Orchestration
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Geolocation Compliance** - IP verification, VPN detection, jurisdiction checks, device fingerprinting
|
|
8
|
+
- **Risk Profiling** - Automated customer risk profile creation and management
|
|
9
|
+
- **Compliance Orchestration** - Unified registration, login, and transaction verification
|
|
10
|
+
- **React Hooks** - Ready-to-use hooks for common compliance workflows
|
|
11
|
+
- **Tree-Shakeable** - Import only what you need
|
|
12
|
+
- **Type-Safe** - Full TypeScript support with detailed type definitions
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install cgs-compliance-sdk
|
|
18
|
+
# or
|
|
19
|
+
yarn add cgs-compliance-sdk
|
|
20
|
+
# or
|
|
21
|
+
pnpm add cgs-compliance-sdk
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
### Registration Flow
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { ComplianceClient } from 'cgs-compliance-sdk';
|
|
30
|
+
|
|
31
|
+
const sdk = new ComplianceClient({
|
|
32
|
+
apiGatewayURL: 'https://api.yourplatform.com',
|
|
33
|
+
tenantId: 'your-casino-id',
|
|
34
|
+
apiKey: 'your-api-key',
|
|
35
|
+
autoCreateProfiles: true
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Verify registration with automatic profile creation
|
|
39
|
+
const result = await sdk.verifyAtRegistration({
|
|
40
|
+
customerId: 'CUST-12345',
|
|
41
|
+
fullName: 'John Doe',
|
|
42
|
+
emailAddress: 'john@example.com',
|
|
43
|
+
ipAddress: req.ip,
|
|
44
|
+
deviceFingerprint: {
|
|
45
|
+
device_id: deviceId,
|
|
46
|
+
user_agent: req.headers['user-agent'],
|
|
47
|
+
platform: 'web'
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (result.allowed) {
|
|
52
|
+
// Registration approved
|
|
53
|
+
console.log('Customer profile created:', result.profile);
|
|
54
|
+
console.log('Risk score:', result.profile.risk_score);
|
|
55
|
+
|
|
56
|
+
if (result.requiresKYC) {
|
|
57
|
+
// Redirect to KYC flow
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
// Registration blocked
|
|
61
|
+
console.log('Blocked reasons:', result.blockReasons);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Login Verification
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const loginResult = await sdk.verifyAtLogin({
|
|
69
|
+
customerId: 'CUST-12345',
|
|
70
|
+
ipAddress: req.ip,
|
|
71
|
+
deviceFingerprint: getDeviceFingerprint()
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (loginResult.allowed) {
|
|
75
|
+
// Allow login
|
|
76
|
+
if (loginResult.requiresStepUp) {
|
|
77
|
+
// Trigger additional verification (MFA, etc.)
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
// Block login
|
|
81
|
+
console.log('Blocked:', loginResult.blockReasons);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Transaction Verification
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const txResult = await sdk.verifyAtTransaction({
|
|
89
|
+
customerId: 'CUST-12345',
|
|
90
|
+
ipAddress: req.ip,
|
|
91
|
+
amount: 5000,
|
|
92
|
+
currency: 'USD',
|
|
93
|
+
transactionType: 'withdrawal',
|
|
94
|
+
deviceFingerprint: getDeviceFingerprint()
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (txResult.allowed) {
|
|
98
|
+
// Process transaction
|
|
99
|
+
} else if (txResult.requiresApproval) {
|
|
100
|
+
// Queue for manual review
|
|
101
|
+
} else {
|
|
102
|
+
// Block transaction
|
|
103
|
+
console.log('Blocked:', txResult.blockReasons);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Module-Specific Imports
|
|
108
|
+
|
|
109
|
+
### Geolocation Only
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { GeolocationClient } from 'cgs-compliance-sdk/geolocation';
|
|
113
|
+
|
|
114
|
+
const geoClient = new GeolocationClient({
|
|
115
|
+
baseURL: 'https://api.yourplatform.com',
|
|
116
|
+
tenantId: 'your-casino-id',
|
|
117
|
+
apiKey: 'your-api-key'
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const verification = await geoClient.verifyIP({
|
|
121
|
+
ip_address: '8.8.8.8',
|
|
122
|
+
user_id: 'user-123',
|
|
123
|
+
event_type: 'login'
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Risk Profile Only
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { RiskProfileClient } from 'cgs-compliance-sdk/risk-profile';
|
|
131
|
+
|
|
132
|
+
const riskClient = new RiskProfileClient({
|
|
133
|
+
baseURL: 'https://api.yourplatform.com',
|
|
134
|
+
tenantId: 'your-casino-id',
|
|
135
|
+
apiKey: 'your-api-key'
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const profile = await riskClient.getProfile('CUST-12345');
|
|
139
|
+
console.log('Risk category:', profile.risk_category);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## React Hooks
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { useRegistration, useCustomerProfile } from 'cgs-compliance-sdk';
|
|
146
|
+
|
|
147
|
+
function RegistrationForm() {
|
|
148
|
+
const { verifyRegistration, loading, error } = useRegistration(sdk, {
|
|
149
|
+
onSuccess: (result) => {
|
|
150
|
+
console.log('Registration approved!', result.profile);
|
|
151
|
+
navigate('/dashboard');
|
|
152
|
+
},
|
|
153
|
+
onBlocked: (result) => {
|
|
154
|
+
alert(`Registration blocked: ${result.blockReasons.join(', ')}`);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const handleSubmit = async (formData) => {
|
|
159
|
+
await verifyRegistration({
|
|
160
|
+
customerId: formData.customerId,
|
|
161
|
+
fullName: formData.fullName,
|
|
162
|
+
emailAddress: formData.email,
|
|
163
|
+
ipAddress: await getClientIP(),
|
|
164
|
+
deviceFingerprint: getDeviceFingerprint()
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<form onSubmit={handleSubmit}>
|
|
170
|
+
{/* Your form fields */}
|
|
171
|
+
<button disabled={loading}>
|
|
172
|
+
{loading ? 'Verifying...' : 'Register'}
|
|
173
|
+
</button>
|
|
174
|
+
{error && <ErrorMessage>{error.message}</ErrorMessage>}
|
|
175
|
+
</form>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## API Documentation
|
|
181
|
+
|
|
182
|
+
### ComplianceClient
|
|
183
|
+
|
|
184
|
+
Main orchestration client that combines geolocation and risk profiling.
|
|
185
|
+
|
|
186
|
+
#### Configuration
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
interface CGSConfig {
|
|
190
|
+
geolocationServiceURL: string;
|
|
191
|
+
riskProfileServiceURL: string;
|
|
192
|
+
tenantId: string;
|
|
193
|
+
apiKey?: string;
|
|
194
|
+
timeout?: number;
|
|
195
|
+
retries?: number;
|
|
196
|
+
debug?: boolean;
|
|
197
|
+
autoCreateProfiles?: boolean;
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### Methods
|
|
202
|
+
|
|
203
|
+
- `verifyAtRegistration(request)` - Complete registration verification with profile creation
|
|
204
|
+
- `verifyAtLogin(request)` - Login verification with profile update
|
|
205
|
+
- `verifyAtTransaction(request)` - Transaction verification with amount-based risk
|
|
206
|
+
- `verifyEvent(request)` - Generic event verification
|
|
207
|
+
|
|
208
|
+
### GeolocationClient
|
|
209
|
+
|
|
210
|
+
IP verification, jurisdiction checks, and device fingerprinting.
|
|
211
|
+
|
|
212
|
+
See [Geolocation SDK Documentation](./docs/geolocation.md) for details.
|
|
213
|
+
|
|
214
|
+
### RiskProfileClient
|
|
215
|
+
|
|
216
|
+
Customer risk profile management.
|
|
217
|
+
|
|
218
|
+
See [Risk Profile SDK Documentation](./docs/risk-profile.md) for details.
|
|
219
|
+
|
|
220
|
+
## Migration from @cgs/geolocation-sdk
|
|
221
|
+
|
|
222
|
+
The unified SDK is fully backward compatible. See [Migration Guide](./MIGRATION.md) for details.
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
// Before (@cgs/geolocation-sdk v1.x)
|
|
226
|
+
import { GeolocationClient } from '@cgs/geolocation-sdk';
|
|
227
|
+
|
|
228
|
+
// After (cgs-compliance-sdk v2.x) - Same API
|
|
229
|
+
import { GeolocationClient } from 'cgs-compliance-sdk/geolocation';
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Examples
|
|
233
|
+
|
|
234
|
+
- [Registration Flow](./examples/registration-flow.tsx)
|
|
235
|
+
- [Login Flow](./examples/login-flow.tsx)
|
|
236
|
+
- [Transaction Verification](./examples/transaction-flow.tsx)
|
|
237
|
+
- [Next.js Integration](./examples/next-js-casino/)
|
|
238
|
+
|
|
239
|
+
## Architecture Overview
|
|
240
|
+
|
|
241
|
+
### API Gateway Pattern
|
|
242
|
+
|
|
243
|
+
**IMPORTANT**: All SDK requests go through the API Gateway. Direct access to individual services is not permitted for third parties.
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
Casino Platform → CGS SDK → API Gateway → Backend Services
|
|
247
|
+
↓
|
|
248
|
+
┌───────────┴───────────┐
|
|
249
|
+
↓ ↓
|
|
250
|
+
Geolocation Service Risk Profile Service
|
|
251
|
+
↓ ↓
|
|
252
|
+
Kafka Event Bus
|
|
253
|
+
↓
|
|
254
|
+
┌───────────┼───────────┬───────────┐
|
|
255
|
+
↓ ↓ ↓ ↓
|
|
256
|
+
KYC Service AML Service Fraud Service Analytics
|
|
257
|
+
↓ ↓ ↓
|
|
258
|
+
All publish events consumed by Risk Profile Service
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Event-Driven Profile Updates
|
|
262
|
+
|
|
263
|
+
Customer risk profiles are automatically updated via Kafka events from all compliance services:
|
|
264
|
+
|
|
265
|
+
**Geolocation Events** → Updates location, compliance status, geo risk factor
|
|
266
|
+
**KYC Events** → Updates KYC status, identity verification, KYC risk factor
|
|
267
|
+
**AML Events** → Updates watchlist matches, PEP status, sanctions, AML risk factor
|
|
268
|
+
**Fraud Events** → Updates flagged transactions, fraud risk factor
|
|
269
|
+
|
|
270
|
+
This ensures customer profiles always reflect the latest compliance data from all sources.
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
MIT
|
|
275
|
+
|
|
276
|
+
## Support
|
|
277
|
+
|
|
278
|
+
For issues and questions, please visit [GitHub Issues](https://github.com/botcalm-compliance/cgs-server/issues)
|