g-ten-security-sdk 1.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/dist/auth/authenticate.d.ts +30 -0
- package/dist/auth/authenticate.js +52 -0
- package/dist/auth/interceptor.d.ts +13 -0
- package/dist/auth/interceptor.js +74 -0
- package/dist/auth/tokenStore.d.ts +17 -0
- package/dist/auth/tokenStore.js +36 -0
- package/dist/client.d.ts +109 -0
- package/dist/client.js +157 -0
- package/dist/generated/src/apis/AuthApi.d.ts +139 -0
- package/dist/generated/src/apis/AuthApi.js +429 -0
- package/dist/generated/src/apis/BranchesApi.d.ts +77 -0
- package/dist/generated/src/apis/BranchesApi.js +228 -0
- package/dist/generated/src/apis/ChatApi.d.ts +34 -0
- package/dist/generated/src/apis/ChatApi.js +92 -0
- package/dist/generated/src/apis/DataApi.d.ts +112 -0
- package/dist/generated/src/apis/DataApi.js +297 -0
- package/dist/generated/src/apis/DefaultApi.d.ts +109 -0
- package/dist/generated/src/apis/DefaultApi.js +306 -0
- package/dist/generated/src/apis/DemoApi.d.ts +46 -0
- package/dist/generated/src/apis/DemoApi.js +129 -0
- package/dist/generated/src/apis/FraudApi.d.ts +311 -0
- package/dist/generated/src/apis/FraudApi.js +809 -0
- package/dist/generated/src/apis/HealthApi.d.ts +31 -0
- package/dist/generated/src/apis/HealthApi.js +92 -0
- package/dist/generated/src/apis/SchemaApi.d.ts +31 -0
- package/dist/generated/src/apis/SchemaApi.js +92 -0
- package/dist/generated/src/apis/WorkflowApi.d.ts +94 -0
- package/dist/generated/src/apis/WorkflowApi.js +269 -0
- package/dist/generated/src/apis/index.d.ts +10 -0
- package/dist/generated/src/apis/index.js +28 -0
- package/dist/generated/src/index.d.ts +3 -0
- package/dist/generated/src/index.js +21 -0
- package/dist/generated/src/models/Account.d.ts +122 -0
- package/dist/generated/src/models/Account.js +92 -0
- package/dist/generated/src/models/AlertStatusUpdate.d.ts +32 -0
- package/dist/generated/src/models/AlertStatusUpdate.js +50 -0
- package/dist/generated/src/models/AssignRequest.d.ts +32 -0
- package/dist/generated/src/models/AssignRequest.js +48 -0
- package/dist/generated/src/models/BranchCreate.d.ts +44 -0
- package/dist/generated/src/models/BranchCreate.js +56 -0
- package/dist/generated/src/models/BranchUpdate.d.ts +38 -0
- package/dist/generated/src/models/BranchUpdate.js +50 -0
- package/dist/generated/src/models/ChatRequest.d.ts +39 -0
- package/dist/generated/src/models/ChatRequest.js +53 -0
- package/dist/generated/src/models/ChatResponse.d.ts +32 -0
- package/dist/generated/src/models/ChatResponse.js +50 -0
- package/dist/generated/src/models/HTTPValidationError.d.ts +33 -0
- package/dist/generated/src/models/HTTPValidationError.js +49 -0
- package/dist/generated/src/models/HistoryTurn.d.ts +38 -0
- package/dist/generated/src/models/HistoryTurn.js +54 -0
- package/dist/generated/src/models/InjectPatternRequest.d.ts +32 -0
- package/dist/generated/src/models/InjectPatternRequest.js +50 -0
- package/dist/generated/src/models/LocationInner.d.ts +26 -0
- package/dist/generated/src/models/LocationInner.js +38 -0
- package/dist/generated/src/models/NarrativeRequest.d.ts +44 -0
- package/dist/generated/src/models/NarrativeRequest.js +52 -0
- package/dist/generated/src/models/NoteCreate.d.ts +38 -0
- package/dist/generated/src/models/NoteCreate.js +52 -0
- package/dist/generated/src/models/PasswordUpdate.d.ts +32 -0
- package/dist/generated/src/models/PasswordUpdate.js +50 -0
- package/dist/generated/src/models/StreamConfigRequest.d.ts +32 -0
- package/dist/generated/src/models/StreamConfigRequest.js +50 -0
- package/dist/generated/src/models/Token.d.ts +46 -0
- package/dist/generated/src/models/Token.js +58 -0
- package/dist/generated/src/models/Transaction.d.ts +74 -0
- package/dist/generated/src/models/Transaction.js +78 -0
- package/dist/generated/src/models/UserCreate.d.ts +56 -0
- package/dist/generated/src/models/UserCreate.js +62 -0
- package/dist/generated/src/models/UserOut.d.ts +62 -0
- package/dist/generated/src/models/UserOut.js +66 -0
- package/dist/generated/src/models/ValidationError.d.ts +57 -0
- package/dist/generated/src/models/ValidationError.js +63 -0
- package/dist/generated/src/models/index.d.ts +20 -0
- package/dist/generated/src/models/index.js +38 -0
- package/dist/generated/src/runtime.d.ts +184 -0
- package/dist/generated/src/runtime.js +353 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +40 -0
- package/dist/types/index.d.ts +85 -0
- package/dist/types/index.js +5 -0
- package/dist/utils/errors.d.ts +33 -0
- package/dist/utils/errors.js +52 -0
- package/dist/utils/validators.d.ts +10 -0
- package/dist/utils/validators.js +26 -0
- package/dist/wrappers/alerts.d.ts +29 -0
- package/dist/wrappers/alerts.js +52 -0
- package/dist/wrappers/analytics.d.ts +8 -0
- package/dist/wrappers/analytics.js +15 -0
- package/dist/wrappers/copilot.d.ts +8 -0
- package/dist/wrappers/copilot.js +20 -0
- package/dist/wrappers/data.d.ts +55 -0
- package/dist/wrappers/data.js +127 -0
- package/dist/wrappers/fraud.d.ts +46 -0
- package/dist/wrappers/fraud.js +84 -0
- package/dist/wrappers/investigation.d.ts +31 -0
- package/dist/wrappers/investigation.js +77 -0
- package/package.json +18 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* G-TEN SDK — Authentication
|
|
3
|
+
*
|
|
4
|
+
* Provides the one-time `authenticate()` function.
|
|
5
|
+
* After calling this, all subsequent SDK calls are automatically authenticated.
|
|
6
|
+
* This module is the ONLY auth surface exported from the SDK.
|
|
7
|
+
*/
|
|
8
|
+
import { AuthResult } from "../types";
|
|
9
|
+
/**
|
|
10
|
+
* Authenticates the SDK against the G-TEN platform.
|
|
11
|
+
*
|
|
12
|
+
* Call this once before using any protected SDK function.
|
|
13
|
+
* The access token is stored internally and automatically attached
|
|
14
|
+
* to all subsequent requests — you never need to manage it manually.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* await authenticate({ apiKey: "key", clientId: "id" });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function authenticate(credentials: {
|
|
22
|
+
apiKey: string;
|
|
23
|
+
clientId: string;
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
}): Promise<AuthResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Signs out and clears the stored access token.
|
|
28
|
+
* After calling this, protected API calls will throw an auth error.
|
|
29
|
+
*/
|
|
30
|
+
export declare function signOut(): void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* G-TEN SDK — Authentication
|
|
4
|
+
*
|
|
5
|
+
* Provides the one-time `authenticate()` function.
|
|
6
|
+
* After calling this, all subsequent SDK calls are automatically authenticated.
|
|
7
|
+
* This module is the ONLY auth surface exported from the SDK.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.authenticate = authenticate;
|
|
11
|
+
exports.signOut = signOut;
|
|
12
|
+
const tokenStore_1 = require("./tokenStore");
|
|
13
|
+
const interceptor_1 = require("./interceptor");
|
|
14
|
+
/**
|
|
15
|
+
* Authenticates the SDK against the G-TEN platform.
|
|
16
|
+
*
|
|
17
|
+
* Call this once before using any protected SDK function.
|
|
18
|
+
* The access token is stored internally and automatically attached
|
|
19
|
+
* to all subsequent requests — you never need to manage it manually.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* await authenticate({ apiKey: "key", clientId: "id" });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
async function authenticate(credentials) {
|
|
27
|
+
if (credentials.baseUrl) {
|
|
28
|
+
(0, tokenStore_1.setBaseUrl)(credentials.baseUrl);
|
|
29
|
+
}
|
|
30
|
+
const response = await (0, interceptor_1.sdkFetch)("/sdk/v1/auth/login", {
|
|
31
|
+
method: "POST",
|
|
32
|
+
body: JSON.stringify({
|
|
33
|
+
apiKey: credentials.apiKey,
|
|
34
|
+
clientId: credentials.clientId
|
|
35
|
+
}),
|
|
36
|
+
public: true // Do not require existing token
|
|
37
|
+
});
|
|
38
|
+
// Store the token internally — the caller never sees or manages it
|
|
39
|
+
(0, tokenStore_1.setToken)(response.access_token);
|
|
40
|
+
return {
|
|
41
|
+
username: credentials.clientId,
|
|
42
|
+
role: "sdk_client",
|
|
43
|
+
authenticated: true,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Signs out and clears the stored access token.
|
|
48
|
+
* After calling this, protected API calls will throw an auth error.
|
|
49
|
+
*/
|
|
50
|
+
function signOut() {
|
|
51
|
+
(0, tokenStore_1.clearToken)();
|
|
52
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* G-TEN SDK — Request Interceptor
|
|
3
|
+
*
|
|
4
|
+
* Injects the Bearer token into every authenticated request.
|
|
5
|
+
* This module is PRIVATE and never exported from the public SDK interface.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* An internal fetch wrapper that automatically appends the Bearer token
|
|
9
|
+
* and handles common HTTP errors with developer-friendly messages.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function sdkFetch<T = any>(endpoint: string, options?: any): Promise<T>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* G-TEN SDK — Request Interceptor
|
|
4
|
+
*
|
|
5
|
+
* Injects the Bearer token into every authenticated request.
|
|
6
|
+
* This module is PRIVATE and never exported from the public SDK interface.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.sdkFetch = sdkFetch;
|
|
10
|
+
const tokenStore_1 = require("./tokenStore");
|
|
11
|
+
const errors_1 = require("../utils/errors");
|
|
12
|
+
// Use global fetch (available in modern Node.js 18+ and all browsers)
|
|
13
|
+
const _fetch = typeof globalThis !== "undefined" && globalThis.fetch
|
|
14
|
+
? globalThis.fetch.bind(globalThis)
|
|
15
|
+
: undefined;
|
|
16
|
+
/**
|
|
17
|
+
* An internal fetch wrapper that automatically appends the Bearer token
|
|
18
|
+
* and handles common HTTP errors with developer-friendly messages.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
async function sdkFetch(endpoint, options = {}) {
|
|
23
|
+
const token = (0, tokenStore_1.getToken)();
|
|
24
|
+
if (!token && !options.public) {
|
|
25
|
+
throw new errors_1.GTenAuthError("SDK is not authenticated. Call sdk.authenticate() before using protected APIs.");
|
|
26
|
+
}
|
|
27
|
+
if (!_fetch) {
|
|
28
|
+
throw new errors_1.GTenNetworkError("No fetch implementation found. Ensure you are running in a modern browser or Node.js 18+.");
|
|
29
|
+
}
|
|
30
|
+
const baseUrl = (0, tokenStore_1.getBaseUrl)();
|
|
31
|
+
const url = `${baseUrl}${endpoint}`;
|
|
32
|
+
const headers = {
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
...options.headers,
|
|
35
|
+
};
|
|
36
|
+
if (token) {
|
|
37
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
38
|
+
}
|
|
39
|
+
// Extract only the standard fetch options (method, headers, body) to avoid
|
|
40
|
+
// passing custom properties like `public` to the fetch API
|
|
41
|
+
const fetchOptions = {
|
|
42
|
+
method: options.method || "GET",
|
|
43
|
+
headers,
|
|
44
|
+
};
|
|
45
|
+
if (options.body) {
|
|
46
|
+
fetchOptions.body = options.body;
|
|
47
|
+
}
|
|
48
|
+
let response;
|
|
49
|
+
try {
|
|
50
|
+
response = await _fetch(url, fetchOptions);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
// Network-level failures: DNS, connection refused, timeout, etc.
|
|
54
|
+
throw new errors_1.GTenNetworkError(`Failed to connect to G-TEN API at ${baseUrl}. Please check your network connection and baseUrl configuration.`, err);
|
|
55
|
+
}
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
let errorDetail;
|
|
58
|
+
try {
|
|
59
|
+
const errorData = await response.json();
|
|
60
|
+
errorDetail = typeof errorData === "object" && errorData.detail
|
|
61
|
+
? String(errorData.detail)
|
|
62
|
+
: JSON.stringify(errorData);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
errorDetail = await response.text();
|
|
66
|
+
}
|
|
67
|
+
// Map common status codes to friendlier messages
|
|
68
|
+
if (response.status === 401) {
|
|
69
|
+
throw new errors_1.GTenAuthError(`Authentication failed: ${errorDetail}`);
|
|
70
|
+
}
|
|
71
|
+
throw new errors_1.GTenApiError(response.status, errorDetail);
|
|
72
|
+
}
|
|
73
|
+
return await response.json();
|
|
74
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* G-TEN SDK — Internal Token Store
|
|
3
|
+
*
|
|
4
|
+
* Holds the JWT access token in-memory for the current session.
|
|
5
|
+
* This module is PRIVATE and never exported from the public SDK interface.
|
|
6
|
+
* The token is never written to disk, localStorage, or any persistent medium.
|
|
7
|
+
*/
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare function setToken(token: string): void;
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare function getToken(): string | null;
|
|
12
|
+
/** @internal */
|
|
13
|
+
export declare function clearToken(): void;
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare function setBaseUrl(url: string): void;
|
|
16
|
+
/** @internal */
|
|
17
|
+
export declare function getBaseUrl(): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* G-TEN SDK — Internal Token Store
|
|
4
|
+
*
|
|
5
|
+
* Holds the JWT access token in-memory for the current session.
|
|
6
|
+
* This module is PRIVATE and never exported from the public SDK interface.
|
|
7
|
+
* The token is never written to disk, localStorage, or any persistent medium.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.setToken = setToken;
|
|
11
|
+
exports.getToken = getToken;
|
|
12
|
+
exports.clearToken = clearToken;
|
|
13
|
+
exports.setBaseUrl = setBaseUrl;
|
|
14
|
+
exports.getBaseUrl = getBaseUrl;
|
|
15
|
+
let _accessToken = null;
|
|
16
|
+
let _baseUrl = "http://localhost:8000";
|
|
17
|
+
/** @internal */
|
|
18
|
+
function setToken(token) {
|
|
19
|
+
_accessToken = token;
|
|
20
|
+
}
|
|
21
|
+
/** @internal */
|
|
22
|
+
function getToken() {
|
|
23
|
+
return _accessToken;
|
|
24
|
+
}
|
|
25
|
+
/** @internal */
|
|
26
|
+
function clearToken() {
|
|
27
|
+
_accessToken = null;
|
|
28
|
+
}
|
|
29
|
+
/** @internal */
|
|
30
|
+
function setBaseUrl(url) {
|
|
31
|
+
_baseUrl = url;
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
function getBaseUrl() {
|
|
35
|
+
return _baseUrl;
|
|
36
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* G-TEN SDK — Main Client Class
|
|
3
|
+
*
|
|
4
|
+
* The primary entry point for external developers integrating with the G-TEN platform.
|
|
5
|
+
* Provides a clean, class-based interface that hides all HTTP, auth, and internal details.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { GTenSDK } from "@gten/sdk";
|
|
10
|
+
*
|
|
11
|
+
* const sdk = new GTenSDK({ apiKey: "...", clientId: "..." });
|
|
12
|
+
* await sdk.authenticate();
|
|
13
|
+
*
|
|
14
|
+
* const alerts = await sdk.listAlerts();
|
|
15
|
+
* const score = await sdk.getRiskScore("ACC001");
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import type { GTenSDKConfig, AuthResult, NarrativeRequest, RiskScoreResult, TraceResult, AlertsResponse, Alert, StatsResponse } from "./types";
|
|
19
|
+
export declare class GTenSDK {
|
|
20
|
+
private readonly config;
|
|
21
|
+
/**
|
|
22
|
+
* Create a new GTenSDK instance.
|
|
23
|
+
*
|
|
24
|
+
* @param config SDK configuration containing apiKey, clientId, and optional baseUrl
|
|
25
|
+
*/
|
|
26
|
+
constructor(config: GTenSDKConfig);
|
|
27
|
+
/**
|
|
28
|
+
* Authenticate the SDK with the G-TEN platform.
|
|
29
|
+
* Must be called once before using any other SDK method.
|
|
30
|
+
* The access token is stored internally and automatically attached to all future requests.
|
|
31
|
+
*/
|
|
32
|
+
authenticate(): Promise<AuthResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Sign out and clear the stored access token.
|
|
35
|
+
* After calling this, all protected methods will throw until `authenticate()` is called again.
|
|
36
|
+
*/
|
|
37
|
+
signOut(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Run a full fraud analysis on an account.
|
|
40
|
+
* Executes the ML scoring pipeline and returns a comprehensive risk assessment.
|
|
41
|
+
*
|
|
42
|
+
* @param accountId The account identifier to analyze
|
|
43
|
+
*/
|
|
44
|
+
analyzeTransaction(accountId: string): Promise<RiskScoreResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the risk score for a specific account.
|
|
47
|
+
*
|
|
48
|
+
* @param accountId The account identifier
|
|
49
|
+
*/
|
|
50
|
+
getRiskScore(accountId: string): Promise<RiskScoreResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Run fraud detection on a specific account.
|
|
53
|
+
* Detects patterns like layering, smurfing, dormancy, and KYC mismatch.
|
|
54
|
+
*
|
|
55
|
+
* @param accountId The account identifier
|
|
56
|
+
*/
|
|
57
|
+
detectFraud(accountId: string): Promise<RiskScoreResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Trace the flow of funds from/to a specific account.
|
|
60
|
+
* Reveals layering chains, round-trip transfers, and connected entities.
|
|
61
|
+
*
|
|
62
|
+
* @param accountId The account identifier
|
|
63
|
+
* @param hint Optional hint to focus tracing (e.g. "layering", "round_trip")
|
|
64
|
+
*/
|
|
65
|
+
trackFunds(accountId: string, hint?: string): Promise<TraceResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Generate an AI-powered narrative commentary / investigation briefing.
|
|
68
|
+
*
|
|
69
|
+
* @param accountId The account identifier
|
|
70
|
+
* @param request Optional parameters to focus the narrative
|
|
71
|
+
*/
|
|
72
|
+
generateCommentary(accountId: string, request?: NarrativeRequest): Promise<any>;
|
|
73
|
+
/**
|
|
74
|
+
* Retrieve a paginated list of active alerts.
|
|
75
|
+
*
|
|
76
|
+
* @param limit Maximum number of alerts to return (default: 200)
|
|
77
|
+
*/
|
|
78
|
+
listAlerts(limit?: number): Promise<AlertsResponse>;
|
|
79
|
+
/**
|
|
80
|
+
* Retrieve a paginated list of active alerts.
|
|
81
|
+
* Alias for `listAlerts()`.
|
|
82
|
+
*
|
|
83
|
+
* @param limit Maximum number of alerts to return (default: 200)
|
|
84
|
+
*/
|
|
85
|
+
getAlerts(limit?: number): Promise<AlertsResponse>;
|
|
86
|
+
/**
|
|
87
|
+
* Retrieve details for a specific alert by ID.
|
|
88
|
+
*
|
|
89
|
+
* @param alertId The alert identifier
|
|
90
|
+
*/
|
|
91
|
+
getAlert(alertId: string): Promise<Alert>;
|
|
92
|
+
/**
|
|
93
|
+
* Create a custom alert.
|
|
94
|
+
*
|
|
95
|
+
* @param payload Alert creation details
|
|
96
|
+
*/
|
|
97
|
+
createAlert(payload: any): Promise<any>;
|
|
98
|
+
/**
|
|
99
|
+
* Retrieve platform-wide statistics and metrics.
|
|
100
|
+
*/
|
|
101
|
+
getStats(): Promise<StatsResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Send a natural-language message to the G-TEN Copilot AI assistant.
|
|
104
|
+
*
|
|
105
|
+
* @param message The natural language query
|
|
106
|
+
* @returns The AI-generated response text
|
|
107
|
+
*/
|
|
108
|
+
chat(message: string): Promise<string>;
|
|
109
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* G-TEN SDK — Main Client Class
|
|
4
|
+
*
|
|
5
|
+
* The primary entry point for external developers integrating with the G-TEN platform.
|
|
6
|
+
* Provides a clean, class-based interface that hides all HTTP, auth, and internal details.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { GTenSDK } from "@gten/sdk";
|
|
11
|
+
*
|
|
12
|
+
* const sdk = new GTenSDK({ apiKey: "...", clientId: "..." });
|
|
13
|
+
* await sdk.authenticate();
|
|
14
|
+
*
|
|
15
|
+
* const alerts = await sdk.listAlerts();
|
|
16
|
+
* const score = await sdk.getRiskScore("ACC001");
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.GTenSDK = void 0;
|
|
21
|
+
const tokenStore_1 = require("./auth/tokenStore");
|
|
22
|
+
const authenticate_1 = require("./auth/authenticate");
|
|
23
|
+
const fraud_1 = require("./wrappers/fraud");
|
|
24
|
+
const alerts_1 = require("./wrappers/alerts");
|
|
25
|
+
const analytics_1 = require("./wrappers/analytics");
|
|
26
|
+
const copilot_1 = require("./wrappers/copilot");
|
|
27
|
+
class GTenSDK {
|
|
28
|
+
/**
|
|
29
|
+
* Create a new GTenSDK instance.
|
|
30
|
+
*
|
|
31
|
+
* @param config SDK configuration containing apiKey, clientId, and optional baseUrl
|
|
32
|
+
*/
|
|
33
|
+
constructor(config) {
|
|
34
|
+
this.config = config;
|
|
35
|
+
if (config.baseUrl) {
|
|
36
|
+
(0, tokenStore_1.setBaseUrl)(config.baseUrl);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// ── Authentication ────────────────────────────────────────────────────────
|
|
40
|
+
/**
|
|
41
|
+
* Authenticate the SDK with the G-TEN platform.
|
|
42
|
+
* Must be called once before using any other SDK method.
|
|
43
|
+
* The access token is stored internally and automatically attached to all future requests.
|
|
44
|
+
*/
|
|
45
|
+
async authenticate() {
|
|
46
|
+
return (0, authenticate_1.authenticate)({
|
|
47
|
+
apiKey: this.config.apiKey,
|
|
48
|
+
clientId: this.config.clientId,
|
|
49
|
+
baseUrl: this.config.baseUrl,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sign out and clear the stored access token.
|
|
54
|
+
* After calling this, all protected methods will throw until `authenticate()` is called again.
|
|
55
|
+
*/
|
|
56
|
+
signOut() {
|
|
57
|
+
(0, authenticate_1.signOut)();
|
|
58
|
+
}
|
|
59
|
+
// ── Fraud Analysis ────────────────────────────────────────────────────────
|
|
60
|
+
/**
|
|
61
|
+
* Run a full fraud analysis on an account.
|
|
62
|
+
* Executes the ML scoring pipeline and returns a comprehensive risk assessment.
|
|
63
|
+
*
|
|
64
|
+
* @param accountId The account identifier to analyze
|
|
65
|
+
*/
|
|
66
|
+
async analyzeTransaction(accountId) {
|
|
67
|
+
return (0, fraud_1.analyzeTransaction)(accountId);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the risk score for a specific account.
|
|
71
|
+
*
|
|
72
|
+
* @param accountId The account identifier
|
|
73
|
+
*/
|
|
74
|
+
async getRiskScore(accountId) {
|
|
75
|
+
return (0, fraud_1.getRiskScore)(accountId);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Run fraud detection on a specific account.
|
|
79
|
+
* Detects patterns like layering, smurfing, dormancy, and KYC mismatch.
|
|
80
|
+
*
|
|
81
|
+
* @param accountId The account identifier
|
|
82
|
+
*/
|
|
83
|
+
async detectFraud(accountId) {
|
|
84
|
+
return (0, fraud_1.detectFraud)(accountId);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Trace the flow of funds from/to a specific account.
|
|
88
|
+
* Reveals layering chains, round-trip transfers, and connected entities.
|
|
89
|
+
*
|
|
90
|
+
* @param accountId The account identifier
|
|
91
|
+
* @param hint Optional hint to focus tracing (e.g. "layering", "round_trip")
|
|
92
|
+
*/
|
|
93
|
+
async trackFunds(accountId, hint) {
|
|
94
|
+
return (0, fraud_1.trackFunds)(accountId, hint);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Generate an AI-powered narrative commentary / investigation briefing.
|
|
98
|
+
*
|
|
99
|
+
* @param accountId The account identifier
|
|
100
|
+
* @param request Optional parameters to focus the narrative
|
|
101
|
+
*/
|
|
102
|
+
async generateCommentary(accountId, request) {
|
|
103
|
+
return (0, fraud_1.generateCommentary)(accountId, request);
|
|
104
|
+
}
|
|
105
|
+
// ── Alerts ─────────────────────────────────────────────────────────────────
|
|
106
|
+
/**
|
|
107
|
+
* Retrieve a paginated list of active alerts.
|
|
108
|
+
*
|
|
109
|
+
* @param limit Maximum number of alerts to return (default: 200)
|
|
110
|
+
*/
|
|
111
|
+
async listAlerts(limit) {
|
|
112
|
+
return (0, alerts_1.listAlerts)(limit);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Retrieve a paginated list of active alerts.
|
|
116
|
+
* Alias for `listAlerts()`.
|
|
117
|
+
*
|
|
118
|
+
* @param limit Maximum number of alerts to return (default: 200)
|
|
119
|
+
*/
|
|
120
|
+
async getAlerts(limit) {
|
|
121
|
+
return (0, alerts_1.getAlerts)(limit);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Retrieve details for a specific alert by ID.
|
|
125
|
+
*
|
|
126
|
+
* @param alertId The alert identifier
|
|
127
|
+
*/
|
|
128
|
+
async getAlert(alertId) {
|
|
129
|
+
return (0, alerts_1.getAlert)(alertId);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Create a custom alert.
|
|
133
|
+
*
|
|
134
|
+
* @param payload Alert creation details
|
|
135
|
+
*/
|
|
136
|
+
async createAlert(payload) {
|
|
137
|
+
return (0, alerts_1.createAlert)(payload);
|
|
138
|
+
}
|
|
139
|
+
// ── Analytics ──────────────────────────────────────────────────────────────
|
|
140
|
+
/**
|
|
141
|
+
* Retrieve platform-wide statistics and metrics.
|
|
142
|
+
*/
|
|
143
|
+
async getStats() {
|
|
144
|
+
return (0, analytics_1.getStats)();
|
|
145
|
+
}
|
|
146
|
+
// ── Copilot ───────────────────────────────────────────────────────────────
|
|
147
|
+
/**
|
|
148
|
+
* Send a natural-language message to the G-TEN Copilot AI assistant.
|
|
149
|
+
*
|
|
150
|
+
* @param message The natural language query
|
|
151
|
+
* @returns The AI-generated response text
|
|
152
|
+
*/
|
|
153
|
+
async chat(message) {
|
|
154
|
+
return (0, copilot_1.chat)(message);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.GTenSDK = GTenSDK;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* G-TEN
|
|
3
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 0.1.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import * as runtime from '../runtime';
|
|
13
|
+
import { type PasswordUpdate } from '../models/PasswordUpdate';
|
|
14
|
+
import { type Token } from '../models/Token';
|
|
15
|
+
import { type UserCreate } from '../models/UserCreate';
|
|
16
|
+
import { type UserOut } from '../models/UserOut';
|
|
17
|
+
export interface CreateUserApiV1AuthUsersPostRequest {
|
|
18
|
+
userCreate: UserCreate;
|
|
19
|
+
}
|
|
20
|
+
export interface DeleteUserApiV1AuthUsersUserIdDeleteRequest {
|
|
21
|
+
userId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface LoginForAccessTokenApiV1AuthLoginPostRequest {
|
|
24
|
+
username: string;
|
|
25
|
+
password: string;
|
|
26
|
+
totpCode?: string;
|
|
27
|
+
grantType?: string | null;
|
|
28
|
+
scope?: string;
|
|
29
|
+
clientId?: string | null;
|
|
30
|
+
clientSecret?: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface UpdateUserPasswordApiV1AuthUsersUserIdPasswordPatchRequest {
|
|
33
|
+
userId: string;
|
|
34
|
+
passwordUpdate: PasswordUpdate;
|
|
35
|
+
}
|
|
36
|
+
export interface Verify2faApiV1Auth2faVerifyPostRequest {
|
|
37
|
+
totpCode: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
export declare class AuthApi extends runtime.BaseAPI {
|
|
43
|
+
/**
|
|
44
|
+
* Creates request options for createUserApiV1AuthUsersPost without sending the request
|
|
45
|
+
*/
|
|
46
|
+
createUserApiV1AuthUsersPostRequestOpts(requestParameters: CreateUserApiV1AuthUsersPostRequest): Promise<runtime.RequestOpts>;
|
|
47
|
+
/**
|
|
48
|
+
* Create User
|
|
49
|
+
*/
|
|
50
|
+
createUserApiV1AuthUsersPostRaw(requestParameters: CreateUserApiV1AuthUsersPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>>;
|
|
51
|
+
/**
|
|
52
|
+
* Create User
|
|
53
|
+
*/
|
|
54
|
+
createUserApiV1AuthUsersPost(requestParameters: CreateUserApiV1AuthUsersPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any>;
|
|
55
|
+
/**
|
|
56
|
+
* Creates request options for deleteUserApiV1AuthUsersUserIdDelete without sending the request
|
|
57
|
+
*/
|
|
58
|
+
deleteUserApiV1AuthUsersUserIdDeleteRequestOpts(requestParameters: DeleteUserApiV1AuthUsersUserIdDeleteRequest): Promise<runtime.RequestOpts>;
|
|
59
|
+
/**
|
|
60
|
+
* Delete User
|
|
61
|
+
*/
|
|
62
|
+
deleteUserApiV1AuthUsersUserIdDeleteRaw(requestParameters: DeleteUserApiV1AuthUsersUserIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>>;
|
|
63
|
+
/**
|
|
64
|
+
* Delete User
|
|
65
|
+
*/
|
|
66
|
+
deleteUserApiV1AuthUsersUserIdDelete(requestParameters: DeleteUserApiV1AuthUsersUserIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any>;
|
|
67
|
+
/**
|
|
68
|
+
* Creates request options for generate2faApiV1Auth2faGeneratePost without sending the request
|
|
69
|
+
*/
|
|
70
|
+
generate2faApiV1Auth2faGeneratePostRequestOpts(): Promise<runtime.RequestOpts>;
|
|
71
|
+
/**
|
|
72
|
+
* Generate 2Fa
|
|
73
|
+
*/
|
|
74
|
+
generate2faApiV1Auth2faGeneratePostRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>>;
|
|
75
|
+
/**
|
|
76
|
+
* Generate 2Fa
|
|
77
|
+
*/
|
|
78
|
+
generate2faApiV1Auth2faGeneratePost(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any>;
|
|
79
|
+
/**
|
|
80
|
+
* Creates request options for getInvestigatorsApiV1AuthUsersInvestigatorsGet without sending the request
|
|
81
|
+
*/
|
|
82
|
+
getInvestigatorsApiV1AuthUsersInvestigatorsGetRequestOpts(): Promise<runtime.RequestOpts>;
|
|
83
|
+
/**
|
|
84
|
+
* Get Investigators
|
|
85
|
+
*/
|
|
86
|
+
getInvestigatorsApiV1AuthUsersInvestigatorsGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>>;
|
|
87
|
+
/**
|
|
88
|
+
* Get Investigators
|
|
89
|
+
*/
|
|
90
|
+
getInvestigatorsApiV1AuthUsersInvestigatorsGet(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any>;
|
|
91
|
+
/**
|
|
92
|
+
* Creates request options for loginForAccessTokenApiV1AuthLoginPost without sending the request
|
|
93
|
+
*/
|
|
94
|
+
loginForAccessTokenApiV1AuthLoginPostRequestOpts(requestParameters: LoginForAccessTokenApiV1AuthLoginPostRequest): Promise<runtime.RequestOpts>;
|
|
95
|
+
/**
|
|
96
|
+
* Login For Access Token
|
|
97
|
+
*/
|
|
98
|
+
loginForAccessTokenApiV1AuthLoginPostRaw(requestParameters: LoginForAccessTokenApiV1AuthLoginPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Token>>;
|
|
99
|
+
/**
|
|
100
|
+
* Login For Access Token
|
|
101
|
+
*/
|
|
102
|
+
loginForAccessTokenApiV1AuthLoginPost(requestParameters: LoginForAccessTokenApiV1AuthLoginPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Token>;
|
|
103
|
+
/**
|
|
104
|
+
* Creates request options for readUsersMeApiV1AuthMeGet without sending the request
|
|
105
|
+
*/
|
|
106
|
+
readUsersMeApiV1AuthMeGetRequestOpts(): Promise<runtime.RequestOpts>;
|
|
107
|
+
/**
|
|
108
|
+
* Read Users Me
|
|
109
|
+
*/
|
|
110
|
+
readUsersMeApiV1AuthMeGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserOut>>;
|
|
111
|
+
/**
|
|
112
|
+
* Read Users Me
|
|
113
|
+
*/
|
|
114
|
+
readUsersMeApiV1AuthMeGet(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserOut>;
|
|
115
|
+
/**
|
|
116
|
+
* Creates request options for updateUserPasswordApiV1AuthUsersUserIdPasswordPatch without sending the request
|
|
117
|
+
*/
|
|
118
|
+
updateUserPasswordApiV1AuthUsersUserIdPasswordPatchRequestOpts(requestParameters: UpdateUserPasswordApiV1AuthUsersUserIdPasswordPatchRequest): Promise<runtime.RequestOpts>;
|
|
119
|
+
/**
|
|
120
|
+
* Update User Password
|
|
121
|
+
*/
|
|
122
|
+
updateUserPasswordApiV1AuthUsersUserIdPasswordPatchRaw(requestParameters: UpdateUserPasswordApiV1AuthUsersUserIdPasswordPatchRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>>;
|
|
123
|
+
/**
|
|
124
|
+
* Update User Password
|
|
125
|
+
*/
|
|
126
|
+
updateUserPasswordApiV1AuthUsersUserIdPasswordPatch(requestParameters: UpdateUserPasswordApiV1AuthUsersUserIdPasswordPatchRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any>;
|
|
127
|
+
/**
|
|
128
|
+
* Creates request options for verify2faApiV1Auth2faVerifyPost without sending the request
|
|
129
|
+
*/
|
|
130
|
+
verify2faApiV1Auth2faVerifyPostRequestOpts(requestParameters: Verify2faApiV1Auth2faVerifyPostRequest): Promise<runtime.RequestOpts>;
|
|
131
|
+
/**
|
|
132
|
+
* Verify 2Fa
|
|
133
|
+
*/
|
|
134
|
+
verify2faApiV1Auth2faVerifyPostRaw(requestParameters: Verify2faApiV1Auth2faVerifyPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>>;
|
|
135
|
+
/**
|
|
136
|
+
* Verify 2Fa
|
|
137
|
+
*/
|
|
138
|
+
verify2faApiV1Auth2faVerifyPost(requestParameters: Verify2faApiV1Auth2faVerifyPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any>;
|
|
139
|
+
}
|