@nexushub/client 0.1.2 → 0.1.4

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 CHANGED
@@ -365,7 +365,9 @@ var RateLimiter = class {
365
365
  getStats() {
366
366
  const now = Date.now();
367
367
  const windowStart = now - this.config.timeWindow;
368
- const currentRequests = this.requests.filter((time) => time > windowStart).length;
368
+ const currentRequests = this.requests.filter(
369
+ (time) => time > windowStart
370
+ ).length;
369
371
  return {
370
372
  currentRequests,
371
373
  limit: this.config.maxRequests
@@ -446,10 +448,15 @@ var CircuitBreaker = class {
446
448
  if (this.failures >= this.failureThreshold) {
447
449
  this.state = 1 /* OPEN */;
448
450
  if (process.env.NODE_ENV === "development") {
449
- console.warn(`[NexusHub] \u{1F50C} Circuit Breaker OPEN. Pausing network requests.`);
451
+ console.warn(
452
+ `[NexusHub] \u{1F50C} Circuit Breaker OPEN. Pausing network requests.`
453
+ );
450
454
  }
451
455
  }
452
456
  }
457
+ isIgnorableError(error) {
458
+ return _optionalChain([error, 'optionalAccess', _13 => _13.status]) === 401 || _optionalChain([error, 'optionalAccess', _14 => _14.status]) === 404;
459
+ }
453
460
  };
454
461
  var RequestBatcher = class {
455
462
  constructor(batchWindow = 10, maxBatchSize = 20) {
@@ -527,10 +534,10 @@ function buildQueryString(query) {
527
534
  if (query.sort) params.append("sort", query.sort);
528
535
  if (query.order) params.append("order", query.order);
529
536
  if (query.search) params.append("search", query.search);
530
- if (_optionalChain([query, 'access', _13 => _13.include, 'optionalAccess', _14 => _14.length])) {
537
+ if (_optionalChain([query, 'access', _15 => _15.include, 'optionalAccess', _16 => _16.length])) {
531
538
  params.append("include", query.include.join(","));
532
539
  }
533
- if (_optionalChain([query, 'access', _15 => _15.fields, 'optionalAccess', _16 => _16.length])) {
540
+ if (_optionalChain([query, 'access', _17 => _17.fields, 'optionalAccess', _18 => _18.length])) {
534
541
  params.append("fields", query.fields.join(","));
535
542
  }
536
543
  if (query.filter) {
@@ -812,7 +819,7 @@ var ContentEngine = class {
812
819
  }
813
820
  return this.requestBatcher.schedule(cacheKey, async () => {
814
821
  const params = new URLSearchParams();
815
- if (_optionalChain([options, 'access', _17 => _17.include, 'optionalAccess', _18 => _18.length])) {
822
+ if (_optionalChain([options, 'access', _19 => _19.include, 'optionalAccess', _20 => _20.length])) {
816
823
  params.append("include", options.include.join(","));
817
824
  }
818
825
  const url = `${this.config.apiUrl}/content/${this.config.projectId}/collection/${collectionId}/${itemId}?${params}`;
@@ -845,10 +852,10 @@ var ContentEngine = class {
845
852
  q: query,
846
853
  limit: (options.limit || 20).toString()
847
854
  });
848
- if (_optionalChain([options, 'access', _19 => _19.collections, 'optionalAccess', _20 => _20.length])) {
855
+ if (_optionalChain([options, 'access', _21 => _21.collections, 'optionalAccess', _22 => _22.length])) {
849
856
  params.append("collections", options.collections.join(","));
850
857
  }
851
- if (_optionalChain([options, 'access', _21 => _21.fields, 'optionalAccess', _22 => _22.length])) {
858
+ if (_optionalChain([options, 'access', _23 => _23.fields, 'optionalAccess', _24 => _24.length])) {
852
859
  params.append("fields", options.fields.join(","));
853
860
  }
854
861
  const url = `${this.config.apiUrl}/content/${this.config.projectId}/search?${params}`;
@@ -909,7 +916,7 @@ var ContentEngine = class {
909
916
  }
910
917
  };
911
918
  eventSource.onerror = () => {
912
- _optionalChain([eventSource, 'optionalAccess', _23 => _23.close, 'call', _24 => _24()]);
919
+ _optionalChain([eventSource, 'optionalAccess', _25 => _25.close, 'call', _26 => _26()]);
913
920
  if (isClosed) return;
914
921
  const timeout = Math.min(1e3 * Math.pow(2, retryCount), 1e4);
915
922
  retryCount++;
@@ -922,7 +929,7 @@ var ContentEngine = class {
922
929
  connect();
923
930
  return () => {
924
931
  isClosed = true;
925
- _optionalChain([eventSource, 'optionalAccess', _25 => _25.close, 'call', _26 => _26()]);
932
+ _optionalChain([eventSource, 'optionalAccess', _27 => _27.close, 'call', _28 => _28()]);
926
933
  };
927
934
  }
928
935
  // --- CACHE MANAGEMENT ---
@@ -1329,7 +1336,7 @@ var initVitals = (tracker) => {
1329
1336
  // src/analytics/storage.ts
1330
1337
  var DB_NAME = "NexusHub_Analytics";
1331
1338
  var STORE_NAME = "events_queue";
1332
- var DB_VERSION = 1;
1339
+ var DB_VERSION = 2;
1333
1340
  var EventStorage = class {
1334
1341
  constructor() {
1335
1342
  this.db = null;
@@ -1342,7 +1349,9 @@ var EventStorage = class {
1342
1349
  return new Promise((resolve, reject) => {
1343
1350
  const request = indexedDB.open(DB_NAME, DB_VERSION);
1344
1351
  request.onerror = () => {
1345
- console.warn("[NexusHub] Failed to open IndexedDB. Falling back to memory.");
1352
+ console.warn(
1353
+ "[NexusHub] Failed to open IndexedDB. Falling back to memory."
1354
+ );
1346
1355
  resolve();
1347
1356
  };
1348
1357
  request.onsuccess = (event) => {
@@ -1351,9 +1360,13 @@ var EventStorage = class {
1351
1360
  };
1352
1361
  request.onupgradeneeded = (event) => {
1353
1362
  const db = event.target.result;
1354
- if (!db.objectStoreNames.contains(STORE_NAME)) {
1355
- db.createObjectStore(STORE_NAME, { keyPath: "id", autoIncrement: true });
1363
+ if (db.objectStoreNames.contains(STORE_NAME)) {
1364
+ db.deleteObjectStore(STORE_NAME);
1356
1365
  }
1366
+ db.createObjectStore(STORE_NAME, {
1367
+ keyPath: "id",
1368
+ autoIncrement: true
1369
+ });
1357
1370
  };
1358
1371
  });
1359
1372
  }
@@ -1462,34 +1475,31 @@ var Tracker = class {
1462
1475
  const entropy = await getDeviceEntropy();
1463
1476
  const perfMetrics = vitalsCollector.getMetricsSnapshot();
1464
1477
  const payload = {
1465
- project_id: this.config.projectId,
1466
- session_id: this.sessionId,
1467
- // We send this, Rust verifies it
1478
+ projectId: this.config.projectId,
1479
+ sessionId: this.sessionId,
1468
1480
  url: window.location.href,
1469
1481
  referrer: document.referrer,
1470
- user_agent: window.navigator.userAgent,
1471
- screen_width: window.screen.width,
1472
- screen_height: window.screen.height,
1482
+ userAgent: window.navigator.userAgent,
1483
+ screenWidth: window.screen.width,
1484
+ screenHeight: window.screen.height,
1473
1485
  language: window.navigator.language,
1474
1486
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
1475
- event_type: eventType,
1476
- event_name: eventName,
1477
- event_data: data,
1478
- // 3. Attach Performance Data (Rust: Option<PerformanceMetrics>)
1487
+ eventType,
1488
+ eventName,
1489
+ eventData: data,
1479
1490
  performance: perfMetrics || void 0,
1480
- // 4. Attach Hardware Signals for Anomaly Detection (Rust: DeviceData)
1481
1491
  context: {
1482
1492
  device: {
1483
- hardware_concurrency: entropy.hardware_concurrency,
1484
- device_memory: entropy.device_memory,
1485
- pixel_ratio: entropy.pixel_ratio,
1486
- canvas_fingerprint: entropy.canvas_hash,
1493
+ hardwareConcurrency: entropy.hardware_concurrency,
1494
+ // Match Rust sub-struct too if needed
1495
+ deviceMemory: entropy.device_memory,
1496
+ pixelRatio: entropy.pixel_ratio,
1497
+ canvasFingerprint: entropy.canvas_hash,
1487
1498
  platform: entropy.platform
1488
1499
  },
1489
- visitor_id_local: this.visitorId
1490
- // Hint for stitching
1500
+ visitorIdLocal: this.visitorId
1491
1501
  },
1492
- client_timestamp: (/* @__PURE__ */ new Date()).toISOString()
1502
+ clientTimestamp: (/* @__PURE__ */ new Date()).toISOString()
1493
1503
  };
1494
1504
  await eventStorage.enqueue(payload);
1495
1505
  const count = await eventStorage.count();
@@ -1611,8 +1621,8 @@ var AnalyticsEngine = class {
1611
1621
  navigator.share = (data) => {
1612
1622
  this.tracker.send("social_share", {
1613
1623
  method: "native_share_menu",
1614
- url: _optionalChain([data, 'optionalAccess', _27 => _27.url]) || window.location.href,
1615
- title: _optionalChain([data, 'optionalAccess', _28 => _28.title])
1624
+ url: _optionalChain([data, 'optionalAccess', _29 => _29.url]) || window.location.href,
1625
+ title: _optionalChain([data, 'optionalAccess', _30 => _30.title])
1616
1626
  });
1617
1627
  return originalShare.apply(navigator, [data]);
1618
1628
  };
@@ -1707,9 +1717,9 @@ var AnalyticsEngine = class {
1707
1717
  const config = this.tracker["config"];
1708
1718
  const endpoint = `${config.analyticsUrl}/api/${type}`;
1709
1719
  const payload = {
1710
- project_id: this.tracker["config"].projectId,
1711
- session_id: this.tracker.getSession(),
1712
- visitor_id: this.tracker.visitorId,
1720
+ projectId: config.projectId,
1721
+ sessionId: this.tracker.getSession(),
1722
+ visitorId: this.tracker.visitorId,
1713
1723
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1714
1724
  ...data
1715
1725
  };
@@ -1743,7 +1753,7 @@ var AnalyticsEngine = class {
1743
1753
  this.tracker.send("click", {
1744
1754
  element_type: "link",
1745
1755
  href: link.href,
1746
- text: _optionalChain([link, 'access', _29 => _29.innerText, 'optionalAccess', _30 => _30.substring, 'call', _31 => _31(0, 50)]),
1756
+ text: _optionalChain([link, 'access', _31 => _31.innerText, 'optionalAccess', _32 => _32.substring, 'call', _33 => _33(0, 50)]),
1747
1757
  id: link.id,
1748
1758
  classes: link.className,
1749
1759
  dataset: { ...link.dataset }
@@ -1753,7 +1763,7 @@ var AnalyticsEngine = class {
1753
1763
  if (button) {
1754
1764
  this.tracker.send("click", {
1755
1765
  element_type: "button",
1756
- text: _optionalChain([button, 'access', _32 => _32.innerText, 'optionalAccess', _33 => _33.substring, 'call', _34 => _34(0, 50)]),
1766
+ text: _optionalChain([button, 'access', _34 => _34.innerText, 'optionalAccess', _35 => _35.substring, 'call', _36 => _36(0, 50)]),
1757
1767
  id: button.id,
1758
1768
  classes: button.className,
1759
1769
  coordinates: { x: e.clientX, y: e.clientY }
@@ -1823,11 +1833,11 @@ var NexusClient = class {
1823
1833
  constructor(config) {
1824
1834
  const fullConfig = getFullConfig(config);
1825
1835
  this.config = {
1826
- debug: _optionalChain([config, 'optionalAccess', _35 => _35.debug]) || false,
1827
- cacheStrategy: _optionalChain([config, 'optionalAccess', _36 => _36.cacheStrategy]) || "memory",
1828
- revalidateTime: _optionalChain([config, 'optionalAccess', _37 => _37.revalidateTime]) || 60,
1829
- timeout: _optionalChain([config, 'optionalAccess', _38 => _38.timeout]) || 1e4,
1830
- retries: _optionalChain([config, 'optionalAccess', _39 => _39.retries]) || 3,
1836
+ debug: _optionalChain([config, 'optionalAccess', _37 => _37.debug]) || false,
1837
+ cacheStrategy: _optionalChain([config, 'optionalAccess', _38 => _38.cacheStrategy]) || "memory",
1838
+ revalidateTime: _optionalChain([config, 'optionalAccess', _39 => _39.revalidateTime]) || 60,
1839
+ timeout: _optionalChain([config, 'optionalAccess', _40 => _40.timeout]) || 1e4,
1840
+ retries: _optionalChain([config, 'optionalAccess', _41 => _41.retries]) || 3,
1831
1841
  ...fullConfig
1832
1842
  };
1833
1843
  this.content = new ContentEngine(this.config);
@@ -1862,6 +1872,12 @@ var _navigation = require('next/navigation');
1862
1872
 
1863
1873
  // src/auth/context.tsx
1864
1874
 
1875
+
1876
+
1877
+
1878
+
1879
+
1880
+
1865
1881
  var _jsxruntime = require('react/jsx-runtime');
1866
1882
  var AuthContext = _react.createContext.call(void 0, null);
1867
1883
  var AuthProvider = ({
@@ -1957,7 +1973,10 @@ var AuthProvider = ({
1957
1973
  const logout = async () => {
1958
1974
  setIsLoading(true);
1959
1975
  try {
1960
- await fetch(`${AUTH_BASE}/logout`, { method: "POST", headers: getHeaders(config) });
1976
+ await fetch(`${AUTH_BASE}/logout`, {
1977
+ method: "POST",
1978
+ headers: getHeaders(config)
1979
+ });
1961
1980
  } catch (e) {
1962
1981
  console.warn("Logout network error", e);
1963
1982
  } finally {
@@ -1994,17 +2013,23 @@ var AuthProvider = ({
1994
2013
  });
1995
2014
  if (!res.ok) throw await parseError(res);
1996
2015
  };
1997
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AuthContext.Provider, { value: {
1998
- user,
1999
- isLoading,
2000
- error,
2001
- isAuthenticated: !!user,
2002
- login,
2003
- register,
2004
- logout,
2005
- updateProfile,
2006
- requestPasswordReset
2007
- }, children });
2016
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2017
+ AuthContext.Provider,
2018
+ {
2019
+ value: {
2020
+ user,
2021
+ isLoading,
2022
+ error,
2023
+ isAuthenticated: !!user,
2024
+ login,
2025
+ register,
2026
+ logout,
2027
+ updateProfile,
2028
+ requestPasswordReset
2029
+ },
2030
+ children
2031
+ }
2032
+ );
2008
2033
  };
2009
2034
  var useNexusAuth = () => {
2010
2035
  const context = _react.useContext.call(void 0, AuthContext);
@@ -2016,8 +2041,10 @@ var useNexusAuth = () => {
2016
2041
  function getHeaders(config) {
2017
2042
  return {
2018
2043
  "Content-Type": "application/json",
2019
- "x-nexus-project": config.projectId
2020
- // Note: We do NOT send the Master API Key here.
2044
+ "x-nexus-project": config.projectId,
2045
+ Authorization: `Bearer ${config.apiKey}`
2046
+ // 👈 CRITICAL: Send the nx_pk_ key
2047
+ // Note: We do NOT send the Master API Key here.
2021
2048
  // This is client-side. The backend uses Cookies or public tokens.
2022
2049
  };
2023
2050
  }
package/dist/index.d.cts CHANGED
@@ -325,7 +325,7 @@ interface AuthContextType extends AuthState {
325
325
  requestPasswordReset: (email: string) => Promise<void>;
326
326
  }
327
327
 
328
- declare const AuthProvider: ({ children, config }: {
328
+ declare const AuthProvider: ({ children, config, }: {
329
329
  children: React.ReactNode;
330
330
  config: NexusConfig;
331
331
  }) => react_jsx_runtime.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -325,7 +325,7 @@ interface AuthContextType extends AuthState {
325
325
  requestPasswordReset: (email: string) => Promise<void>;
326
326
  }
327
327
 
328
- declare const AuthProvider: ({ children, config }: {
328
+ declare const AuthProvider: ({ children, config, }: {
329
329
  children: React.ReactNode;
330
330
  config: NexusConfig;
331
331
  }) => react_jsx_runtime.JSX.Element;
package/dist/index.js CHANGED
@@ -365,7 +365,9 @@ var RateLimiter = class {
365
365
  getStats() {
366
366
  const now = Date.now();
367
367
  const windowStart = now - this.config.timeWindow;
368
- const currentRequests = this.requests.filter((time) => time > windowStart).length;
368
+ const currentRequests = this.requests.filter(
369
+ (time) => time > windowStart
370
+ ).length;
369
371
  return {
370
372
  currentRequests,
371
373
  limit: this.config.maxRequests
@@ -446,10 +448,15 @@ var CircuitBreaker = class {
446
448
  if (this.failures >= this.failureThreshold) {
447
449
  this.state = 1 /* OPEN */;
448
450
  if (process.env.NODE_ENV === "development") {
449
- console.warn(`[NexusHub] \u{1F50C} Circuit Breaker OPEN. Pausing network requests.`);
451
+ console.warn(
452
+ `[NexusHub] \u{1F50C} Circuit Breaker OPEN. Pausing network requests.`
453
+ );
450
454
  }
451
455
  }
452
456
  }
457
+ isIgnorableError(error) {
458
+ return error?.status === 401 || error?.status === 404;
459
+ }
453
460
  };
454
461
  var RequestBatcher = class {
455
462
  constructor(batchWindow = 10, maxBatchSize = 20) {
@@ -1329,7 +1336,7 @@ var initVitals = (tracker) => {
1329
1336
  // src/analytics/storage.ts
1330
1337
  var DB_NAME = "NexusHub_Analytics";
1331
1338
  var STORE_NAME = "events_queue";
1332
- var DB_VERSION = 1;
1339
+ var DB_VERSION = 2;
1333
1340
  var EventStorage = class {
1334
1341
  constructor() {
1335
1342
  this.db = null;
@@ -1342,7 +1349,9 @@ var EventStorage = class {
1342
1349
  return new Promise((resolve, reject) => {
1343
1350
  const request = indexedDB.open(DB_NAME, DB_VERSION);
1344
1351
  request.onerror = () => {
1345
- console.warn("[NexusHub] Failed to open IndexedDB. Falling back to memory.");
1352
+ console.warn(
1353
+ "[NexusHub] Failed to open IndexedDB. Falling back to memory."
1354
+ );
1346
1355
  resolve();
1347
1356
  };
1348
1357
  request.onsuccess = (event) => {
@@ -1351,9 +1360,13 @@ var EventStorage = class {
1351
1360
  };
1352
1361
  request.onupgradeneeded = (event) => {
1353
1362
  const db = event.target.result;
1354
- if (!db.objectStoreNames.contains(STORE_NAME)) {
1355
- db.createObjectStore(STORE_NAME, { keyPath: "id", autoIncrement: true });
1363
+ if (db.objectStoreNames.contains(STORE_NAME)) {
1364
+ db.deleteObjectStore(STORE_NAME);
1356
1365
  }
1366
+ db.createObjectStore(STORE_NAME, {
1367
+ keyPath: "id",
1368
+ autoIncrement: true
1369
+ });
1357
1370
  };
1358
1371
  });
1359
1372
  }
@@ -1462,34 +1475,31 @@ var Tracker = class {
1462
1475
  const entropy = await getDeviceEntropy();
1463
1476
  const perfMetrics = vitalsCollector.getMetricsSnapshot();
1464
1477
  const payload = {
1465
- project_id: this.config.projectId,
1466
- session_id: this.sessionId,
1467
- // We send this, Rust verifies it
1478
+ projectId: this.config.projectId,
1479
+ sessionId: this.sessionId,
1468
1480
  url: window.location.href,
1469
1481
  referrer: document.referrer,
1470
- user_agent: window.navigator.userAgent,
1471
- screen_width: window.screen.width,
1472
- screen_height: window.screen.height,
1482
+ userAgent: window.navigator.userAgent,
1483
+ screenWidth: window.screen.width,
1484
+ screenHeight: window.screen.height,
1473
1485
  language: window.navigator.language,
1474
1486
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
1475
- event_type: eventType,
1476
- event_name: eventName,
1477
- event_data: data,
1478
- // 3. Attach Performance Data (Rust: Option<PerformanceMetrics>)
1487
+ eventType,
1488
+ eventName,
1489
+ eventData: data,
1479
1490
  performance: perfMetrics || void 0,
1480
- // 4. Attach Hardware Signals for Anomaly Detection (Rust: DeviceData)
1481
1491
  context: {
1482
1492
  device: {
1483
- hardware_concurrency: entropy.hardware_concurrency,
1484
- device_memory: entropy.device_memory,
1485
- pixel_ratio: entropy.pixel_ratio,
1486
- canvas_fingerprint: entropy.canvas_hash,
1493
+ hardwareConcurrency: entropy.hardware_concurrency,
1494
+ // Match Rust sub-struct too if needed
1495
+ deviceMemory: entropy.device_memory,
1496
+ pixelRatio: entropy.pixel_ratio,
1497
+ canvasFingerprint: entropy.canvas_hash,
1487
1498
  platform: entropy.platform
1488
1499
  },
1489
- visitor_id_local: this.visitorId
1490
- // Hint for stitching
1500
+ visitorIdLocal: this.visitorId
1491
1501
  },
1492
- client_timestamp: (/* @__PURE__ */ new Date()).toISOString()
1502
+ clientTimestamp: (/* @__PURE__ */ new Date()).toISOString()
1493
1503
  };
1494
1504
  await eventStorage.enqueue(payload);
1495
1505
  const count = await eventStorage.count();
@@ -1707,9 +1717,9 @@ var AnalyticsEngine = class {
1707
1717
  const config = this.tracker["config"];
1708
1718
  const endpoint = `${config.analyticsUrl}/api/${type}`;
1709
1719
  const payload = {
1710
- project_id: this.tracker["config"].projectId,
1711
- session_id: this.tracker.getSession(),
1712
- visitor_id: this.tracker.visitorId,
1720
+ projectId: config.projectId,
1721
+ sessionId: this.tracker.getSession(),
1722
+ visitorId: this.tracker.visitorId,
1713
1723
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1714
1724
  ...data
1715
1725
  };
@@ -1861,7 +1871,13 @@ import React2, { createContext as createContext2, useEffect as useEffect2, useRe
1861
1871
  import { usePathname, useSearchParams } from "next/navigation";
1862
1872
 
1863
1873
  // src/auth/context.tsx
1864
- import { createContext, useContext, useEffect, useState, useCallback } from "react";
1874
+ import {
1875
+ createContext,
1876
+ useContext,
1877
+ useEffect,
1878
+ useState,
1879
+ useCallback
1880
+ } from "react";
1865
1881
  import { jsx } from "react/jsx-runtime";
1866
1882
  var AuthContext = createContext(null);
1867
1883
  var AuthProvider = ({
@@ -1957,7 +1973,10 @@ var AuthProvider = ({
1957
1973
  const logout = async () => {
1958
1974
  setIsLoading(true);
1959
1975
  try {
1960
- await fetch(`${AUTH_BASE}/logout`, { method: "POST", headers: getHeaders(config) });
1976
+ await fetch(`${AUTH_BASE}/logout`, {
1977
+ method: "POST",
1978
+ headers: getHeaders(config)
1979
+ });
1961
1980
  } catch (e) {
1962
1981
  console.warn("Logout network error", e);
1963
1982
  } finally {
@@ -1994,17 +2013,23 @@ var AuthProvider = ({
1994
2013
  });
1995
2014
  if (!res.ok) throw await parseError(res);
1996
2015
  };
1997
- return /* @__PURE__ */ jsx(AuthContext.Provider, { value: {
1998
- user,
1999
- isLoading,
2000
- error,
2001
- isAuthenticated: !!user,
2002
- login,
2003
- register,
2004
- logout,
2005
- updateProfile,
2006
- requestPasswordReset
2007
- }, children });
2016
+ return /* @__PURE__ */ jsx(
2017
+ AuthContext.Provider,
2018
+ {
2019
+ value: {
2020
+ user,
2021
+ isLoading,
2022
+ error,
2023
+ isAuthenticated: !!user,
2024
+ login,
2025
+ register,
2026
+ logout,
2027
+ updateProfile,
2028
+ requestPasswordReset
2029
+ },
2030
+ children
2031
+ }
2032
+ );
2008
2033
  };
2009
2034
  var useNexusAuth = () => {
2010
2035
  const context = useContext(AuthContext);
@@ -2016,8 +2041,10 @@ var useNexusAuth = () => {
2016
2041
  function getHeaders(config) {
2017
2042
  return {
2018
2043
  "Content-Type": "application/json",
2019
- "x-nexus-project": config.projectId
2020
- // Note: We do NOT send the Master API Key here.
2044
+ "x-nexus-project": config.projectId,
2045
+ Authorization: `Bearer ${config.apiKey}`
2046
+ // 👈 CRITICAL: Send the nx_pk_ key
2047
+ // Note: We do NOT send the Master API Key here.
2021
2048
  // This is client-side. The backend uses Cookies or public tokens.
2022
2049
  };
2023
2050
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nexushub/client",
3
3
  "private": false,
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "description": "The God-Tier NexusHub SDK",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",