@palbase/web 5.0.1 → 7.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.
Files changed (45) hide show
  1. package/README.md +15 -15
  2. package/dist/{analytics-facade-Cp3d4QI-.d.ts → analytics-facade-CdTK9Y0s.d.ts} +42 -1
  3. package/dist/{analytics-facade-CaluA4bW.d.cts → analytics-facade-TB-D4ww8.d.cts} +42 -1
  4. package/dist/{chunk-QKFPPZLF.js → chunk-7SNSLY5M.js} +20 -3
  5. package/dist/chunk-7SNSLY5M.js.map +1 -0
  6. package/dist/{chunk-BNAGRUIQ.js → chunk-ACCJV6FV.js} +32 -2
  7. package/dist/chunk-ACCJV6FV.js.map +1 -0
  8. package/dist/{chunk-OWLTZG2V.js → chunk-ZC6Q3GPX.js} +2 -2
  9. package/dist/index.cjs +18 -1
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +3 -3
  12. package/dist/index.d.ts +3 -3
  13. package/dist/index.js +2 -2
  14. package/dist/internal.cjs +49 -2
  15. package/dist/internal.cjs.map +1 -1
  16. package/dist/internal.d.cts +3 -3
  17. package/dist/internal.d.ts +3 -3
  18. package/dist/internal.js +2 -2
  19. package/dist/next/client.cjs +49 -2
  20. package/dist/next/client.cjs.map +1 -1
  21. package/dist/next/client.js +2 -2
  22. package/dist/next/index.cjs +49 -2
  23. package/dist/next/index.cjs.map +1 -1
  24. package/dist/next/index.d.cts +2 -2
  25. package/dist/next/index.d.ts +2 -2
  26. package/dist/next/index.js +3 -3
  27. package/dist/next/{middleware.cjs → proxy.cjs} +11 -11
  28. package/dist/next/proxy.cjs.map +1 -0
  29. package/dist/next/{middleware.d.cts → proxy.d.cts} +32 -31
  30. package/dist/next/{middleware.d.ts → proxy.d.ts} +32 -31
  31. package/dist/next/{middleware.js → proxy.js} +8 -8
  32. package/dist/next/proxy.js.map +1 -0
  33. package/dist/{pb-DUK5qy81.d.ts → pb-B6ZcZy8v.d.ts} +1 -1
  34. package/dist/{pb-DvV6ftmf.d.cts → pb-CiSj4lM3.d.cts} +1 -1
  35. package/dist/react/index.cjs +1 -1
  36. package/dist/react/index.cjs.map +1 -1
  37. package/dist/react/index.d.cts +1 -1
  38. package/dist/react/index.d.ts +1 -1
  39. package/dist/react/index.js +2 -2
  40. package/package.json +8 -8
  41. package/dist/chunk-BNAGRUIQ.js.map +0 -1
  42. package/dist/chunk-QKFPPZLF.js.map +0 -1
  43. package/dist/next/middleware.cjs.map +0 -1
  44. package/dist/next/middleware.js.map +0 -1
  45. /package/dist/{chunk-OWLTZG2V.js.map → chunk-ZC6Q3GPX.js.map} +0 -0
package/README.md CHANGED
@@ -49,10 +49,10 @@ If you forget to import it, every `pb` call throws a guided `BackendError`
49
49
 
50
50
  ## Calling your backend
51
51
 
52
- Codegen turns each backend controller into a typed namespace on `pb`. A
53
- controller method `todos.create` becomes `pb.todos.create(input)`; a top-level
54
- endpoint `getHello` becomes `pb.getHello()`. Path params come first, the request
55
- body/query second:
52
+ Codegen turns each backend controller into a typed namespace on `pb`. The
53
+ operation id is `<controller>.<method>` `TodosController.create` becomes
54
+ `pb.todos.create(input)`, `HelloController.greet` becomes `pb.hello.greet()`.
55
+ Path params come first, the request body/query second:
56
56
 
57
57
  ```ts
58
58
  import { pb } from '@palbase/web';
@@ -206,8 +206,8 @@ specific failures a given endpoint documents.
206
206
  ## Next.js — `@palbase/web/next`
207
207
 
208
208
  The Next.js App Router adapter shares one session cookie between the browser and
209
- the server so Server Components, Route Handlers and middleware all see the same
210
- auth state.
209
+ the server so Server Components, Route Handlers and the proxy all see the same
210
+ auth state. Requires `next >= 16` (the `proxy` file convention).
211
211
 
212
212
  **1. Configure the browser client** (a client provider/component):
213
213
 
@@ -225,15 +225,15 @@ export function PalbeProvider({ children }: { children: React.ReactNode }) {
225
225
  `setupPalbeNext()` swaps in `cookieSessionStorage` so the session is written to a
226
226
  cookie the server can read.
227
227
 
228
- **2. Refresh the session in middleware** (required for session-bearing RSC apps):
228
+ **2. Refresh the session in the proxy** (required for session-bearing RSC apps):
229
229
 
230
230
  ```ts
231
- // middleware.ts
232
- import { palbeMiddleware } from '@palbase/web/next/middleware';
231
+ // proxy.ts
232
+ import { palbeProxy } from '@palbase/web/next/proxy';
233
233
  import type { NextRequest } from 'next/server';
234
234
 
235
- export function middleware(request: NextRequest) {
236
- return palbeMiddleware(request, {
235
+ export function proxy(request: NextRequest) {
236
+ return palbeProxy(request, {
237
237
  url: 'https://<environmentRef>.palbase.studio',
238
238
  apiKey: 'pb_<environmentRef>_c...',
239
239
  });
@@ -247,15 +247,15 @@ export const config = { matcher: ['/((?!_next/static|_next/image|favicon.ico).*)
247
247
 
248
248
  Two rules the shape above encodes:
249
249
 
250
- - **Import `@palbase/web/next/middleware`, not `@palbase/web/next`.** Next
251
- compiles middleware into a separate Edge bundle, and the full adapter graph
252
- reaches `WebAssembly.compile`, which Next rejects there with a build error.
250
+ - **Import `@palbase/web/next/proxy`, not `@palbase/web/next`.** Next compiles
251
+ the proxy into its own bundle, and the full adapter graph reaches
252
+ `livekit-client` and the MLS WASM loader megabytes on every request path.
253
253
  This entry reaches none of it.
254
254
  - **Pass the config explicitly; do not `import './palbe.gen'` here.** That
255
255
  import would pull the same graph back in. It also means `config`/`matcher`
256
256
  must be declared in this file — Next reads `export const config` off this
257
257
  file's own AST, so a re-exported or imported one is silently ignored and the
258
- middleware degrades to matching every request.
258
+ proxy degrades to matching every request.
259
259
 
260
260
  **3. Read data in Server Components** with `pbServer()` — a per-request,
261
261
  session-isolated client:
@@ -15,6 +15,15 @@ interface PalbaseResponse$1<T> {
15
15
  status: number;
16
16
  }
17
17
  interface HttpClientOptions$1 {
18
+ /**
19
+ * The host application's own version, sent as `X-Palbase-Client-Version` and
20
+ * readable in flag targeting as `client.app_version`.
21
+ *
22
+ * Opt-in because the SDK cannot discover it on the web — there is no bundle
23
+ * to read a version out of. iOS fills the same header automatically from
24
+ * CFBundleShortVersionString.
25
+ */
26
+ appVersion?: string;
18
27
  url?: string;
19
28
  headers?: Record<string, string>;
20
29
  }
@@ -104,6 +113,15 @@ interface PalbaseResponse<T> {
104
113
  status: number;
105
114
  }
106
115
  interface HttpClientOptions {
116
+ /**
117
+ * The host application's own version, sent as `X-Palbase-Client-Version` and
118
+ * readable in flag targeting as `client.app_version`.
119
+ *
120
+ * Opt-in because the SDK cannot discover it on the web — there is no bundle
121
+ * to read a version out of. iOS fills the same header automatically from
122
+ * CFBundleShortVersionString.
123
+ */
124
+ appVersion?: string;
107
125
  url?: string;
108
126
  headers?: Record<string, string>;
109
127
  }
@@ -1648,6 +1666,19 @@ interface AuthUser {
1648
1666
  emailVerified: boolean;
1649
1667
  createdAt: string;
1650
1668
  }
1669
+ /** What `pb.auth.getSignInMethods()` reports about an account's credentials. */
1670
+ interface SignInMethods {
1671
+ /** A local password exists — offer "change password", not "set password". */
1672
+ password: boolean;
1673
+ /** An MFA factor is enrolled. */
1674
+ mfa: boolean;
1675
+ /**
1676
+ * Linked OAuth providers, e.g. `['google']`. `[]` means none are linked;
1677
+ * `null` means the server could not determine it (social login is not
1678
+ * configured, or the lookup failed) — treat null as unknown, not as none.
1679
+ */
1680
+ providers: string[] | null;
1681
+ }
1651
1682
  interface AuthSuccess {
1652
1683
  user: AuthUser;
1653
1684
  session: Session$1;
@@ -1716,6 +1747,16 @@ declare class PalbeAuth {
1716
1747
  erasureId: string;
1717
1748
  }>;
1718
1749
  getUser(): Promise<AuthUser>;
1750
+ /**
1751
+ * Which credentials this account actually has.
1752
+ *
1753
+ * An account reached through Google has no password, so showing it a
1754
+ * "current password" field gives the user something they can never fill —
1755
+ * and `getUser()` cannot tell you, because GET /auth/user carries no
1756
+ * credential information. Read this before rendering any re-auth or
1757
+ * change-password form.
1758
+ */
1759
+ getSignInMethods(): Promise<SignInMethods>;
1719
1760
  refreshUser(): Promise<AuthUser>;
1720
1761
  /**
1721
1762
  * Restore the user after a session was rehydrated from storage (page reload).
@@ -1906,4 +1947,4 @@ declare class PalbeAnalytics {
1906
1947
  private post;
1907
1948
  }
1908
1949
 
1909
- export { type AuthUser as A, PalbeMessaging as B, Chat as C, type PalbeOAuthConfig as D, PalbeRealtime as E, type FlagsView as F, type PresenceState as G, RealtimeChannel as H, type RealtimeHandler as I, type RealtimeStatus as J, type RealtimeStatusSnapshot as K, type RealtimeSubscription as L, type MagicLinkResult as M, type NotifyScope as N, type OAuthExchangeResult as O, type PalbeConfig as P, type ResolvedMention as Q, type RealtimeConnectionState as R, type ResolvedReply as S, type SentReceipt as T, type UnreadView as U, type Unsubscribe as V, PalbePerf as W, type RealtimePayload as a, type ChatMember as b, type ChatMessage as c, type PalbeRuntime as d, buildRuntime as e, type AnalyticsProperties as f, type AuthChangeEvent as g, type AuthState as h, type AuthSuccess as i, Call as j, type CallChangeCallback as k, type CallParticipant as l, type CallState as m, type ChatBackend as n, type ChatDraft as o, type ChatKind as p, type ChatMessageKind as q, type ChatRole as r, type ChatState as s, type CommsPrefs as t, type MentionRange as u, type MessageDirection as v, PalbeAnalytics as w, PalbeAuth as x, PalbeCalls as y, PalbeFlags as z };
1950
+ export { type AuthUser as A, PalbeMessaging as B, Chat as C, type PalbeOAuthConfig as D, PalbeRealtime as E, type FlagsView as F, type PresenceState as G, RealtimeChannel as H, type RealtimeHandler as I, type RealtimeStatus as J, type RealtimeStatusSnapshot as K, type RealtimeSubscription as L, type MagicLinkResult as M, type NotifyScope as N, type OAuthExchangeResult as O, type PalbeConfig as P, type ResolvedMention as Q, type RealtimeConnectionState as R, type ResolvedReply as S, type SentReceipt as T, type SignInMethods as U, type UnreadView as V, type Unsubscribe as W, PalbePerf as X, type RealtimePayload as a, type ChatMember as b, type ChatMessage as c, type PalbeRuntime as d, buildRuntime as e, type AnalyticsProperties as f, type AuthChangeEvent as g, type AuthState as h, type AuthSuccess as i, Call as j, type CallChangeCallback as k, type CallParticipant as l, type CallState as m, type ChatBackend as n, type ChatDraft as o, type ChatKind as p, type ChatMessageKind as q, type ChatRole as r, type ChatState as s, type CommsPrefs as t, type MentionRange as u, type MessageDirection as v, PalbeAnalytics as w, PalbeAuth as x, PalbeCalls as y, PalbeFlags as z };
@@ -15,6 +15,15 @@ interface PalbaseResponse$1<T> {
15
15
  status: number;
16
16
  }
17
17
  interface HttpClientOptions$1 {
18
+ /**
19
+ * The host application's own version, sent as `X-Palbase-Client-Version` and
20
+ * readable in flag targeting as `client.app_version`.
21
+ *
22
+ * Opt-in because the SDK cannot discover it on the web — there is no bundle
23
+ * to read a version out of. iOS fills the same header automatically from
24
+ * CFBundleShortVersionString.
25
+ */
26
+ appVersion?: string;
18
27
  url?: string;
19
28
  headers?: Record<string, string>;
20
29
  }
@@ -104,6 +113,15 @@ interface PalbaseResponse<T> {
104
113
  status: number;
105
114
  }
106
115
  interface HttpClientOptions {
116
+ /**
117
+ * The host application's own version, sent as `X-Palbase-Client-Version` and
118
+ * readable in flag targeting as `client.app_version`.
119
+ *
120
+ * Opt-in because the SDK cannot discover it on the web — there is no bundle
121
+ * to read a version out of. iOS fills the same header automatically from
122
+ * CFBundleShortVersionString.
123
+ */
124
+ appVersion?: string;
107
125
  url?: string;
108
126
  headers?: Record<string, string>;
109
127
  }
@@ -1648,6 +1666,19 @@ interface AuthUser {
1648
1666
  emailVerified: boolean;
1649
1667
  createdAt: string;
1650
1668
  }
1669
+ /** What `pb.auth.getSignInMethods()` reports about an account's credentials. */
1670
+ interface SignInMethods {
1671
+ /** A local password exists — offer "change password", not "set password". */
1672
+ password: boolean;
1673
+ /** An MFA factor is enrolled. */
1674
+ mfa: boolean;
1675
+ /**
1676
+ * Linked OAuth providers, e.g. `['google']`. `[]` means none are linked;
1677
+ * `null` means the server could not determine it (social login is not
1678
+ * configured, or the lookup failed) — treat null as unknown, not as none.
1679
+ */
1680
+ providers: string[] | null;
1681
+ }
1651
1682
  interface AuthSuccess {
1652
1683
  user: AuthUser;
1653
1684
  session: Session$1;
@@ -1716,6 +1747,16 @@ declare class PalbeAuth {
1716
1747
  erasureId: string;
1717
1748
  }>;
1718
1749
  getUser(): Promise<AuthUser>;
1750
+ /**
1751
+ * Which credentials this account actually has.
1752
+ *
1753
+ * An account reached through Google has no password, so showing it a
1754
+ * "current password" field gives the user something they can never fill —
1755
+ * and `getUser()` cannot tell you, because GET /auth/user carries no
1756
+ * credential information. Read this before rendering any re-auth or
1757
+ * change-password form.
1758
+ */
1759
+ getSignInMethods(): Promise<SignInMethods>;
1719
1760
  refreshUser(): Promise<AuthUser>;
1720
1761
  /**
1721
1762
  * Restore the user after a session was rehydrated from storage (page reload).
@@ -1906,4 +1947,4 @@ declare class PalbeAnalytics {
1906
1947
  private post;
1907
1948
  }
1908
1949
 
1909
- export { type AuthUser as A, PalbeMessaging as B, Chat as C, type PalbeOAuthConfig as D, PalbeRealtime as E, type FlagsView as F, type PresenceState as G, RealtimeChannel as H, type RealtimeHandler as I, type RealtimeStatus as J, type RealtimeStatusSnapshot as K, type RealtimeSubscription as L, type MagicLinkResult as M, type NotifyScope as N, type OAuthExchangeResult as O, type PalbeConfig as P, type ResolvedMention as Q, type RealtimeConnectionState as R, type ResolvedReply as S, type SentReceipt as T, type UnreadView as U, type Unsubscribe as V, PalbePerf as W, type RealtimePayload as a, type ChatMember as b, type ChatMessage as c, type PalbeRuntime as d, buildRuntime as e, type AnalyticsProperties as f, type AuthChangeEvent as g, type AuthState as h, type AuthSuccess as i, Call as j, type CallChangeCallback as k, type CallParticipant as l, type CallState as m, type ChatBackend as n, type ChatDraft as o, type ChatKind as p, type ChatMessageKind as q, type ChatRole as r, type ChatState as s, type CommsPrefs as t, type MentionRange as u, type MessageDirection as v, PalbeAnalytics as w, PalbeAuth as x, PalbeCalls as y, PalbeFlags as z };
1950
+ export { type AuthUser as A, PalbeMessaging as B, Chat as C, type PalbeOAuthConfig as D, PalbeRealtime as E, type FlagsView as F, type PresenceState as G, RealtimeChannel as H, type RealtimeHandler as I, type RealtimeStatus as J, type RealtimeStatusSnapshot as K, type RealtimeSubscription as L, type MagicLinkResult as M, type NotifyScope as N, type OAuthExchangeResult as O, type PalbeConfig as P, type ResolvedMention as Q, type RealtimeConnectionState as R, type ResolvedReply as S, type SentReceipt as T, type SignInMethods as U, type UnreadView as V, type Unsubscribe as W, PalbePerf as X, type RealtimePayload as a, type ChatMember as b, type ChatMessage as c, type PalbeRuntime as d, buildRuntime as e, type AnalyticsProperties as f, type AuthChangeEvent as g, type AuthState as h, type AuthSuccess as i, Call as j, type CallChangeCallback as k, type CallParticipant as l, type CallState as m, type ChatBackend as n, type ChatDraft as o, type ChatKind as p, type ChatMessageKind as q, type ChatRole as r, type ChatState as s, type CommsPrefs as t, type MentionRange as u, type MessageDirection as v, PalbeAnalytics as w, PalbeAuth as x, PalbeCalls as y, PalbeFlags as z };
@@ -8,7 +8,7 @@ import {
8
8
  fromPalbaseError,
9
9
  isBackendError,
10
10
  unwrap
11
- } from "./chunk-BNAGRUIQ.js";
11
+ } from "./chunk-ACCJV6FV.js";
12
12
  import {
13
13
  environmentRefFromPublishableApiKey
14
14
  } from "./chunk-CFDU23TB.js";
@@ -1184,6 +1184,23 @@ var PalbeAuth = class {
1184
1184
  const raw = await palbeRequest(this.rt, "GET", "/auth/user");
1185
1185
  return mapWireUser(raw);
1186
1186
  }
1187
+ /**
1188
+ * Which credentials this account actually has.
1189
+ *
1190
+ * An account reached through Google has no password, so showing it a
1191
+ * "current password" field gives the user something they can never fill —
1192
+ * and `getUser()` cannot tell you, because GET /auth/user carries no
1193
+ * credential information. Read this before rendering any re-auth or
1194
+ * change-password form.
1195
+ */
1196
+ async getSignInMethods() {
1197
+ const raw = await palbeRequest(this.rt, "GET", "/auth/me");
1198
+ return {
1199
+ password: raw.has_password,
1200
+ mfa: raw.has_mfa,
1201
+ providers: raw.providers ?? null
1202
+ };
1203
+ }
1187
1204
  async refreshUser() {
1188
1205
  const user = await this.getUser();
1189
1206
  const changed = !usersEqual(user, this.cachedUser);
@@ -8633,7 +8650,7 @@ function defaultSessionStorage(key) {
8633
8650
  }
8634
8651
 
8635
8652
  // src/version.ts
8636
- var VERSION = "5.0.1";
8653
+ var VERSION = "7.0.0";
8637
8654
 
8638
8655
  // src/runtime.ts
8639
8656
  function buildRuntime(config) {
@@ -9058,4 +9075,4 @@ export {
9058
9075
  pb,
9059
9076
  createBoundClient
9060
9077
  };
9061
- //# sourceMappingURL=chunk-QKFPPZLF.js.map
9078
+ //# sourceMappingURL=chunk-7SNSLY5M.js.map