@palbase/web 4.0.1 → 5.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 +20 -3
- package/dist/{analytics-facade-DwOtlXPP.d.cts → analytics-facade-CaluA4bW.d.cts} +26 -1
- package/dist/{analytics-facade-Nk6J9Ncm.d.ts → analytics-facade-Cp3d4QI-.d.ts} +26 -1
- package/dist/chunk-BNAGRUIQ.js +381 -0
- package/dist/chunk-BNAGRUIQ.js.map +1 -0
- package/dist/{chunk-NXEPAEF5.js → chunk-CFDU23TB.js} +3 -3
- package/dist/chunk-CFDU23TB.js.map +1 -0
- package/dist/chunk-OWLTZG2V.js +24 -0
- package/dist/chunk-OWLTZG2V.js.map +1 -0
- package/dist/{chunk-TGDS6VMT.js → chunk-XTQXFZUP.js} +68 -376
- package/dist/chunk-XTQXFZUP.js.map +1 -0
- package/dist/gen/cli.cjs +5 -5
- package/dist/gen/cli.cjs.map +1 -1
- package/dist/gen/cli.js +5 -5
- package/dist/gen/cli.js.map +1 -1
- package/dist/index.cjs +55 -3
- 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 +6 -4
- package/dist/internal.cjs +57 -5
- 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 +3 -2
- package/dist/next/client.cjs +57 -5
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +3 -2
- package/dist/next/client.js.map +1 -1
- package/dist/next/index.cjs +61 -93
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +4 -64
- package/dist/next/index.d.ts +4 -64
- package/dist/next/index.js +9 -103
- package/dist/next/index.js.map +1 -1
- package/dist/next/middleware.cjs +263 -0
- package/dist/next/middleware.cjs.map +1 -0
- package/dist/next/middleware.d.cts +101 -0
- package/dist/next/middleware.d.ts +101 -0
- package/dist/next/middleware.js +107 -0
- package/dist/next/middleware.js.map +1 -0
- package/dist/{pb-FG_nV7NR.d.ts → pb-DUK5qy81.d.ts} +1 -1
- package/dist/{pb-C9v5dEO6.d.cts → pb-DvV6ftmf.d.cts} +1 -1
- package/dist/react/index.cjs +10 -2
- 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 +3 -2
- package/dist/react/index.js.map +1 -1
- package/package.json +11 -1
- package/dist/chunk-NXEPAEF5.js.map +0 -1
- package/dist/chunk-TGDS6VMT.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { f as AnalyticsProperties, g as AuthChangeEvent, h as AuthState, i as AuthSuccess, A as AuthUser, j as Call, k as CallChangeCallback, l as CallParticipant, m as CallState, C as Chat, n as ChatBackend, o as ChatDraft, p as ChatKind, b as ChatMember, c as ChatMessage, q as ChatMessageKind, r as ChatRole, s as ChatState, t as CommsPrefs, F as FlagsView, M as MagicLinkResult, u as MentionRange, v as MessageDirection, N as NotifyScope, O as OAuthExchangeResult, w as PalbeAnalytics, x as PalbeAuth, y as PalbeCalls, P as PalbeConfig, z as PalbeFlags, B as PalbeMessaging, D as PalbeOAuthConfig, E as PalbeRealtime, G as PresenceState, H as RealtimeChannel, R as RealtimeConnectionState, I as RealtimeHandler, a as RealtimePayload, J as RealtimeStatus, K as RealtimeStatusSnapshot, L as RealtimeSubscription, Q as ResolvedMention, S as ResolvedReply, T as SentReceipt, U as UnreadView, V as Unsubscribe } from './analytics-facade-
|
|
1
|
+
export { f as AnalyticsProperties, g as AuthChangeEvent, h as AuthState, i as AuthSuccess, A as AuthUser, j as Call, k as CallChangeCallback, l as CallParticipant, m as CallState, C as Chat, n as ChatBackend, o as ChatDraft, p as ChatKind, b as ChatMember, c as ChatMessage, q as ChatMessageKind, r as ChatRole, s as ChatState, t as CommsPrefs, F as FlagsView, M as MagicLinkResult, u as MentionRange, v as MessageDirection, N as NotifyScope, O as OAuthExchangeResult, w as PalbeAnalytics, x as PalbeAuth, y as PalbeCalls, P as PalbeConfig, z as PalbeFlags, B as PalbeMessaging, D as PalbeOAuthConfig, E as PalbeRealtime, G as PresenceState, H as RealtimeChannel, R as RealtimeConnectionState, I as RealtimeHandler, a as RealtimePayload, J as RealtimeStatus, K as RealtimeStatusSnapshot, L as RealtimeSubscription, Q as ResolvedMention, S as ResolvedReply, T as SentReceipt, U as UnreadView, V as Unsubscribe } from './analytics-facade-CaluA4bW.cjs';
|
|
2
2
|
export { B as BackendError, a as BackendErrorKind, F as FieldError, i as isBackendError } from './errors-fDoNdTrJ.cjs';
|
|
3
|
-
export { C as CallOptions, P as PB, U as UploadOptions, a as UploadProgress, p as pb } from './pb-
|
|
3
|
+
export { C as CallOptions, P as PB, U as UploadOptions, a as UploadProgress, p as pb } from './pb-DvV6ftmf.cjs';
|
|
4
4
|
export { P as PersistedSession, S as SessionStorageAdapter, l as localStorageSessionStorage, m as memorySessionStorage } from './storage-BPaeSG8K.cjs';
|
|
5
5
|
export { F as FlagValue } from './pooled-flags-4GtDtsiu.js';
|
|
6
6
|
|
|
@@ -206,6 +206,6 @@ interface MlsGlue {
|
|
|
206
206
|
*/
|
|
207
207
|
declare function initMls(): Promise<MlsGlue>;
|
|
208
208
|
|
|
209
|
-
declare const VERSION = "
|
|
209
|
+
declare const VERSION = "5.0.0";
|
|
210
210
|
|
|
211
211
|
export { VERSION, initMls };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { f as AnalyticsProperties, g as AuthChangeEvent, h as AuthState, i as AuthSuccess, A as AuthUser, j as Call, k as CallChangeCallback, l as CallParticipant, m as CallState, C as Chat, n as ChatBackend, o as ChatDraft, p as ChatKind, b as ChatMember, c as ChatMessage, q as ChatMessageKind, r as ChatRole, s as ChatState, t as CommsPrefs, F as FlagsView, M as MagicLinkResult, u as MentionRange, v as MessageDirection, N as NotifyScope, O as OAuthExchangeResult, w as PalbeAnalytics, x as PalbeAuth, y as PalbeCalls, P as PalbeConfig, z as PalbeFlags, B as PalbeMessaging, D as PalbeOAuthConfig, E as PalbeRealtime, G as PresenceState, H as RealtimeChannel, R as RealtimeConnectionState, I as RealtimeHandler, a as RealtimePayload, J as RealtimeStatus, K as RealtimeStatusSnapshot, L as RealtimeSubscription, Q as ResolvedMention, S as ResolvedReply, T as SentReceipt, U as UnreadView, V as Unsubscribe } from './analytics-facade-
|
|
1
|
+
export { f as AnalyticsProperties, g as AuthChangeEvent, h as AuthState, i as AuthSuccess, A as AuthUser, j as Call, k as CallChangeCallback, l as CallParticipant, m as CallState, C as Chat, n as ChatBackend, o as ChatDraft, p as ChatKind, b as ChatMember, c as ChatMessage, q as ChatMessageKind, r as ChatRole, s as ChatState, t as CommsPrefs, F as FlagsView, M as MagicLinkResult, u as MentionRange, v as MessageDirection, N as NotifyScope, O as OAuthExchangeResult, w as PalbeAnalytics, x as PalbeAuth, y as PalbeCalls, P as PalbeConfig, z as PalbeFlags, B as PalbeMessaging, D as PalbeOAuthConfig, E as PalbeRealtime, G as PresenceState, H as RealtimeChannel, R as RealtimeConnectionState, I as RealtimeHandler, a as RealtimePayload, J as RealtimeStatus, K as RealtimeStatusSnapshot, L as RealtimeSubscription, Q as ResolvedMention, S as ResolvedReply, T as SentReceipt, U as UnreadView, V as Unsubscribe } from './analytics-facade-Cp3d4QI-.js';
|
|
2
2
|
export { B as BackendError, a as BackendErrorKind, F as FieldError, i as isBackendError } from './errors-fDoNdTrJ.js';
|
|
3
|
-
export { C as CallOptions, P as PB, U as UploadOptions, a as UploadProgress, p as pb } from './pb-
|
|
3
|
+
export { C as CallOptions, P as PB, U as UploadOptions, a as UploadProgress, p as pb } from './pb-DUK5qy81.js';
|
|
4
4
|
export { P as PersistedSession, S as SessionStorageAdapter, l as localStorageSessionStorage, m as memorySessionStorage } from './storage-BPaeSG8K.js';
|
|
5
5
|
export { F as FlagValue } from './pooled-flags-4GtDtsiu.js';
|
|
6
6
|
|
|
@@ -206,6 +206,6 @@ interface MlsGlue {
|
|
|
206
206
|
*/
|
|
207
207
|
declare function initMls(): Promise<MlsGlue>;
|
|
208
208
|
|
|
209
|
-
declare const VERSION = "
|
|
209
|
+
declare const VERSION = "5.0.0";
|
|
210
210
|
|
|
211
211
|
export { VERSION, initMls };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BackendError,
|
|
3
2
|
PalbeAnalytics,
|
|
4
3
|
PalbeAuth,
|
|
5
4
|
PalbeCalls,
|
|
@@ -9,12 +8,15 @@ import {
|
|
|
9
8
|
RealtimeChannel,
|
|
10
9
|
VERSION,
|
|
11
10
|
initMls,
|
|
12
|
-
isBackendError,
|
|
13
11
|
localStorageSessionStorage,
|
|
14
12
|
memorySessionStorage,
|
|
15
13
|
pb
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import
|
|
14
|
+
} from "./chunk-XTQXFZUP.js";
|
|
15
|
+
import {
|
|
16
|
+
BackendError,
|
|
17
|
+
isBackendError
|
|
18
|
+
} from "./chunk-BNAGRUIQ.js";
|
|
19
|
+
import "./chunk-CFDU23TB.js";
|
|
18
20
|
import "./chunk-PZ5AY32C.js";
|
|
19
21
|
export {
|
|
20
22
|
BackendError,
|
package/dist/internal.cjs
CHANGED
|
@@ -55,7 +55,7 @@ var PalbaseError = class extends Error {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
var PALBASE_DEFAULT_HOST = "api.palbase.studio";
|
|
58
|
-
var API_KEY_RE = /^pb_([a-z0-9]
|
|
58
|
+
var API_KEY_RE = /^pb_([a-z0-9]{4,24})_c[A-Za-z0-9]{20}$/;
|
|
59
59
|
function parseEnvironmentRef(apiKey) {
|
|
60
60
|
return API_KEY_RE.exec(apiKey)?.[1] ?? null;
|
|
61
61
|
}
|
|
@@ -432,6 +432,11 @@ var PERF_EXCLUDED_PREFIX = "/v1/analytics/";
|
|
|
432
432
|
function isSelfTraced(path) {
|
|
433
433
|
return path.startsWith(PERF_EXCLUDED_PREFIX);
|
|
434
434
|
}
|
|
435
|
+
function isSessionKilled(status, code) {
|
|
436
|
+
if (status === 401) return code === "session_revoked";
|
|
437
|
+
if (status === 403) return code === "subject_fenced" || code === "subject_erased";
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
435
440
|
function nowMs() {
|
|
436
441
|
return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
437
442
|
}
|
|
@@ -467,7 +472,7 @@ async function palbeRequest(rt, method, path, spec = {}) {
|
|
|
467
472
|
let res;
|
|
468
473
|
try {
|
|
469
474
|
res = await attempt();
|
|
470
|
-
if (res.error?.status === 401 && rt.tokenManager.getRefreshToken() && rt.tokenManager.refreshFunction) {
|
|
475
|
+
if (res.error?.status === 401 && res.error.code !== "session_revoked" && rt.tokenManager.getRefreshToken() && rt.tokenManager.refreshFunction) {
|
|
471
476
|
try {
|
|
472
477
|
await rt.tokenManager.refreshSession();
|
|
473
478
|
} catch (refreshErr) {
|
|
@@ -487,6 +492,9 @@ async function palbeRequest(rt, method, path, spec = {}) {
|
|
|
487
492
|
if (!isAbort(e)) record(asPalbaseError(e)?.status ?? 0);
|
|
488
493
|
throw e;
|
|
489
494
|
}
|
|
495
|
+
if (res.error && isSessionKilled(res.error.status, res.error.code)) {
|
|
496
|
+
rt.auth.reactiveTeardown();
|
|
497
|
+
}
|
|
490
498
|
record(res.error?.status ?? 200);
|
|
491
499
|
return unwrap(res);
|
|
492
500
|
}
|
|
@@ -1421,7 +1429,7 @@ var PalbeAnalytics = class {
|
|
|
1421
1429
|
};
|
|
1422
1430
|
|
|
1423
1431
|
// src/api-key.ts
|
|
1424
|
-
var PUBLISHABLE_API_KEY_RE = /^pb_([a-z0-9]
|
|
1432
|
+
var PUBLISHABLE_API_KEY_RE = /^pb_([a-z0-9]{4,24})_c[A-Za-z0-9]{20}$/;
|
|
1425
1433
|
function environmentRefFromPublishableApiKey(apiKey) {
|
|
1426
1434
|
const match = PUBLISHABLE_API_KEY_RE.exec(apiKey);
|
|
1427
1435
|
return match ? match[1] ?? "" : "";
|
|
@@ -1468,7 +1476,8 @@ var PalbeAuth = class {
|
|
|
1468
1476
|
if (!this.signedInState) return;
|
|
1469
1477
|
this.signedInState = false;
|
|
1470
1478
|
this.cachedUser = null;
|
|
1471
|
-
const reason = this.signingOut ? "userInitiated" : "sessionExpired";
|
|
1479
|
+
const reason = this.nextSignOutReason ?? (this.signingOut ? "userInitiated" : "sessionExpired");
|
|
1480
|
+
this.nextSignOutReason = null;
|
|
1472
1481
|
this.emitState({ status: "signedOut" });
|
|
1473
1482
|
this.emitEvent({ type: "signedOut", reason });
|
|
1474
1483
|
} else if (event === "TOKEN_REFRESHED") {
|
|
@@ -1481,6 +1490,10 @@ var PalbeAuth = class {
|
|
|
1481
1490
|
rt;
|
|
1482
1491
|
cachedUser = null;
|
|
1483
1492
|
signingOut = false;
|
|
1493
|
+
// Explicit signedOut reason pinned for the NEXT session clear (deleteAccount /
|
|
1494
|
+
// reactiveTeardown set it before clearSession; the SIGNED_OUT handler consumes
|
|
1495
|
+
// it exactly once, then resets to null → normal signOut/expiry split resumes).
|
|
1496
|
+
nextSignOutReason = null;
|
|
1484
1497
|
signingIn = false;
|
|
1485
1498
|
// suppresses AuthClient's TOKEN_REFRESHED during re-signIn
|
|
1486
1499
|
signedInState = false;
|
|
@@ -1528,6 +1541,45 @@ var PalbeAuth = class {
|
|
|
1528
1541
|
this.cachedUser = null;
|
|
1529
1542
|
}
|
|
1530
1543
|
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Self-service account erasure ("right to be forgotten"). Calls palauth
|
|
1546
|
+
* `DELETE /auth/user` (session-authed + fresh re-auth): password users pass
|
|
1547
|
+
* `{ password }`; passwordless/OAuth users rely on a freshly stepped-up
|
|
1548
|
+
* session. On 202 the erasure workflow is durably queued AND every session is
|
|
1549
|
+
* already revoked server-side — so we tear down local state (mirroring
|
|
1550
|
+
* `signOut()`'s clear, minus the pointless `/logout`) and emit
|
|
1551
|
+
* `signedOut{reason:'accountDeleted'}`.
|
|
1552
|
+
*
|
|
1553
|
+
* On 401 `reauth_required` / 503 `not_configured` (or `erasure_unavailable`)
|
|
1554
|
+
* the request throws BEFORE the teardown line, so the local session is left
|
|
1555
|
+
* fully intact — the deletion did not happen and the user is still signed in.
|
|
1556
|
+
*/
|
|
1557
|
+
async deleteAccount(params = {}) {
|
|
1558
|
+
const res = await palbeRequest(this.rt, "DELETE", "/auth/user", {
|
|
1559
|
+
body: params.password ? { password: params.password } : {}
|
|
1560
|
+
});
|
|
1561
|
+
this.nextSignOutReason = "accountDeleted";
|
|
1562
|
+
this.rt.tokenManager.clearSession();
|
|
1563
|
+
this.rt.storage.clear();
|
|
1564
|
+
this.cachedUser = null;
|
|
1565
|
+
return { erasureId: res.erasure_id };
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* @internal — invoked by the transport choke point (`request.ts`), not app code.
|
|
1569
|
+
* Reactive teardown when the server reports the session is gone: a 403
|
|
1570
|
+
* `subject_fenced`/`subject_erased` (subject being erased) or a 401
|
|
1571
|
+
* `session_revoked`. Clears local state and emits
|
|
1572
|
+
* `signedOut{reason:'sessionInvalid'}` exactly once (deduped by
|
|
1573
|
+
* `signedInState`). An ordinary 403 authz denial does NOT reach here —
|
|
1574
|
+
* `request.ts` matches only the exact session-kill codes.
|
|
1575
|
+
*/
|
|
1576
|
+
reactiveTeardown() {
|
|
1577
|
+
if (!this.signedInState) return;
|
|
1578
|
+
this.nextSignOutReason = "sessionInvalid";
|
|
1579
|
+
this.rt.tokenManager.clearSession();
|
|
1580
|
+
this.rt.storage.clear();
|
|
1581
|
+
this.cachedUser = null;
|
|
1582
|
+
}
|
|
1531
1583
|
async getUser() {
|
|
1532
1584
|
const raw = await palbeRequest(this.rt, "GET", "/auth/user");
|
|
1533
1585
|
return mapWireUser(raw);
|
|
@@ -8976,7 +9028,7 @@ function defaultSessionStorage(key) {
|
|
|
8976
9028
|
}
|
|
8977
9029
|
|
|
8978
9030
|
// src/version.ts
|
|
8979
|
-
var VERSION = "
|
|
9031
|
+
var VERSION = "5.0.0";
|
|
8980
9032
|
|
|
8981
9033
|
// src/runtime.ts
|
|
8982
9034
|
function buildRuntime(config) {
|