@palbase/web 1.7.0 → 1.8.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/{analytics-facade-CQJ3b-zB.d.ts → analytics-facade-CgURkjpP.d.ts} +173 -1
- package/dist/{analytics-facade-9GPSKnVG.d.cts → analytics-facade-DfJ420F5.d.cts} +173 -1
- package/dist/{chunk-QRO632M7.js → chunk-AWVNDAMG.js} +601 -17
- package/dist/chunk-AWVNDAMG.js.map +1 -0
- package/dist/index.cjs +69 -13
- 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 +600 -16
- 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 +590 -13
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/index.cjs +596 -13
- 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-D4HyUbpb.d.cts → pb-BwQwp411.d.cts} +9 -1
- package/dist/{pb-BvfCJZux.d.ts → pb-C1v9ErPy.d.ts} +9 -1
- package/dist/react/index.cjs +69 -13
- 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 +1 -1
- package/dist/chunk-QRO632M7.js.map +0 -1
package/dist/next/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { P as PB } from '../pb-
|
|
3
|
-
import '../analytics-facade-
|
|
2
|
+
import { P as PB } from '../pb-BwQwp411.cjs';
|
|
3
|
+
import '../analytics-facade-DfJ420F5.cjs';
|
|
4
4
|
import 'livekit-client';
|
|
5
5
|
import '../storage-BPaeSG8K.cjs';
|
|
6
6
|
import './pooled-flags-Bwq4usn0.js';
|
package/dist/next/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import { P as PB } from '../pb-
|
|
3
|
-
import '../analytics-facade-
|
|
2
|
+
import { P as PB } from '../pb-C1v9ErPy.js';
|
|
3
|
+
import '../analytics-facade-CgURkjpP.js';
|
|
4
4
|
import 'livekit-client';
|
|
5
5
|
import '../storage-BPaeSG8K.js';
|
|
6
6
|
import './pooled-flags-Bwq4usn0.js';
|
package/dist/next/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PalbeAuth, w as PalbeFlags, z as PalbeRealtime, P as PalbeAnalytics, u as PalbeCalls, x as PalbeMessaging, T as PalbeRuntime } from './analytics-facade-
|
|
1
|
+
import { t as PalbeAuth, w as PalbeFlags, z as PalbeRealtime, P as PalbeAnalytics, u as PalbeCalls, x as PalbeMessaging, W as PalbePerf, T as PalbeRuntime } from './analytics-facade-DfJ420F5.cjs';
|
|
2
2
|
|
|
3
3
|
interface CallOptions {
|
|
4
4
|
headers?: Record<string, string>;
|
|
@@ -42,6 +42,14 @@ interface PB {
|
|
|
42
42
|
readonly analytics: PalbeAnalytics;
|
|
43
43
|
readonly calls: PalbeCalls;
|
|
44
44
|
readonly messaging: PalbeMessaging;
|
|
45
|
+
/** The PalPerf surface: custom traces (`startTrace`) + the buffered flush of
|
|
46
|
+
* network/app-start/custom items. `pb.perf.record(...)` is also how the
|
|
47
|
+
* runtime feeds the cold-start measurement in. */
|
|
48
|
+
readonly perf: PalbePerf;
|
|
49
|
+
/** Mark (or unmark) this client's traffic as test — flips the facade's flag
|
|
50
|
+
* so every subsequent perf flush carries `X-Palbase-Test-Device: 1` (the
|
|
51
|
+
* SAME header the iOS SDK sends; the server reads it → `is_test_traffic`). */
|
|
52
|
+
setTestDevice(on: boolean): void;
|
|
45
53
|
}
|
|
46
54
|
declare const pb: PB;
|
|
47
55
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PalbeAuth, w as PalbeFlags, z as PalbeRealtime, P as PalbeAnalytics, u as PalbeCalls, x as PalbeMessaging, T as PalbeRuntime } from './analytics-facade-
|
|
1
|
+
import { t as PalbeAuth, w as PalbeFlags, z as PalbeRealtime, P as PalbeAnalytics, u as PalbeCalls, x as PalbeMessaging, W as PalbePerf, T as PalbeRuntime } from './analytics-facade-CgURkjpP.js';
|
|
2
2
|
|
|
3
3
|
interface CallOptions {
|
|
4
4
|
headers?: Record<string, string>;
|
|
@@ -42,6 +42,14 @@ interface PB {
|
|
|
42
42
|
readonly analytics: PalbeAnalytics;
|
|
43
43
|
readonly calls: PalbeCalls;
|
|
44
44
|
readonly messaging: PalbeMessaging;
|
|
45
|
+
/** The PalPerf surface: custom traces (`startTrace`) + the buffered flush of
|
|
46
|
+
* network/app-start/custom items. `pb.perf.record(...)` is also how the
|
|
47
|
+
* runtime feeds the cold-start measurement in. */
|
|
48
|
+
readonly perf: PalbePerf;
|
|
49
|
+
/** Mark (or unmark) this client's traffic as test — flips the facade's flag
|
|
50
|
+
* so every subsequent perf flush carries `X-Palbase-Test-Device: 1` (the
|
|
51
|
+
* SAME header the iOS SDK sends; the server reads it → `is_test_traffic`). */
|
|
52
|
+
setTestDevice(on: boolean): void;
|
|
45
53
|
}
|
|
46
54
|
declare const pb: PB;
|
|
47
55
|
/**
|
package/dist/react/index.cjs
CHANGED
|
@@ -152,14 +152,47 @@ function unwrap(res) {
|
|
|
152
152
|
return res.data;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
// src/perf/url-redactor.ts
|
|
156
|
+
var ID_SEGMENT = /^(?:\d+|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
157
|
+
var EMAIL_SEGMENT = /(?:@|%40)/i;
|
|
158
|
+
function isSensitiveSegment(seg) {
|
|
159
|
+
return ID_SEGMENT.test(seg) || EMAIL_SEGMENT.test(seg);
|
|
160
|
+
}
|
|
161
|
+
function redactUrl(rawUrl) {
|
|
162
|
+
let path = rawUrl;
|
|
163
|
+
try {
|
|
164
|
+
path = new URL(rawUrl).pathname;
|
|
165
|
+
} catch {
|
|
166
|
+
const q = path.indexOf("?");
|
|
167
|
+
if (q >= 0) path = path.slice(0, q);
|
|
168
|
+
}
|
|
169
|
+
return path.split("/").map((seg) => isSensitiveSegment(seg) ? ":id" : seg).join("/");
|
|
170
|
+
}
|
|
171
|
+
|
|
155
172
|
// src/request.ts
|
|
156
173
|
var MUTATING = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
174
|
+
var PERF_EXCLUDED_PREFIX = "/v1/analytics/";
|
|
175
|
+
function isSelfTraced(path) {
|
|
176
|
+
return path.startsWith(PERF_EXCLUDED_PREFIX);
|
|
177
|
+
}
|
|
178
|
+
function nowMs() {
|
|
179
|
+
return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
180
|
+
}
|
|
181
|
+
function isAbort(e) {
|
|
182
|
+
return e instanceof Error && e.name === "AbortError";
|
|
183
|
+
}
|
|
157
184
|
async function palbeRequest(rt, method, path, spec = {}) {
|
|
158
185
|
const headers = { ...spec.headers };
|
|
159
186
|
const callerHasKey = Object.keys(headers).some((k) => k.toLowerCase() === "idempotency-key");
|
|
160
187
|
if (MUTATING.has(method) && !callerHasKey) {
|
|
161
188
|
headers["Idempotency-Key"] = crypto.randomUUID();
|
|
162
189
|
}
|
|
190
|
+
if (rt.appIdentifier !== "") {
|
|
191
|
+
const callerHasBundle = Object.keys(headers).some(
|
|
192
|
+
(k) => k.toLowerCase() === "x-palbase-bundle"
|
|
193
|
+
);
|
|
194
|
+
if (!callerHasBundle) headers["X-Palbase-Bundle"] = rt.appIdentifier;
|
|
195
|
+
}
|
|
163
196
|
const attempt = async () => {
|
|
164
197
|
try {
|
|
165
198
|
return await rt.http.request(method, path, {
|
|
@@ -172,21 +205,38 @@ async function palbeRequest(rt, method, path, spec = {}) {
|
|
|
172
205
|
throw pe ? fromPalbaseError(pe) : e;
|
|
173
206
|
}
|
|
174
207
|
};
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
208
|
+
const traced = !isSelfTraced(path) && rt.perf !== void 0;
|
|
209
|
+
const startedAt = traced ? nowMs() : 0;
|
|
210
|
+
let recorded = false;
|
|
211
|
+
const record = (status) => {
|
|
212
|
+
if (!traced || recorded) return;
|
|
213
|
+
recorded = true;
|
|
214
|
+
rt.perf.recordNetwork(method, redactUrl(path), status, nowMs() - startedAt);
|
|
215
|
+
};
|
|
216
|
+
let res;
|
|
217
|
+
try {
|
|
218
|
+
res = await attempt();
|
|
219
|
+
if (res.error?.status === 401 && rt.tokenManager.getRefreshToken() && rt.tokenManager.refreshFunction) {
|
|
220
|
+
try {
|
|
221
|
+
await rt.tokenManager.refreshSession();
|
|
222
|
+
} catch (refreshErr) {
|
|
223
|
+
const pe = asPalbaseError(refreshErr);
|
|
224
|
+
const status = pe?.status ?? 0;
|
|
225
|
+
if (status === 400 || status === 401 || status === 403) {
|
|
226
|
+
rt.tokenManager.clearSession();
|
|
227
|
+
record(res.error.status);
|
|
228
|
+
throw fromPalbaseError(res.error);
|
|
229
|
+
}
|
|
230
|
+
record(pe?.status ?? 0);
|
|
231
|
+
throw pe ? fromPalbaseError(pe) : refreshErr;
|
|
185
232
|
}
|
|
186
|
-
|
|
233
|
+
res = await attempt();
|
|
187
234
|
}
|
|
188
|
-
|
|
235
|
+
} catch (e) {
|
|
236
|
+
if (!isAbort(e)) record(asPalbaseError(e)?.status ?? 0);
|
|
237
|
+
throw e;
|
|
189
238
|
}
|
|
239
|
+
record(res.error?.status ?? 200);
|
|
190
240
|
return unwrap(res);
|
|
191
241
|
}
|
|
192
242
|
|
|
@@ -297,7 +347,7 @@ function getNamespace(name) {
|
|
|
297
347
|
}
|
|
298
348
|
|
|
299
349
|
// src/version.ts
|
|
300
|
-
var VERSION = "1.
|
|
350
|
+
var VERSION = "1.8.0";
|
|
301
351
|
|
|
302
352
|
// src/call.ts
|
|
303
353
|
async function callEndpoint(resolveRt, name, input, options) {
|
|
@@ -476,6 +526,12 @@ function createClientProxy(resolveRt, nsAccessor) {
|
|
|
476
526
|
},
|
|
477
527
|
get messaging() {
|
|
478
528
|
return resolveRt().messaging;
|
|
529
|
+
},
|
|
530
|
+
get perf() {
|
|
531
|
+
return resolveRt().perf;
|
|
532
|
+
},
|
|
533
|
+
setTestDevice(on) {
|
|
534
|
+
resolveRt().perf.setTestDevice(on);
|
|
479
535
|
}
|
|
480
536
|
};
|
|
481
537
|
return new Proxy(base, {
|