@blinkdotnew/sdk 2.3.10 → 2.4.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/index.d.mts CHANGED
@@ -1969,7 +1969,8 @@ interface BlinkFunctions {
1969
1969
  * Invoke a Blink Edge Function.
1970
1970
  *
1971
1971
  * Automatically attaches the user's JWT for authenticated requests.
1972
- * The function URL is constructed as: https://{projectSuffix}--{functionSlug}.functions.blink.new
1972
+ * The function URL is constructed as: https://{projectId8}.backend.blink.new/{functionSlug}
1973
+ * User-supplied headers take precedence over the auto-attached Authorization header.
1973
1974
  *
1974
1975
  * @param functionSlug - The slug of the edge function to invoke
1975
1976
  * @param options - Request options (method, body, headers, etc.)
package/dist/index.d.ts CHANGED
@@ -1969,7 +1969,8 @@ interface BlinkFunctions {
1969
1969
  * Invoke a Blink Edge Function.
1970
1970
  *
1971
1971
  * Automatically attaches the user's JWT for authenticated requests.
1972
- * The function URL is constructed as: https://{projectSuffix}--{functionSlug}.functions.blink.new
1972
+ * The function URL is constructed as: https://{projectId8}.backend.blink.new/{functionSlug}
1973
+ * User-supplied headers take precedence over the auto-attached Authorization header.
1973
1974
  *
1974
1975
  * @param functionSlug - The slug of the edge function to invoke
1975
1976
  * @param options - Request options (method, body, headers, etc.)
package/dist/index.js CHANGED
@@ -421,7 +421,7 @@ var HttpClient = class {
421
421
  shouldSkipSecretKey(url) {
422
422
  try {
423
423
  const parsed = new URL(url);
424
- return parsed.hostname.endsWith(".functions.blink.new");
424
+ return parsed.hostname.endsWith(".functions.blink.new") || parsed.hostname.endsWith(".backend.blink.new");
425
425
  } catch {
426
426
  return false;
427
427
  }
@@ -6272,9 +6272,11 @@ var BlinkConnectorsImpl = class {
6272
6272
  var BlinkFunctionsImpl = class {
6273
6273
  httpClient;
6274
6274
  projectId;
6275
- constructor(httpClient, projectId, _getToken) {
6275
+ getToken;
6276
+ constructor(httpClient, projectId, getToken) {
6276
6277
  this.httpClient = httpClient;
6277
6278
  this.projectId = projectId;
6279
+ this.getToken = getToken;
6278
6280
  }
6279
6281
  /**
6280
6282
  * Get the project suffix from the full project ID.
@@ -6285,11 +6287,11 @@ var BlinkFunctionsImpl = class {
6285
6287
  return this.projectId.slice(-8);
6286
6288
  }
6287
6289
  /**
6288
- * Build the full function URL
6290
+ * Build the full function URL using CF Workers format.
6289
6291
  */
6290
6292
  buildFunctionUrl(functionSlug, searchParams) {
6291
6293
  const suffix = this.getProjectSuffix();
6292
- const baseUrl = `https://${suffix}--${functionSlug}.functions.blink.new`;
6294
+ const baseUrl = `https://${suffix}.backend.blink.new/${functionSlug}`;
6293
6295
  if (!searchParams || Object.keys(searchParams).length === 0) {
6294
6296
  return baseUrl;
6295
6297
  }
@@ -6302,7 +6304,13 @@ var BlinkFunctionsImpl = class {
6302
6304
  async invoke(functionSlug, options = {}) {
6303
6305
  const { method = "POST", body, headers = {}, searchParams } = options;
6304
6306
  const url = this.buildFunctionUrl(functionSlug, searchParams);
6305
- const res = await this.httpClient.request(url, { method, body, headers });
6307
+ const token = await this.getToken();
6308
+ const authHeaders = token ? { Authorization: `Bearer ${token}` } : {};
6309
+ const res = await this.httpClient.request(url, {
6310
+ method,
6311
+ body,
6312
+ headers: { ...authHeaders, ...headers }
6313
+ });
6306
6314
  return { data: res.data, status: res.status, headers: res.headers };
6307
6315
  }
6308
6316
  };
package/dist/index.mjs CHANGED
@@ -419,7 +419,7 @@ var HttpClient = class {
419
419
  shouldSkipSecretKey(url) {
420
420
  try {
421
421
  const parsed = new URL(url);
422
- return parsed.hostname.endsWith(".functions.blink.new");
422
+ return parsed.hostname.endsWith(".functions.blink.new") || parsed.hostname.endsWith(".backend.blink.new");
423
423
  } catch {
424
424
  return false;
425
425
  }
@@ -6270,9 +6270,11 @@ var BlinkConnectorsImpl = class {
6270
6270
  var BlinkFunctionsImpl = class {
6271
6271
  httpClient;
6272
6272
  projectId;
6273
- constructor(httpClient, projectId, _getToken) {
6273
+ getToken;
6274
+ constructor(httpClient, projectId, getToken) {
6274
6275
  this.httpClient = httpClient;
6275
6276
  this.projectId = projectId;
6277
+ this.getToken = getToken;
6276
6278
  }
6277
6279
  /**
6278
6280
  * Get the project suffix from the full project ID.
@@ -6283,11 +6285,11 @@ var BlinkFunctionsImpl = class {
6283
6285
  return this.projectId.slice(-8);
6284
6286
  }
6285
6287
  /**
6286
- * Build the full function URL
6288
+ * Build the full function URL using CF Workers format.
6287
6289
  */
6288
6290
  buildFunctionUrl(functionSlug, searchParams) {
6289
6291
  const suffix = this.getProjectSuffix();
6290
- const baseUrl = `https://${suffix}--${functionSlug}.functions.blink.new`;
6292
+ const baseUrl = `https://${suffix}.backend.blink.new/${functionSlug}`;
6291
6293
  if (!searchParams || Object.keys(searchParams).length === 0) {
6292
6294
  return baseUrl;
6293
6295
  }
@@ -6300,7 +6302,13 @@ var BlinkFunctionsImpl = class {
6300
6302
  async invoke(functionSlug, options = {}) {
6301
6303
  const { method = "POST", body, headers = {}, searchParams } = options;
6302
6304
  const url = this.buildFunctionUrl(functionSlug, searchParams);
6303
- const res = await this.httpClient.request(url, { method, body, headers });
6305
+ const token = await this.getToken();
6306
+ const authHeaders = token ? { Authorization: `Bearer ${token}` } : {};
6307
+ const res = await this.httpClient.request(url, {
6308
+ method,
6309
+ body,
6310
+ headers: { ...authHeaders, ...headers }
6311
+ });
6304
6312
  return { data: res.data, status: res.status, headers: res.headers };
6305
6313
  }
6306
6314
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkdotnew/sdk",
3
- "version": "2.3.10",
3
+ "version": "2.4.0",
4
4
  "description": "Blink TypeScript SDK for client-side applications - Zero-boilerplate CRUD + auth + AI + analytics + notifications for modern SaaS/AI apps",
5
5
  "keywords": [
6
6
  "blink",