@amaster.ai/client 1.1.0-beta.4 → 1.1.0-beta.41
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/index.cjs +84 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +84 -8
- package/dist/index.js.map +1 -1
- package/package.json +15 -11
- package/types/__tests__/type-checks.test-d.ts +163 -0
- package/types/asr.d.ts +10 -114
- package/types/auth/code-auth.d.ts +5 -154
- package/types/auth/index.d.ts +54 -96
- package/types/auth/oauth.d.ts +6 -143
- package/types/auth/password-auth.d.ts +38 -137
- package/types/auth/profile.d.ts +4 -103
- package/types/auth/user.d.ts +8 -32
- package/types/bpm.d.ts +182 -92
- package/types/common.d.ts +52 -44
- package/types/copilot.d.ts +78 -124
- package/types/entity.d.ts +65 -342
- package/types/function.d.ts +11 -88
- package/types/index.d.ts +85 -278
- package/types/s3.d.ts +96 -0
- package/types/tts.d.ts +10 -128
- package/types/workflow.d.ts +16 -165
- package/types/auth/permissions.d.ts +0 -254
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-level tests for @amaster.ai/client
|
|
3
|
+
*
|
|
4
|
+
* These tests verify type inference and type safety at compile time.
|
|
5
|
+
* They ensure that the type definitions work correctly with TypeScript.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expectTypeOf } from 'vitest';
|
|
9
|
+
import type {
|
|
10
|
+
AmasterClient,
|
|
11
|
+
AmasterClientOptions,
|
|
12
|
+
ClientResult,
|
|
13
|
+
ClientError,
|
|
14
|
+
EntityListResponse,
|
|
15
|
+
LoginParams,
|
|
16
|
+
User,
|
|
17
|
+
Task,
|
|
18
|
+
ProcessInstance,
|
|
19
|
+
} from '../index';
|
|
20
|
+
|
|
21
|
+
describe('Type Tests', () => {
|
|
22
|
+
describe('ClientResult', () => {
|
|
23
|
+
it('should have correct structure', () => {
|
|
24
|
+
type Result = ClientResult<{ id: number; name: string }>;
|
|
25
|
+
|
|
26
|
+
expectTypeOf<Result>().toMatchTypeOf<{
|
|
27
|
+
data: { id: number; name: string } | null;
|
|
28
|
+
error: ClientError | null;
|
|
29
|
+
status: number;
|
|
30
|
+
success: boolean;
|
|
31
|
+
}>();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should infer data type correctly', () => {
|
|
35
|
+
type UserResult = ClientResult<User>;
|
|
36
|
+
|
|
37
|
+
expectTypeOf<UserResult['data']>().toEqualTypeOf<User | null>();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should have success field', () => {
|
|
41
|
+
type Result = ClientResult<unknown>;
|
|
42
|
+
|
|
43
|
+
expectTypeOf<Result['success']>().toEqualTypeOf<boolean>();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('ClientError', () => {
|
|
48
|
+
it('should have all required fields', () => {
|
|
49
|
+
expectTypeOf<ClientError>().toMatchTypeOf<{
|
|
50
|
+
status: number;
|
|
51
|
+
message: string;
|
|
52
|
+
code?: string;
|
|
53
|
+
details?: unknown;
|
|
54
|
+
timestamp?: string;
|
|
55
|
+
}>();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('EntityListResponse', () => {
|
|
60
|
+
it('should infer item type correctly', () => {
|
|
61
|
+
type UserListResponse = EntityListResponse<{ id: number; name: string }>;
|
|
62
|
+
|
|
63
|
+
expectTypeOf<UserListResponse['items']>().toEqualTypeOf<Array<{ id: number; name: string }>>();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should have pagination fields', () => {
|
|
67
|
+
type Response = EntityListResponse<unknown>;
|
|
68
|
+
|
|
69
|
+
expectTypeOf<Response>().toMatchTypeOf<{
|
|
70
|
+
items: unknown[];
|
|
71
|
+
total: number;
|
|
72
|
+
page?: number;
|
|
73
|
+
perPage?: number;
|
|
74
|
+
}>();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('AmasterClient', () => {
|
|
79
|
+
it('should have all service modules', () => {
|
|
80
|
+
expectTypeOf<AmasterClient>().toHaveProperty('auth');
|
|
81
|
+
expectTypeOf<AmasterClient>().toHaveProperty('entity');
|
|
82
|
+
expectTypeOf<AmasterClient>().toHaveProperty('bpm');
|
|
83
|
+
expectTypeOf<AmasterClient>().toHaveProperty('workflow');
|
|
84
|
+
expectTypeOf<AmasterClient>().toHaveProperty('asr');
|
|
85
|
+
expectTypeOf<AmasterClient>().toHaveProperty('copilot');
|
|
86
|
+
expectTypeOf<AmasterClient>().toHaveProperty('function');
|
|
87
|
+
expectTypeOf<AmasterClient>().toHaveProperty('tts');
|
|
88
|
+
expectTypeOf<AmasterClient>().toHaveProperty('s3');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should have utility methods', () => {
|
|
92
|
+
expectTypeOf<AmasterClient>().toHaveProperty('isAuthenticated');
|
|
93
|
+
expectTypeOf<AmasterClient>().toHaveProperty('getAccessToken');
|
|
94
|
+
expectTypeOf<AmasterClient>().toHaveProperty('setAccessToken');
|
|
95
|
+
expectTypeOf<AmasterClient>().toHaveProperty('clearAuth');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('LoginParams', () => {
|
|
100
|
+
it('should accept email login', () => {
|
|
101
|
+
const params: LoginParams = {
|
|
102
|
+
email: 'user@example.com',
|
|
103
|
+
password: 'password123'
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
expectTypeOf(params).toMatchTypeOf<LoginParams>();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should accept username login', () => {
|
|
110
|
+
const params: LoginParams = {
|
|
111
|
+
username: 'johndoe',
|
|
112
|
+
password: 'password123'
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
expectTypeOf(params).toMatchTypeOf<LoginParams>();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should accept phone login', () => {
|
|
119
|
+
const params: LoginParams = {
|
|
120
|
+
phone: '+1234567890',
|
|
121
|
+
password: 'password123'
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
expectTypeOf(params).toMatchTypeOf<LoginParams>();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('Generic Type Inference', () => {
|
|
129
|
+
it('should infer entity list result type', () => {
|
|
130
|
+
type User = { id: number; name: string; email: string };
|
|
131
|
+
type Result = ClientResult<EntityListResponse<User>>;
|
|
132
|
+
|
|
133
|
+
// If success, data.items should be User[]
|
|
134
|
+
expectTypeOf<NonNullable<Result['data']>['items']>().toEqualTypeOf<User[]>();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should infer entity get result type', () => {
|
|
138
|
+
type Product = { id: number; title: string; price: number };
|
|
139
|
+
type Result = ClientResult<Product>;
|
|
140
|
+
|
|
141
|
+
expectTypeOf<NonNullable<Result['data']>>().toEqualTypeOf<Product>();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe('BPM Types', () => {
|
|
146
|
+
it('should have correct Task structure', () => {
|
|
147
|
+
expectTypeOf<Task>().toMatchTypeOf<{
|
|
148
|
+
id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
assignee: string | null;
|
|
151
|
+
processInstanceId: string;
|
|
152
|
+
}>();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should have correct ProcessInstance structure', () => {
|
|
156
|
+
expectTypeOf<ProcessInstance>().toMatchTypeOf<{
|
|
157
|
+
id: string;
|
|
158
|
+
definitionId?: string;
|
|
159
|
+
businessKey?: string;
|
|
160
|
+
}>();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
});
|
package/types/asr.d.ts
CHANGED
|
@@ -1,31 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* ASR (Automatic Speech Recognition) - Type Definitions
|
|
4
|
-
* ============================================================================
|
|
5
|
-
*
|
|
6
|
-
* Real-time speech recognition using WebSocket connection.
|
|
2
|
+
* * Real-time speech recognition using WebSocket connection.
|
|
7
3
|
*
|
|
8
4
|
* @module asr
|
|
9
5
|
*/
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* ASR Client Configuration
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* Configure ASR with custom voice settings:
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
18
|
-
*
|
|
19
|
-
* // Reconfigure ASR client
|
|
20
|
-
* client.asr = createASRClient({
|
|
21
|
-
* audioFormat: 'pcm16',
|
|
22
|
-
* sampleRate: 16000,
|
|
23
|
-
* onTranscript: (text, isFinal) => {
|
|
24
|
-
* console.log(isFinal ? `Final: ${text}` : `Interim: ${text}`);
|
|
25
|
-
* },
|
|
26
|
-
* onError: (error) => console.error('ASR Error:', error)
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
9
|
+
*
|
|
29
10
|
*/
|
|
30
11
|
export interface ASRClientConfig {
|
|
31
12
|
/** Audio format, default 'pcm16' */
|
|
@@ -61,78 +42,20 @@ export interface ASRClientConfig {
|
|
|
61
42
|
}
|
|
62
43
|
|
|
63
44
|
/**
|
|
64
|
-
* ASR Client API
|
|
65
|
-
*
|
|
66
|
-
* Real-time speech recognition client using WebSocket.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* Basic usage:
|
|
70
|
-
* ```typescript
|
|
71
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
72
|
-
*
|
|
73
|
-
* // Configure callbacks
|
|
74
|
-
* client.asr = createASRClient({
|
|
75
|
-
* onTranscript: (text, isFinal) => {
|
|
76
|
-
* if (isFinal) {
|
|
77
|
-
* console.log('Final transcript:', text);
|
|
78
|
-
* } else {
|
|
79
|
-
* console.log('Interim transcript:', text);
|
|
80
|
-
* }
|
|
81
|
-
* }
|
|
82
|
-
* });
|
|
83
|
-
*
|
|
84
|
-
* // Connect and start recording
|
|
85
|
-
* await client.asr.connect();
|
|
86
|
-
* await client.asr.startRecording();
|
|
45
|
+
* ASR (Automatic Speech Recognition) Client API
|
|
87
46
|
*
|
|
88
|
-
*
|
|
89
|
-
* client.asr.stopRecording();
|
|
47
|
+
* Provides real-time speech-to-text conversion via WebSocket.
|
|
90
48
|
*
|
|
91
|
-
*
|
|
92
|
-
* client.asr.close();
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* With error handling:
|
|
97
|
-
* ```typescript
|
|
98
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
99
|
-
*
|
|
100
|
-
* client.asr = createASRClient({
|
|
101
|
-
* onReady: () => console.log('ASR ready'),
|
|
102
|
-
* onSpeechStart: () => console.log('Speech detected'),
|
|
103
|
-
* onSpeechEnd: () => console.log('Speech ended'),
|
|
104
|
-
* onTranscript: (text, isFinal) => {
|
|
105
|
-
* console.log(isFinal ? `[FINAL] ${text}` : `[INTERIM] ${text}`);
|
|
106
|
-
* },
|
|
107
|
-
* onError: (error) => {
|
|
108
|
-
* console.error('ASR Error:', error.message);
|
|
109
|
-
* },
|
|
110
|
-
* onClose: () => {
|
|
111
|
-
* console.log('ASR connection closed');
|
|
112
|
-
* }
|
|
113
|
-
* });
|
|
114
|
-
*
|
|
115
|
-
* try {
|
|
116
|
-
* await client.asr.connect();
|
|
117
|
-
* await client.asr.startRecording();
|
|
118
|
-
* } catch (error) {
|
|
119
|
-
* console.error('Failed to start ASR:', error);
|
|
120
|
-
* }
|
|
121
|
-
* ```
|
|
49
|
+
* @since 1.0.0
|
|
122
50
|
*/
|
|
123
|
-
export interface
|
|
51
|
+
export interface ASRClientAPI {
|
|
124
52
|
/**
|
|
125
53
|
* Connect to ASR service
|
|
126
54
|
*
|
|
127
55
|
* Establishes WebSocket connection to the speech recognition service.
|
|
128
56
|
*
|
|
129
57
|
* @returns Promise that resolves when connected
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```typescript
|
|
133
|
-
* await client.asr.connect();
|
|
134
|
-
* console.log('Connected to ASR service');
|
|
135
|
-
* ```
|
|
58
|
+
*
|
|
136
59
|
*/
|
|
137
60
|
connect(): Promise<void>;
|
|
138
61
|
|
|
@@ -143,19 +66,7 @@ export interface ASRClient {
|
|
|
143
66
|
* Requires microphone permission from the user.
|
|
144
67
|
*
|
|
145
68
|
* @returns Promise that resolves when recording starts
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```typescript
|
|
149
|
-
* // Request microphone permission and start recording
|
|
150
|
-
* try {
|
|
151
|
-
* await client.asr.startRecording();
|
|
152
|
-
* console.log('Recording started');
|
|
153
|
-
* } catch (error) {
|
|
154
|
-
* if (error.name === 'NotAllowedError') {
|
|
155
|
-
* console.error('Microphone permission denied');
|
|
156
|
-
* }
|
|
157
|
-
* }
|
|
158
|
-
* ```
|
|
69
|
+
*
|
|
159
70
|
*/
|
|
160
71
|
startRecording(): Promise<void>;
|
|
161
72
|
|
|
@@ -163,16 +74,7 @@ export interface ASRClient {
|
|
|
163
74
|
* Stop recording
|
|
164
75
|
*
|
|
165
76
|
* Stops capturing audio from the microphone but keeps the WebSocket connection open.
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* ```typescript
|
|
169
|
-
* // Stop recording after 10 seconds
|
|
170
|
-
* await client.asr.startRecording();
|
|
171
|
-
* setTimeout(() => {
|
|
172
|
-
* client.asr.stopRecording();
|
|
173
|
-
* console.log('Recording stopped');
|
|
174
|
-
* }, 10000);
|
|
175
|
-
* ```
|
|
77
|
+
*
|
|
176
78
|
*/
|
|
177
79
|
stopRecording(): void;
|
|
178
80
|
|
|
@@ -180,13 +82,7 @@ export interface ASRClient {
|
|
|
180
82
|
* Close connection
|
|
181
83
|
*
|
|
182
84
|
* Closes the WebSocket connection and releases resources.
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* ```typescript
|
|
186
|
-
* // Cleanup when done
|
|
187
|
-
* client.asr.stopRecording();
|
|
188
|
-
* client.asr.close();
|
|
189
|
-
* ```
|
|
85
|
+
*
|
|
190
86
|
*/
|
|
191
87
|
close(): void;
|
|
192
88
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Verification Code Authentication - Type Definitions
|
|
4
|
-
* ============================================================================
|
|
5
|
-
*
|
|
6
|
-
* Verification code-based authentication including:
|
|
2
|
+
* * Verification code-based authentication including:
|
|
7
3
|
* - Email verification code login
|
|
8
4
|
* - SMS verification code login
|
|
9
5
|
* - Send verification code
|
|
@@ -24,46 +20,7 @@ export type CodeLoginType = 'email' | 'phone';
|
|
|
24
20
|
|
|
25
21
|
/**
|
|
26
22
|
* Verification code login parameters
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* Email code login:
|
|
30
|
-
* ```typescript
|
|
31
|
-
* // 1. Send verification code
|
|
32
|
-
* await client.auth.sendCode({
|
|
33
|
-
* type: 'email',
|
|
34
|
-
* email: 'user@example.com'
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* // 2. User receives code via email: "123456"
|
|
38
|
-
*
|
|
39
|
-
* // 3. Login with code
|
|
40
|
-
* const result = await client.auth.codeLogin({
|
|
41
|
-
* email: 'user@example.com',
|
|
42
|
-
* code: '123456'
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* if (result.data) {
|
|
46
|
-
* console.log('Logged in successfully!');
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* Phone code login:
|
|
52
|
-
* ```typescript
|
|
53
|
-
* // 1. Send SMS code
|
|
54
|
-
* await client.auth.sendCode({
|
|
55
|
-
* type: 'phone',
|
|
56
|
-
* phone: '+86-13800138000'
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* // 2. User receives SMS: "654321"
|
|
60
|
-
*
|
|
61
|
-
* // 3. Login with code
|
|
62
|
-
* await client.auth.codeLogin({
|
|
63
|
-
* phone: '+86-13800138000',
|
|
64
|
-
* code: '654321'
|
|
65
|
-
* });
|
|
66
|
-
* ```
|
|
23
|
+
*
|
|
67
24
|
*/
|
|
68
25
|
export interface CodeLoginParams {
|
|
69
26
|
/** Login method (optional, auto-detected) */
|
|
@@ -119,45 +76,7 @@ export interface CodeAuthAPI {
|
|
|
119
76
|
*
|
|
120
77
|
* @param params - Email/phone and verification code
|
|
121
78
|
* @returns User info and access token
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* Complete code login flow:
|
|
125
|
-
* ```typescript
|
|
126
|
-
* // 1. Send verification code
|
|
127
|
-
* await client.auth.sendCode({
|
|
128
|
-
* type: 'email',
|
|
129
|
-
* email: 'user@example.com'
|
|
130
|
-
* });
|
|
131
|
-
*
|
|
132
|
-
* // 2. User receives code: "123456"
|
|
133
|
-
*
|
|
134
|
-
* // 3. Login with code
|
|
135
|
-
* const result = await client.auth.codeLogin({
|
|
136
|
-
* email: 'user@example.com',
|
|
137
|
-
* code: '123456'
|
|
138
|
-
* });
|
|
139
|
-
*
|
|
140
|
-
* if (result.data) {
|
|
141
|
-
* console.log('Logged in successfully!');
|
|
142
|
-
* }
|
|
143
|
-
* ```
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* SMS code login with error handling:
|
|
147
|
-
* ```typescript
|
|
148
|
-
* const result = await client.auth.codeLogin({
|
|
149
|
-
* phone: '+86-13800138000',
|
|
150
|
-
* code: userInputCode
|
|
151
|
-
* });
|
|
152
|
-
*
|
|
153
|
-
* if (result.error) {
|
|
154
|
-
* if (result.status === 400) {
|
|
155
|
-
* console.error('Invalid or expired code');
|
|
156
|
-
* } else {
|
|
157
|
-
* console.error('Login failed:', result.error.message);
|
|
158
|
-
* }
|
|
159
|
-
* }
|
|
160
|
-
* ```
|
|
79
|
+
*
|
|
161
80
|
*/
|
|
162
81
|
codeLogin(params: CodeLoginParams): Promise<ClientResult<LoginResponse>>;
|
|
163
82
|
|
|
@@ -169,43 +88,7 @@ export interface CodeAuthAPI {
|
|
|
169
88
|
*
|
|
170
89
|
* @param params - Email or phone to send code to
|
|
171
90
|
* @returns Success status
|
|
172
|
-
*
|
|
173
|
-
* @example
|
|
174
|
-
* Send email verification code:
|
|
175
|
-
* ```typescript
|
|
176
|
-
* const result = await client.auth.sendCode({
|
|
177
|
-
* type: 'email',
|
|
178
|
-
* email: 'user@example.com'
|
|
179
|
-
* });
|
|
180
|
-
*
|
|
181
|
-
* if (result.data?.success) {
|
|
182
|
-
* console.log('Code sent to email');
|
|
183
|
-
* showCodeInputForm();
|
|
184
|
-
* }
|
|
185
|
-
* ```
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* Send SMS verification code:
|
|
189
|
-
* ```typescript
|
|
190
|
-
* await client.auth.sendCode({
|
|
191
|
-
* type: 'phone',
|
|
192
|
-
* phone: '+86-13800138000'
|
|
193
|
-
* });
|
|
194
|
-
* console.log('SMS sent');
|
|
195
|
-
* ```
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* With rate limiting handling:
|
|
199
|
-
* ```typescript
|
|
200
|
-
* const result = await client.auth.sendCode({
|
|
201
|
-
* type: 'email',
|
|
202
|
-
* email: 'user@example.com'
|
|
203
|
-
* });
|
|
204
|
-
*
|
|
205
|
-
* if (result.status === 429) {
|
|
206
|
-
* console.error('Too many requests. Please try again later.');
|
|
207
|
-
* }
|
|
208
|
-
* ```
|
|
91
|
+
*
|
|
209
92
|
*/
|
|
210
93
|
sendCode(params: SendCodeParams): Promise<ClientResult<SuccessResponse>>;
|
|
211
94
|
|
|
@@ -216,39 +99,7 @@ export interface CodeAuthAPI {
|
|
|
216
99
|
* Used during registration or sensitive operations.
|
|
217
100
|
*
|
|
218
101
|
* @returns Captcha ID and image (base64)
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* Display captcha to user:
|
|
222
|
-
* ```typescript
|
|
223
|
-
* const result = await client.auth.getCaptcha();
|
|
224
|
-
* if (result.data) {
|
|
225
|
-
* // Display image to user
|
|
226
|
-
* const img = document.createElement('img');
|
|
227
|
-
* img.src = result.data.captchaImage;
|
|
228
|
-
* document.body.appendChild(img);
|
|
229
|
-
*
|
|
230
|
-
* // Save captchaId for later verification
|
|
231
|
-
* const captchaId = result.data.captchaId;
|
|
232
|
-
* }
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* Use with registration:
|
|
237
|
-
* ```typescript
|
|
238
|
-
* // 1. Get captcha
|
|
239
|
-
* const captchaResult = await client.auth.getCaptcha();
|
|
240
|
-
* showCaptchaImage(captchaResult.data.captchaImage);
|
|
241
|
-
*
|
|
242
|
-
* // 2. Get user input
|
|
243
|
-
* const userInput = await promptUserForCaptcha();
|
|
244
|
-
*
|
|
245
|
-
* // 3. Register with captcha
|
|
246
|
-
* await client.auth.register({
|
|
247
|
-
* email: 'user@example.com',
|
|
248
|
-
* password: 'Password@123',
|
|
249
|
-
* captcha: `${captchaResult.data.captchaId}:${userInput}`
|
|
250
|
-
* });
|
|
251
|
-
* ```
|
|
102
|
+
*
|
|
252
103
|
*/
|
|
253
104
|
getCaptcha(): Promise<ClientResult<CaptchaResponse>>;
|
|
254
105
|
}
|