@robosystems/client 0.1.21 → 0.1.22

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.
Files changed (43) hide show
  1. package/extensions/CopyClient.d.ts +1 -0
  2. package/extensions/CopyClient.js +3 -0
  3. package/extensions/CopyClient.ts +5 -0
  4. package/extensions/OperationClient.d.ts +1 -0
  5. package/extensions/OperationClient.ts +2 -0
  6. package/extensions/QueryClient.d.ts +1 -0
  7. package/extensions/QueryClient.js +1 -0
  8. package/extensions/QueryClient.ts +3 -0
  9. package/extensions/SSEClient.d.ts +14 -0
  10. package/extensions/SSEClient.js +7 -1
  11. package/extensions/SSEClient.ts +22 -1
  12. package/extensions/config.d.ts +25 -0
  13. package/extensions/config.js +78 -0
  14. package/extensions/config.ts +84 -0
  15. package/extensions/hooks.js +16 -0
  16. package/extensions/hooks.ts +27 -1
  17. package/extensions/index.d.ts +2 -0
  18. package/extensions/index.js +14 -0
  19. package/extensions/index.ts +28 -1
  20. package/package.json +1 -1
  21. package/sdk/types.gen.d.ts +493 -59
  22. package/sdk/types.gen.ts +493 -59
  23. package/sdk-extensions/CopyClient.d.ts +1 -0
  24. package/sdk-extensions/CopyClient.js +3 -0
  25. package/sdk-extensions/CopyClient.ts +5 -0
  26. package/sdk-extensions/OperationClient.d.ts +1 -0
  27. package/sdk-extensions/OperationClient.ts +2 -0
  28. package/sdk-extensions/QueryClient.d.ts +1 -0
  29. package/sdk-extensions/QueryClient.js +1 -0
  30. package/sdk-extensions/QueryClient.ts +3 -0
  31. package/sdk-extensions/SSEClient.d.ts +14 -0
  32. package/sdk-extensions/SSEClient.js +7 -1
  33. package/sdk-extensions/SSEClient.ts +22 -1
  34. package/sdk-extensions/config.d.ts +25 -0
  35. package/sdk-extensions/config.js +78 -0
  36. package/sdk-extensions/config.ts +84 -0
  37. package/sdk-extensions/hooks.js +16 -0
  38. package/sdk-extensions/hooks.ts +27 -1
  39. package/sdk-extensions/index.d.ts +2 -0
  40. package/sdk-extensions/index.js +14 -0
  41. package/sdk-extensions/index.ts +28 -1
  42. package/types.gen.d.ts +493 -59
  43. package/types.gen.ts +493 -59
@@ -34,6 +34,7 @@ export declare class CopyClient {
34
34
  baseUrl: string;
35
35
  credentials?: 'include' | 'same-origin' | 'omit';
36
36
  headers?: Record<string, string>;
37
+ token?: string;
37
38
  });
38
39
  /**
39
40
  * Copy data from S3 to graph database
@@ -39,6 +39,9 @@ class CopyClient {
39
39
  url: '/v1/{graph_id}/copy',
40
40
  path: { graph_id: graphId },
41
41
  body: request,
42
+ query: {
43
+ token: this.config.token, // Pass JWT token for SSE authentication
44
+ },
42
45
  };
43
46
  try {
44
47
  // Execute the copy request
@@ -53,12 +53,14 @@ export class CopyClient {
53
53
  baseUrl: string
54
54
  credentials?: 'include' | 'same-origin' | 'omit'
55
55
  headers?: Record<string, string>
56
+ token?: string // JWT token for authentication
56
57
  }
57
58
 
58
59
  constructor(config: {
59
60
  baseUrl: string
60
61
  credentials?: 'include' | 'same-origin' | 'omit'
61
62
  headers?: Record<string, string>
63
+ token?: string // JWT token for authentication
62
64
  }) {
63
65
  this.config = config
64
66
  }
@@ -111,6 +113,9 @@ export class CopyClient {
111
113
  url: '/v1/{graph_id}/copy' as const,
112
114
  path: { graph_id: graphId },
113
115
  body: request,
116
+ query: {
117
+ token: this.config.token, // Pass JWT token for SSE authentication
118
+ },
114
119
  }
115
120
 
116
121
  try {
@@ -24,6 +24,7 @@ export declare class OperationClient {
24
24
  baseUrl: string;
25
25
  credentials?: 'include' | 'same-origin' | 'omit';
26
26
  headers?: Record<string, string>;
27
+ token?: string;
27
28
  maxRetries?: number;
28
29
  retryDelay?: number;
29
30
  });
@@ -34,6 +34,7 @@ export class OperationClient {
34
34
  baseUrl: string
35
35
  credentials?: 'include' | 'same-origin' | 'omit'
36
36
  headers?: Record<string, string>
37
+ token?: string // JWT token for authentication
37
38
  maxRetries?: number
38
39
  retryDelay?: number
39
40
  }
@@ -44,6 +45,7 @@ export class OperationClient {
44
45
  baseUrl: string
45
46
  credentials?: 'include' | 'same-origin' | 'omit'
46
47
  headers?: Record<string, string>
48
+ token?: string // JWT token for authentication
47
49
  maxRetries?: number
48
50
  retryDelay?: number
49
51
  }) {
@@ -33,6 +33,7 @@ export declare class QueryClient {
33
33
  baseUrl: string;
34
34
  credentials?: 'include' | 'same-origin' | 'omit';
35
35
  headers?: Record<string, string>;
36
+ token?: string;
36
37
  });
37
38
  executeQuery(graphId: string, request: QueryRequest, options?: QueryOptions): Promise<QueryResult | AsyncIterableIterator<any>>;
38
39
  private streamQueryResults;
@@ -23,6 +23,7 @@ class QueryClient {
23
23
  query: {
24
24
  mode: options.mode,
25
25
  test_mode: options.testMode,
26
+ token: this.config.token, // Pass JWT token for SSE authentication
26
27
  },
27
28
  };
28
29
  // Execute the query
@@ -47,12 +47,14 @@ export class QueryClient {
47
47
  baseUrl: string
48
48
  credentials?: 'include' | 'same-origin' | 'omit'
49
49
  headers?: Record<string, string>
50
+ token?: string // JWT token for authentication
50
51
  }
51
52
 
52
53
  constructor(config: {
53
54
  baseUrl: string
54
55
  credentials?: 'include' | 'same-origin' | 'omit'
55
56
  headers?: Record<string, string>
57
+ token?: string // JWT token for authentication
56
58
  }) {
57
59
  this.config = config
58
60
  }
@@ -72,6 +74,7 @@ export class QueryClient {
72
74
  query: {
73
75
  mode: options.mode,
74
76
  test_mode: options.testMode,
77
+ token: this.config.token, // Pass JWT token for SSE authentication
75
78
  },
76
79
  }
77
80
 
@@ -1,11 +1,25 @@
1
1
  /**
2
2
  * Core SSE (Server-Sent Events) client for RoboSystems API
3
3
  * Provides automatic reconnection, event replay, and type-safe event handling
4
+ *
5
+ * SECURITY NOTE: When using JWT authentication, tokens are passed as query parameters
6
+ * due to EventSource API limitations. This means tokens may appear in:
7
+ * - Server access logs
8
+ * - Proxy logs
9
+ * - Browser history
10
+ * - Referer headers
11
+ *
12
+ * For production environments with sensitive data, consider:
13
+ * - Using cookie-based authentication instead
14
+ * - Implementing a WebSocket-based alternative
15
+ * - Using short-lived tokens that expire quickly
16
+ * - Ensuring all connections use HTTPS
4
17
  */
5
18
  export interface SSEConfig {
6
19
  baseUrl: string;
7
20
  credentials?: 'include' | 'same-origin' | 'omit';
8
21
  headers?: Record<string, string>;
22
+ token?: string;
9
23
  maxRetries?: number;
10
24
  retryDelay?: number;
11
25
  heartbeatInterval?: number;
@@ -28,7 +28,13 @@ class SSEClient {
28
28
  }
29
29
  async connect(operationId, fromSequence = 0) {
30
30
  return new Promise((resolve, reject) => {
31
- const url = `${this.config.baseUrl}/v1/operations/${operationId}/stream?from_sequence=${fromSequence}`;
31
+ let url = `${this.config.baseUrl}/v1/operations/${operationId}/stream?from_sequence=${fromSequence}`;
32
+ // Add JWT token as query parameter if provided
33
+ // WARNING: EventSource API doesn't support custom headers, so tokens are passed via query param
34
+ // This has security implications - see class documentation
35
+ if (this.config.token) {
36
+ url += `&token=${encodeURIComponent(this.config.token)}`;
37
+ }
32
38
  this.eventSource = new EventSource(url, {
33
39
  withCredentials: this.config.credentials === 'include',
34
40
  });
@@ -3,12 +3,26 @@
3
3
  /**
4
4
  * Core SSE (Server-Sent Events) client for RoboSystems API
5
5
  * Provides automatic reconnection, event replay, and type-safe event handling
6
+ *
7
+ * SECURITY NOTE: When using JWT authentication, tokens are passed as query parameters
8
+ * due to EventSource API limitations. This means tokens may appear in:
9
+ * - Server access logs
10
+ * - Proxy logs
11
+ * - Browser history
12
+ * - Referer headers
13
+ *
14
+ * For production environments with sensitive data, consider:
15
+ * - Using cookie-based authentication instead
16
+ * - Implementing a WebSocket-based alternative
17
+ * - Using short-lived tokens that expire quickly
18
+ * - Ensuring all connections use HTTPS
6
19
  */
7
20
 
8
21
  export interface SSEConfig {
9
22
  baseUrl: string
10
23
  credentials?: 'include' | 'same-origin' | 'omit'
11
24
  headers?: Record<string, string>
25
+ token?: string // JWT token for authentication
12
26
  maxRetries?: number
13
27
  retryDelay?: number
14
28
  heartbeatInterval?: number
@@ -53,7 +67,14 @@ export class SSEClient {
53
67
 
54
68
  async connect(operationId: string, fromSequence: number = 0): Promise<void> {
55
69
  return new Promise((resolve, reject) => {
56
- const url = `${this.config.baseUrl}/v1/operations/${operationId}/stream?from_sequence=${fromSequence}`
70
+ let url = `${this.config.baseUrl}/v1/operations/${operationId}/stream?from_sequence=${fromSequence}`
71
+
72
+ // Add JWT token as query parameter if provided
73
+ // WARNING: EventSource API doesn't support custom headers, so tokens are passed via query param
74
+ // This has security implications - see class documentation
75
+ if (this.config.token) {
76
+ url += `&token=${encodeURIComponent(this.config.token)}`
77
+ }
57
78
 
58
79
  this.eventSource = new EventSource(url, {
59
80
  withCredentials: this.config.credentials === 'include',
@@ -6,6 +6,7 @@ export interface SDKExtensionsConfig {
6
6
  baseUrl?: string;
7
7
  credentials?: 'include' | 'same-origin' | 'omit';
8
8
  headers?: Record<string, string>;
9
+ token?: string;
9
10
  timeout?: number;
10
11
  maxRetries?: number;
11
12
  retryDelay?: number;
@@ -24,6 +25,30 @@ export declare function getSDKExtensionsConfig(): SDKExtensionsConfig;
24
25
  * Reset configuration to defaults
25
26
  */
26
27
  export declare function resetSDKExtensionsConfig(): void;
28
+ /**
29
+ * Extract JWT token from Authorization header
30
+ * @param authHeader Authorization header value
31
+ * @returns JWT token or undefined
32
+ */
33
+ export declare function extractJWTFromHeader(authHeader?: string | string[]): string | undefined;
34
+ /**
35
+ * Validate JWT token format (basic validation)
36
+ * @param token JWT token to validate
37
+ * @returns true if token appears valid
38
+ */
39
+ export declare function isValidJWT(token: string | undefined): boolean;
40
+ /**
41
+ * Extract JWT token from SDK client configuration
42
+ * Centralizes the logic for extracting tokens from the client
43
+ * @returns JWT token or undefined
44
+ */
45
+ export declare function extractTokenFromSDKClient(): string | undefined;
46
+ /**
47
+ * Configure SDK extensions for JWT authentication
48
+ * @param token JWT token
49
+ * @param config Additional configuration options
50
+ */
51
+ export declare function configureWithJWT(token: string, config?: Partial<SDKExtensionsConfig>): void;
27
52
  /**
28
53
  * Get configuration for a specific environment
29
54
  * @param env Environment name (production, staging, development)
@@ -4,11 +4,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.setSDKExtensionsConfig = setSDKExtensionsConfig;
5
5
  exports.getSDKExtensionsConfig = getSDKExtensionsConfig;
6
6
  exports.resetSDKExtensionsConfig = resetSDKExtensionsConfig;
7
+ exports.extractJWTFromHeader = extractJWTFromHeader;
8
+ exports.isValidJWT = isValidJWT;
9
+ exports.extractTokenFromSDKClient = extractTokenFromSDKClient;
10
+ exports.configureWithJWT = configureWithJWT;
7
11
  exports.getEnvironmentConfig = getEnvironmentConfig;
8
12
  // Default configuration
9
13
  const defaultConfig = {
10
14
  baseUrl: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000',
11
15
  credentials: 'include',
16
+ token: undefined, // Will be set from environment or programmatically
12
17
  timeout: 30000,
13
18
  maxRetries: 3,
14
19
  retryDelay: 1000,
@@ -38,6 +43,79 @@ function getSDKExtensionsConfig() {
38
43
  function resetSDKExtensionsConfig() {
39
44
  globalConfig = { ...defaultConfig };
40
45
  }
46
+ /**
47
+ * Extract JWT token from Authorization header
48
+ * @param authHeader Authorization header value
49
+ * @returns JWT token or undefined
50
+ */
51
+ function extractJWTFromHeader(authHeader) {
52
+ if (!authHeader)
53
+ return undefined;
54
+ const headerValue = Array.isArray(authHeader) ? authHeader[0] : authHeader;
55
+ if (typeof headerValue === 'string' && headerValue.startsWith('Bearer ')) {
56
+ return headerValue.substring(7);
57
+ }
58
+ return undefined;
59
+ }
60
+ /**
61
+ * Validate JWT token format (basic validation)
62
+ * @param token JWT token to validate
63
+ * @returns true if token appears valid
64
+ */
65
+ function isValidJWT(token) {
66
+ if (!token || typeof token !== 'string')
67
+ return false;
68
+ try {
69
+ const parts = token.split('.');
70
+ // JWT should have exactly 3 parts: header.payload.signature
71
+ return parts.length === 3 && parts.every((part) => part.length > 0);
72
+ }
73
+ catch {
74
+ return false;
75
+ }
76
+ }
77
+ /**
78
+ * Extract JWT token from SDK client configuration
79
+ * Centralizes the logic for extracting tokens from the client
80
+ * @returns JWT token or undefined
81
+ */
82
+ function extractTokenFromSDKClient() {
83
+ // Import dynamically to avoid circular dependency
84
+ const { client } = require('../sdk/client.gen');
85
+ const sdkConfig = getSDKExtensionsConfig();
86
+ // Priority 1: Use explicitly configured token
87
+ if (sdkConfig.token) {
88
+ return sdkConfig.token;
89
+ }
90
+ // Priority 2: Extract from SDK client headers
91
+ const clientConfig = client.getConfig();
92
+ if (clientConfig.headers) {
93
+ if (typeof clientConfig.headers === 'object' && !Array.isArray(clientConfig.headers)) {
94
+ const headers = clientConfig.headers;
95
+ const token = extractJWTFromHeader(headers.Authorization);
96
+ if (isValidJWT(token)) {
97
+ return token;
98
+ }
99
+ }
100
+ }
101
+ return undefined;
102
+ }
103
+ /**
104
+ * Configure SDK extensions for JWT authentication
105
+ * @param token JWT token
106
+ * @param config Additional configuration options
107
+ */
108
+ function configureWithJWT(token, config) {
109
+ if (!isValidJWT(token)) {
110
+ console.warn('Warning: Provided JWT token does not appear to be valid');
111
+ }
112
+ setSDKExtensionsConfig({
113
+ ...config,
114
+ token,
115
+ // When using JWT, typically don't need cookies
116
+ credentials: config?.credentials || 'omit',
117
+ });
118
+ }
41
119
  /**
42
120
  * Get configuration for a specific environment
43
121
  * @param env Environment name (production, staging, development)
@@ -9,6 +9,7 @@ export interface SDKExtensionsConfig {
9
9
  baseUrl?: string
10
10
  credentials?: 'include' | 'same-origin' | 'omit'
11
11
  headers?: Record<string, string>
12
+ token?: string // JWT token for authentication
12
13
  timeout?: number
13
14
  maxRetries?: number
14
15
  retryDelay?: number
@@ -18,6 +19,7 @@ export interface SDKExtensionsConfig {
18
19
  const defaultConfig: SDKExtensionsConfig = {
19
20
  baseUrl: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000',
20
21
  credentials: 'include',
22
+ token: undefined, // Will be set from environment or programmatically
21
23
  timeout: 30000,
22
24
  maxRetries: 3,
23
25
  retryDelay: 1000,
@@ -52,6 +54,88 @@ export function resetSDKExtensionsConfig() {
52
54
  globalConfig = { ...defaultConfig }
53
55
  }
54
56
 
57
+ /**
58
+ * Extract JWT token from Authorization header
59
+ * @param authHeader Authorization header value
60
+ * @returns JWT token or undefined
61
+ */
62
+ export function extractJWTFromHeader(authHeader?: string | string[]): string | undefined {
63
+ if (!authHeader) return undefined
64
+
65
+ const headerValue = Array.isArray(authHeader) ? authHeader[0] : authHeader
66
+ if (typeof headerValue === 'string' && headerValue.startsWith('Bearer ')) {
67
+ return headerValue.substring(7)
68
+ }
69
+
70
+ return undefined
71
+ }
72
+
73
+ /**
74
+ * Validate JWT token format (basic validation)
75
+ * @param token JWT token to validate
76
+ * @returns true if token appears valid
77
+ */
78
+ export function isValidJWT(token: string | undefined): boolean {
79
+ if (!token || typeof token !== 'string') return false
80
+
81
+ try {
82
+ const parts = token.split('.')
83
+ // JWT should have exactly 3 parts: header.payload.signature
84
+ return parts.length === 3 && parts.every((part) => part.length > 0)
85
+ } catch {
86
+ return false
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Extract JWT token from SDK client configuration
92
+ * Centralizes the logic for extracting tokens from the client
93
+ * @returns JWT token or undefined
94
+ */
95
+ export function extractTokenFromSDKClient(): string | undefined {
96
+ // Import dynamically to avoid circular dependency
97
+ const { client } = require('../sdk/client.gen')
98
+
99
+ const sdkConfig = getSDKExtensionsConfig()
100
+
101
+ // Priority 1: Use explicitly configured token
102
+ if (sdkConfig.token) {
103
+ return sdkConfig.token
104
+ }
105
+
106
+ // Priority 2: Extract from SDK client headers
107
+ const clientConfig = client.getConfig()
108
+ if (clientConfig.headers) {
109
+ if (typeof clientConfig.headers === 'object' && !Array.isArray(clientConfig.headers)) {
110
+ const headers = clientConfig.headers as Record<string, unknown>
111
+ const token = extractJWTFromHeader(headers.Authorization as string | undefined)
112
+ if (isValidJWT(token)) {
113
+ return token
114
+ }
115
+ }
116
+ }
117
+
118
+ return undefined
119
+ }
120
+
121
+ /**
122
+ * Configure SDK extensions for JWT authentication
123
+ * @param token JWT token
124
+ * @param config Additional configuration options
125
+ */
126
+ export function configureWithJWT(token: string, config?: Partial<SDKExtensionsConfig>) {
127
+ if (!isValidJWT(token)) {
128
+ console.warn('Warning: Provided JWT token does not appear to be valid')
129
+ }
130
+
131
+ setSDKExtensionsConfig({
132
+ ...config,
133
+ token,
134
+ // When using JWT, typically don't need cookies
135
+ credentials: config?.credentials || 'omit',
136
+ })
137
+ }
138
+
55
139
  /**
56
140
  * Get configuration for a specific environment
57
141
  * @param env Environment name (production, staging, development)
@@ -40,10 +40,13 @@ function useQuery(graphId) {
40
40
  (0, react_1.useEffect)(() => {
41
41
  const sdkConfig = (0, config_1.getSDKExtensionsConfig)();
42
42
  const clientConfig = client_gen_1.client.getConfig();
43
+ // Extract JWT token (uses centralized logic)
44
+ const token = (0, config_1.extractTokenFromSDKClient)();
43
45
  clientRef.current = new QueryClient_1.QueryClient({
44
46
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
45
47
  credentials: sdkConfig.credentials,
46
48
  headers: sdkConfig.headers,
49
+ token,
47
50
  });
48
51
  return () => {
49
52
  clientRef.current?.close();
@@ -120,6 +123,7 @@ function useStreamingQuery(graphId) {
120
123
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
121
124
  credentials: sdkConfig.credentials,
122
125
  headers: sdkConfig.headers,
126
+ token: sdkConfig.token,
123
127
  });
124
128
  return () => {
125
129
  clientRef.current?.close();
@@ -193,9 +197,12 @@ function useOperation(operationId) {
193
197
  (0, react_1.useEffect)(() => {
194
198
  const sdkConfig = (0, config_1.getSDKExtensionsConfig)();
195
199
  const clientConfig = client_gen_1.client.getConfig();
200
+ // Extract JWT token (uses centralized logic)
201
+ const token = (0, config_1.extractTokenFromSDKClient)();
196
202
  clientRef.current = new OperationClient_1.OperationClient({
197
203
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
198
204
  credentials: sdkConfig.credentials,
205
+ token,
199
206
  maxRetries: sdkConfig.maxRetries,
200
207
  retryDelay: sdkConfig.retryDelay,
201
208
  });
@@ -289,9 +296,12 @@ function useMultipleOperations() {
289
296
  (0, react_1.useEffect)(() => {
290
297
  const sdkConfig = (0, config_1.getSDKExtensionsConfig)();
291
298
  const clientConfig = client_gen_1.client.getConfig();
299
+ // Extract JWT token (uses centralized logic)
300
+ const token = (0, config_1.extractTokenFromSDKClient)();
292
301
  clientRef.current = new OperationClient_1.OperationClient({
293
302
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
294
303
  credentials: sdkConfig.credentials,
304
+ token,
295
305
  maxRetries: sdkConfig.maxRetries,
296
306
  retryDelay: sdkConfig.retryDelay,
297
307
  });
@@ -354,10 +364,13 @@ function useSDKClients() {
354
364
  (0, react_1.useEffect)(() => {
355
365
  const sdkConfig = (0, config_1.getSDKExtensionsConfig)();
356
366
  const clientConfig = client_gen_1.client.getConfig();
367
+ // Extract JWT token (uses centralized logic)
368
+ const token = (0, config_1.extractTokenFromSDKClient)();
357
369
  const baseConfig = {
358
370
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
359
371
  credentials: sdkConfig.credentials,
360
372
  headers: sdkConfig.headers,
373
+ token,
361
374
  };
362
375
  const copyClient = new CopyClient_1.CopyClient(baseConfig);
363
376
  const queryClient = new QueryClient_1.QueryClient(baseConfig);
@@ -404,10 +417,13 @@ function useCopy(graphId) {
404
417
  (0, react_1.useEffect)(() => {
405
418
  const sdkConfig = (0, config_1.getSDKExtensionsConfig)();
406
419
  const clientConfig = client_gen_1.client.getConfig();
420
+ // Extract JWT token (uses centralized logic)
421
+ const token = (0, config_1.extractTokenFromSDKClient)();
407
422
  clientRef.current = new CopyClient_1.CopyClient({
408
423
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
409
424
  credentials: sdkConfig.credentials,
410
425
  headers: sdkConfig.headers,
426
+ token,
411
427
  });
412
428
  return () => {
413
429
  clientRef.current?.close();
@@ -8,7 +8,7 @@
8
8
  import { useCallback, useEffect, useRef, useState } from 'react'
9
9
  import { client } from '../client.gen'
10
10
  import type { S3CopyRequest } from '../types.gen'
11
- import { getSDKExtensionsConfig } from './config'
11
+ import { extractTokenFromSDKClient, getSDKExtensionsConfig } from './config'
12
12
  import type { CopyOptions, CopyResult } from './CopyClient'
13
13
  import { CopyClient } from './CopyClient'
14
14
  import type { OperationProgress, OperationResult } from './OperationClient'
@@ -40,10 +40,15 @@ export function useQuery(graphId: string) {
40
40
  useEffect(() => {
41
41
  const sdkConfig = getSDKExtensionsConfig()
42
42
  const clientConfig = client.getConfig()
43
+
44
+ // Extract JWT token (uses centralized logic)
45
+ const token = extractTokenFromSDKClient()
46
+
43
47
  clientRef.current = new QueryClient({
44
48
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
45
49
  credentials: sdkConfig.credentials,
46
50
  headers: sdkConfig.headers,
51
+ token,
47
52
  })
48
53
 
49
54
  return () => {
@@ -140,6 +145,7 @@ export function useStreamingQuery(graphId: string) {
140
145
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
141
146
  credentials: sdkConfig.credentials,
142
147
  headers: sdkConfig.headers,
148
+ token: sdkConfig.token,
143
149
  })
144
150
 
145
151
  return () => {
@@ -229,9 +235,14 @@ export function useOperation<T = any>(operationId?: string) {
229
235
  useEffect(() => {
230
236
  const sdkConfig = getSDKExtensionsConfig()
231
237
  const clientConfig = client.getConfig()
238
+
239
+ // Extract JWT token (uses centralized logic)
240
+ const token = extractTokenFromSDKClient()
241
+
232
242
  clientRef.current = new OperationClient({
233
243
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
234
244
  credentials: sdkConfig.credentials,
245
+ token,
235
246
  maxRetries: sdkConfig.maxRetries,
236
247
  retryDelay: sdkConfig.retryDelay,
237
248
  })
@@ -337,9 +348,14 @@ export function useMultipleOperations<T = any>() {
337
348
  useEffect(() => {
338
349
  const sdkConfig = getSDKExtensionsConfig()
339
350
  const clientConfig = client.getConfig()
351
+
352
+ // Extract JWT token (uses centralized logic)
353
+ const token = extractTokenFromSDKClient()
354
+
340
355
  clientRef.current = new OperationClient({
341
356
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
342
357
  credentials: sdkConfig.credentials,
358
+ token,
343
359
  maxRetries: sdkConfig.maxRetries,
344
360
  retryDelay: sdkConfig.retryDelay,
345
361
  })
@@ -419,10 +435,15 @@ export function useSDKClients() {
419
435
  useEffect(() => {
420
436
  const sdkConfig = getSDKExtensionsConfig()
421
437
  const clientConfig = client.getConfig()
438
+
439
+ // Extract JWT token (uses centralized logic)
440
+ const token = extractTokenFromSDKClient()
441
+
422
442
  const baseConfig = {
423
443
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
424
444
  credentials: sdkConfig.credentials,
425
445
  headers: sdkConfig.headers,
446
+ token,
426
447
  }
427
448
 
428
449
  const copyClient = new CopyClient(baseConfig)
@@ -478,10 +499,15 @@ export function useCopy(graphId: string) {
478
499
  useEffect(() => {
479
500
  const sdkConfig = getSDKExtensionsConfig()
480
501
  const clientConfig = client.getConfig()
502
+
503
+ // Extract JWT token (uses centralized logic)
504
+ const token = extractTokenFromSDKClient()
505
+
481
506
  clientRef.current = new CopyClient({
482
507
  baseUrl: sdkConfig.baseUrl || clientConfig.baseUrl || 'http://localhost:8000',
483
508
  credentials: sdkConfig.credentials,
484
509
  headers: sdkConfig.headers,
510
+ token,
485
511
  })
486
512
 
487
513
  return () => {
@@ -9,6 +9,8 @@ import { SSEClient } from './SSEClient';
9
9
  export interface RoboSystemsExtensionConfig {
10
10
  baseUrl?: string;
11
11
  credentials?: 'include' | 'same-origin' | 'omit';
12
+ token?: string;
13
+ headers?: Record<string, string>;
12
14
  maxRetries?: number;
13
15
  retryDelay?: number;
14
16
  }
@@ -20,6 +20,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.copyFromS3 = exports.streamQuery = exports.executeQuery = exports.monitorOperation = exports.extensions = exports.useStreamingQuery = exports.useSDKClients = exports.useQuery = exports.useOperation = exports.useMultipleOperations = exports.useCopy = exports.SSEClient = exports.QueryClient = exports.OperationClient = exports.CopyClient = exports.RoboSystemsExtensions = void 0;
22
22
  const client_gen_1 = require("../client.gen");
23
+ const config_1 = require("./config");
23
24
  const CopyClient_1 = require("./CopyClient");
24
25
  Object.defineProperty(exports, "CopyClient", { enumerable: true, get: function () { return CopyClient_1.CopyClient; } });
25
26
  const OperationClient_1 = require("./OperationClient");
@@ -32,23 +33,34 @@ class RoboSystemsExtensions {
32
33
  constructor(config = {}) {
33
34
  // Get base URL from SDK client config or use provided/default
34
35
  const sdkConfig = client_gen_1.client.getConfig();
36
+ // Extract JWT token using centralized logic
37
+ const token = config.token || (0, config_1.extractTokenFromSDKClient)();
35
38
  this.config = {
36
39
  baseUrl: config.baseUrl || sdkConfig.baseUrl || 'http://localhost:8000',
37
40
  credentials: config.credentials || 'include',
41
+ token,
42
+ headers: config.headers,
38
43
  maxRetries: config.maxRetries || 5,
39
44
  retryDelay: config.retryDelay || 1000,
40
45
  };
41
46
  this.copy = new CopyClient_1.CopyClient({
42
47
  baseUrl: this.config.baseUrl,
43
48
  credentials: this.config.credentials,
49
+ token: this.config.token,
50
+ headers: this.config.headers,
44
51
  });
45
52
  this.query = new QueryClient_1.QueryClient({
46
53
  baseUrl: this.config.baseUrl,
47
54
  credentials: this.config.credentials,
55
+ token: this.config.token,
56
+ headers: this.config.headers,
48
57
  });
49
58
  this.operations = new OperationClient_1.OperationClient({
50
59
  baseUrl: this.config.baseUrl,
51
60
  credentials: this.config.credentials,
61
+ token: this.config.token,
62
+ maxRetries: this.config.maxRetries,
63
+ retryDelay: this.config.retryDelay,
52
64
  });
53
65
  }
54
66
  /**
@@ -64,6 +76,8 @@ class RoboSystemsExtensions {
64
76
  return new SSEClient_1.SSEClient({
65
77
  baseUrl: this.config.baseUrl,
66
78
  credentials: this.config.credentials,
79
+ token: this.config.token,
80
+ headers: this.config.headers,
67
81
  maxRetries: this.config.maxRetries,
68
82
  retryDelay: this.config.retryDelay,
69
83
  });