graphlit-client 1.0.20251222001 → 1.0.20251222002

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/client.d.ts CHANGED
@@ -26,6 +26,8 @@ export interface GraphlitClientOptions {
26
26
  ownerId?: string;
27
27
  userId?: string;
28
28
  apiUri?: string;
29
+ /** Pre-signed JWT token. When provided, jwtSecret is not required. */
30
+ token?: string;
29
31
  /** Retry configuration for network errors */
30
32
  retryConfig?: RetryConfig;
31
33
  }
@@ -50,7 +52,13 @@ declare class Graphlit {
50
52
  private deepseekClient?;
51
53
  private xaiClient?;
52
54
  constructor(organizationIdOrOptions?: string | GraphlitClientOptions, environmentId?: string, jwtSecret?: string, ownerId?: string, userId?: string, apiUri?: string);
55
+ /**
56
+ * Initialize the Apollo client without regenerating the token.
57
+ * Used when a pre-signed token is provided.
58
+ */
59
+ private initializeClient;
53
60
  refreshClient(): void;
61
+ private setupApolloClient;
54
62
  /**
55
63
  * Set a custom OpenAI client instance for streaming
56
64
  * @param client - OpenAI client instance (e.g., new OpenAI({ apiKey: "..." }))
package/dist/client.js CHANGED
@@ -223,7 +223,8 @@ class Graphlit {
223
223
  throw new Error(`Invalid environment ID format. Expected a valid GUID, but received: '${this.environmentId}'. ` +
224
224
  "A valid GUID should be in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
225
225
  }
226
- if (!this.jwtSecret) {
226
+ // jwtSecret is only required if no pre-signed token is provided
227
+ if (!this.jwtSecret && !options.token) {
227
228
  throw new Error("Graphlit environment JWT secret is required.");
228
229
  }
229
230
  // Validate optional userId if provided (ownerId can be any format)
@@ -231,11 +232,29 @@ class Graphlit {
231
232
  throw new Error(`Invalid user ID format. Expected a valid GUID, but received: '${this.userId}'. ` +
232
233
  "A valid GUID should be in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
233
234
  }
234
- this.refreshClient();
235
+ // If a pre-signed token is provided, use it directly instead of generating one
236
+ if (options.token) {
237
+ this.token = options.token;
238
+ this.initializeClient();
239
+ }
240
+ else {
241
+ this.refreshClient();
242
+ }
243
+ }
244
+ /**
245
+ * Initialize the Apollo client without regenerating the token.
246
+ * Used when a pre-signed token is provided.
247
+ */
248
+ initializeClient() {
249
+ this.client = undefined;
250
+ this.setupApolloClient();
235
251
  }
236
252
  refreshClient() {
237
253
  this.client = undefined;
238
254
  this.generateToken();
255
+ this.setupApolloClient();
256
+ }
257
+ setupApolloClient() {
239
258
  const httpLink = createHttpLink({
240
259
  uri: this.apiUri,
241
260
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphlit-client",
3
- "version": "1.0.20251222001",
3
+ "version": "1.0.20251222002",
4
4
  "description": "Graphlit API Client for TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/client.js",