@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.
- package/README.md +3 -2
- package/dist/{analytics-facade-CHh5EGC2.d.ts → analytics-facade-DMtGDGfd.d.ts} +2 -18
- package/dist/{analytics-facade-B7vujhPJ.d.cts → analytics-facade-ovP0pF2P.d.cts} +2 -18
- package/dist/{chunk-4ZJHHXD3.js → chunk-V6VTX65P.js} +20 -31
- package/dist/chunk-V6VTX65P.js.map +1 -0
- package/dist/gen/cli.cjs +20 -12
- package/dist/gen/cli.cjs.map +1 -1
- package/dist/gen/cli.js +20 -12
- package/dist/gen/cli.js.map +1 -1
- package/dist/index.cjs +18 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/internal.cjs +19 -30
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +3 -3
- package/dist/internal.d.ts +3 -3
- package/dist/internal.js +1 -1
- package/dist/next/client.cjs +16 -29
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/index.cjs +19 -30
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +2 -2
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +1 -1
- package/dist/{pb-ChNq987M.d.ts → pb-CvpcQero.d.ts} +1 -1
- package/dist/{pb-6965XULp.d.cts → pb-DDM_mCQB.d.cts} +1 -1
- package/dist/react/index.cjs +12 -8
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-4ZJHHXD3.js.map +0 -1
package/dist/next/client.js
CHANGED
package/dist/next/index.cjs
CHANGED
|
@@ -566,12 +566,6 @@ async function palbeRequest(rt, method, path, spec = {}) {
|
|
|
566
566
|
if (MUTATING.has(method) && !callerHasKey) {
|
|
567
567
|
headers["Idempotency-Key"] = crypto.randomUUID();
|
|
568
568
|
}
|
|
569
|
-
if (rt.appIdentifier !== "") {
|
|
570
|
-
const callerHasBundle = Object.keys(headers).some(
|
|
571
|
-
(k) => k.toLowerCase() === "x-palbase-bundle"
|
|
572
|
-
);
|
|
573
|
-
if (!callerHasBundle) headers["X-Palbase-Bundle"] = rt.appIdentifier;
|
|
574
|
-
}
|
|
575
569
|
const attempt = async () => {
|
|
576
570
|
try {
|
|
577
571
|
return await rt.http.request(method, path, {
|
|
@@ -1465,23 +1459,6 @@ var PalbeAnalytics = class {
|
|
|
1465
1459
|
}
|
|
1466
1460
|
};
|
|
1467
1461
|
|
|
1468
|
-
// src/app-config.ts
|
|
1469
|
-
function loadAppConfig(raw) {
|
|
1470
|
-
if (typeof raw !== "object" || raw === null) {
|
|
1471
|
-
throw new Error("app_config_invalid: expected a JSON object");
|
|
1472
|
-
}
|
|
1473
|
-
const r = raw;
|
|
1474
|
-
const str = (k) => typeof r[k] === "string" ? r[k] : "";
|
|
1475
|
-
return { appId: str("app_id"), identifier: str("identifier"), envPreset: str("env_preset") };
|
|
1476
|
-
}
|
|
1477
|
-
function assertOriginMatches(cfg, runtimeOrigin) {
|
|
1478
|
-
if (cfg.identifier === "") return;
|
|
1479
|
-
if (runtimeOrigin === "") return;
|
|
1480
|
-
if (runtimeOrigin !== cfg.identifier) {
|
|
1481
|
-
throw new Error(`app_config_mismatch: expected origin ${cfg.identifier}, got ${runtimeOrigin}`);
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
1462
|
// src/auth-facade.ts
|
|
1486
1463
|
function mapWireUser(raw) {
|
|
1487
1464
|
return {
|
|
@@ -8278,6 +8255,14 @@ function observeWebVitals(record) {
|
|
|
8278
8255
|
};
|
|
8279
8256
|
}
|
|
8280
8257
|
|
|
8258
|
+
// src/runtime-metadata.ts
|
|
8259
|
+
var APP_METADATA_HEADER = "X-Palbase-Bundle";
|
|
8260
|
+
function applyBrowserOriginHeader(headers) {
|
|
8261
|
+
if (Object.keys(headers).some((key) => key.toLowerCase() === "x-palbase-bundle")) return;
|
|
8262
|
+
const origin = typeof window !== "undefined" && typeof window.location !== "undefined" ? window.location.origin : "";
|
|
8263
|
+
if (origin !== "") headers[APP_METADATA_HEADER] = origin;
|
|
8264
|
+
}
|
|
8265
|
+
|
|
8281
8266
|
// src/realtime/anon-token.ts
|
|
8282
8267
|
var REFRESH_SKEW_MS = 6e4;
|
|
8283
8268
|
var AnonTokenProvider = class {
|
|
@@ -8320,11 +8305,16 @@ var AnonTokenProvider = class {
|
|
|
8320
8305
|
*/
|
|
8321
8306
|
async mint() {
|
|
8322
8307
|
const base = this.rt.config.url.replace(/\/+$/, "");
|
|
8308
|
+
const headers = {
|
|
8309
|
+
apikey: this.rt.config.apiKey,
|
|
8310
|
+
...this.rt.config.headers
|
|
8311
|
+
};
|
|
8312
|
+
applyBrowserOriginHeader(headers);
|
|
8323
8313
|
let response;
|
|
8324
8314
|
try {
|
|
8325
8315
|
response = await fetch(`${base}/auth/anonymous`, {
|
|
8326
8316
|
method: "POST",
|
|
8327
|
-
headers
|
|
8317
|
+
headers
|
|
8328
8318
|
});
|
|
8329
8319
|
} catch (e) {
|
|
8330
8320
|
throw new BackendError("network", {
|
|
@@ -8965,17 +8955,15 @@ function defaultSessionStorage(key) {
|
|
|
8965
8955
|
}
|
|
8966
8956
|
|
|
8967
8957
|
// src/version.ts
|
|
8968
|
-
var VERSION = "
|
|
8958
|
+
var VERSION = "2.0.0";
|
|
8969
8959
|
|
|
8970
8960
|
// src/runtime.ts
|
|
8971
8961
|
function buildRuntime(config) {
|
|
8972
|
-
const appIdentifier = config.identifier ?? "";
|
|
8973
|
-
const runtimeOrigin = typeof window !== "undefined" && typeof window.location !== "undefined" ? window.location.origin : "";
|
|
8974
|
-
assertOriginMatches(loadAppConfig({ identifier: appIdentifier }), runtimeOrigin);
|
|
8975
8962
|
const http = new HttpClient(config.apiKey, {
|
|
8976
8963
|
url: config.url,
|
|
8977
8964
|
headers: { "X-Client-Info": `palbe-web/${VERSION}`, ...config.headers }
|
|
8978
8965
|
});
|
|
8966
|
+
http.addInterceptor(({ headers }) => applyBrowserOriginHeader(headers));
|
|
8979
8967
|
const tokenManager = new TokenManager();
|
|
8980
8968
|
http.tokenManager = tokenManager;
|
|
8981
8969
|
const authClient = new AuthClient(http, tokenManager);
|
|
@@ -9024,7 +9012,6 @@ function buildRuntime(config) {
|
|
|
9024
9012
|
let perf;
|
|
9025
9013
|
const rt = {
|
|
9026
9014
|
config,
|
|
9027
|
-
appIdentifier,
|
|
9028
9015
|
http,
|
|
9029
9016
|
tokenManager,
|
|
9030
9017
|
authClient,
|
|
@@ -9183,7 +9170,9 @@ async function buildHeaders(rt, extra) {
|
|
|
9183
9170
|
if (token) headers.Authorization = `Bearer ${token}`;
|
|
9184
9171
|
const callerHasKey = Object.keys(extra ?? {}).some((k) => k.toLowerCase() === "idempotency-key");
|
|
9185
9172
|
if (!callerHasKey) headers["Idempotency-Key"] = crypto.randomUUID();
|
|
9186
|
-
|
|
9173
|
+
const merged = { ...headers, ...extra };
|
|
9174
|
+
applyBrowserOriginHeader(merged);
|
|
9175
|
+
return merged;
|
|
9187
9176
|
}
|
|
9188
9177
|
function buildForm(options) {
|
|
9189
9178
|
const form = new FormData();
|