@palbase/web 1.10.0 → 2.0.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.
@@ -1,7 +1,7 @@
1
- import { P as PalbeConfig, d as PalbeRuntime } from './analytics-facade-B7vujhPJ.cjs';
2
- export { e as buildRuntime } from './analytics-facade-B7vujhPJ.cjs';
1
+ import { P as PalbeConfig, d as PalbeRuntime } from './analytics-facade-ovP0pF2P.cjs';
2
+ export { e as buildRuntime } from './analytics-facade-ovP0pF2P.cjs';
3
3
  import { B as BackendError } from './errors-fDoNdTrJ.cjs';
4
- export { P as PB, c as createBoundClient } from './pb-6965XULp.cjs';
4
+ export { P as PB, c as createBoundClient } from './pb-DDM_mCQB.cjs';
5
5
  import 'livekit-client';
6
6
  import './storage-BPaeSG8K.cjs';
7
7
  import './pooled-flags-Bwq4usn0.js';
@@ -1,7 +1,7 @@
1
- import { P as PalbeConfig, d as PalbeRuntime } from './analytics-facade-CHh5EGC2.js';
2
- export { e as buildRuntime } from './analytics-facade-CHh5EGC2.js';
1
+ import { P as PalbeConfig, d as PalbeRuntime } from './analytics-facade-DMtGDGfd.js';
2
+ export { e as buildRuntime } from './analytics-facade-DMtGDGfd.js';
3
3
  import { B as BackendError } from './errors-fDoNdTrJ.js';
4
- export { P as PB, c as createBoundClient } from './pb-ChNq987M.js';
4
+ export { P as PB, c as createBoundClient } from './pb-CvpcQero.js';
5
5
  import 'livekit-client';
6
6
  import './storage-BPaeSG8K.js';
7
7
  import './pooled-flags-Bwq4usn0.js';
package/dist/internal.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  createBoundClient,
7
7
  getRuntime,
8
8
  onConfigured
9
- } from "./chunk-4ZJHHXD3.js";
9
+ } from "./chunk-V6VTX65P.js";
10
10
  import "./chunk-PZ5AY32C.js";
11
11
  export {
12
12
  __configure,
@@ -443,12 +443,6 @@ async function palbeRequest(rt, method, path, spec = {}) {
443
443
  if (MUTATING.has(method) && !callerHasKey) {
444
444
  headers["Idempotency-Key"] = crypto.randomUUID();
445
445
  }
446
- if (rt.appIdentifier !== "") {
447
- const callerHasBundle = Object.keys(headers).some(
448
- (k) => k.toLowerCase() === "x-palbase-bundle"
449
- );
450
- if (!callerHasBundle) headers["X-Palbase-Bundle"] = rt.appIdentifier;
451
- }
452
446
  const attempt = async () => {
453
447
  try {
454
448
  return await rt.http.request(method, path, {
@@ -1237,23 +1231,6 @@ var PalbeAnalytics = class {
1237
1231
  }
1238
1232
  };
1239
1233
 
1240
- // src/app-config.ts
1241
- function loadAppConfig(raw) {
1242
- if (typeof raw !== "object" || raw === null) {
1243
- throw new Error("app_config_invalid: expected a JSON object");
1244
- }
1245
- const r = raw;
1246
- const str = (k) => typeof r[k] === "string" ? r[k] : "";
1247
- return { appId: str("app_id"), identifier: str("identifier"), envPreset: str("env_preset") };
1248
- }
1249
- function assertOriginMatches(cfg, runtimeOrigin) {
1250
- if (cfg.identifier === "") return;
1251
- if (runtimeOrigin === "") return;
1252
- if (runtimeOrigin !== cfg.identifier) {
1253
- throw new Error(`app_config_mismatch: expected origin ${cfg.identifier}, got ${runtimeOrigin}`);
1254
- }
1255
- }
1256
-
1257
1234
  // src/auth-wire.ts
1258
1235
  function asWireAuthResult(raw) {
1259
1236
  if (typeof raw !== "object" || raw === null) return null;
@@ -8063,6 +8040,14 @@ function observeWebVitals(record) {
8063
8040
  };
8064
8041
  }
8065
8042
 
8043
+ // src/runtime-metadata.ts
8044
+ var APP_METADATA_HEADER = "X-Palbase-Bundle";
8045
+ function applyBrowserOriginHeader(headers) {
8046
+ if (Object.keys(headers).some((key) => key.toLowerCase() === "x-palbase-bundle")) return;
8047
+ const origin = typeof window !== "undefined" && typeof window.location !== "undefined" ? window.location.origin : "";
8048
+ if (origin !== "") headers[APP_METADATA_HEADER] = origin;
8049
+ }
8050
+
8066
8051
  // src/realtime/anon-token.ts
8067
8052
  var REFRESH_SKEW_MS = 6e4;
8068
8053
  var AnonTokenProvider = class {
@@ -8105,11 +8090,16 @@ var AnonTokenProvider = class {
8105
8090
  */
8106
8091
  async mint() {
8107
8092
  const base = this.rt.config.url.replace(/\/+$/, "");
8093
+ const headers = {
8094
+ apikey: this.rt.config.apiKey,
8095
+ ...this.rt.config.headers
8096
+ };
8097
+ applyBrowserOriginHeader(headers);
8108
8098
  let response;
8109
8099
  try {
8110
8100
  response = await fetch(`${base}/auth/anonymous`, {
8111
8101
  method: "POST",
8112
- headers: { apikey: this.rt.config.apiKey }
8102
+ headers
8113
8103
  });
8114
8104
  } catch (e) {
8115
8105
  throw new BackendError("network", {
@@ -8750,17 +8740,15 @@ function defaultSessionStorage(key) {
8750
8740
  }
8751
8741
 
8752
8742
  // src/version.ts
8753
- var VERSION = "1.10.0";
8743
+ var VERSION = "2.0.0";
8754
8744
 
8755
8745
  // src/runtime.ts
8756
8746
  function buildRuntime(config) {
8757
- const appIdentifier = config.identifier ?? "";
8758
- const runtimeOrigin = typeof window !== "undefined" && typeof window.location !== "undefined" ? window.location.origin : "";
8759
- assertOriginMatches(loadAppConfig({ identifier: appIdentifier }), runtimeOrigin);
8760
8747
  const http = new HttpClient(config.apiKey, {
8761
8748
  url: config.url,
8762
8749
  headers: { "X-Client-Info": `palbe-web/${VERSION}`, ...config.headers }
8763
8750
  });
8751
+ http.addInterceptor(({ headers }) => applyBrowserOriginHeader(headers));
8764
8752
  const tokenManager = new TokenManager();
8765
8753
  http.tokenManager = tokenManager;
8766
8754
  const authClient = new AuthClient(http, tokenManager);
@@ -8809,7 +8797,6 @@ function buildRuntime(config) {
8809
8797
  let perf;
8810
8798
  const rt = {
8811
8799
  config,
8812
- appIdentifier,
8813
8800
  http,
8814
8801
  tokenManager,
8815
8802
  authClient,