@supatype/client 0.9.0 → 0.9.1

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 (116) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-test.log +71 -68
  3. package/.turbo/turbo-typecheck.log +1 -1
  4. package/CHANGELOG.md +82 -0
  5. package/dist/auth.d.ts +41 -6
  6. package/dist/auth.d.ts.map +1 -1
  7. package/dist/auth.js +102 -32
  8. package/dist/auth.js.map +1 -1
  9. package/dist/bindings.d.ts +3 -0
  10. package/dist/bindings.d.ts.map +1 -1
  11. package/dist/bindings.js +2 -0
  12. package/dist/bindings.js.map +1 -1
  13. package/dist/error-codes-doc.d.ts +1 -1
  14. package/dist/error-codes-doc.d.ts.map +1 -1
  15. package/dist/error-codes-doc.js +7 -0
  16. package/dist/error-codes-doc.js.map +1 -1
  17. package/dist/errors.d.ts +81 -21
  18. package/dist/errors.d.ts.map +1 -1
  19. package/dist/errors.js +133 -46
  20. package/dist/errors.js.map +1 -1
  21. package/dist/graphql-transport.d.ts +8 -1
  22. package/dist/graphql-transport.d.ts.map +1 -1
  23. package/dist/graphql-transport.js +5 -5
  24. package/dist/graphql-transport.js.map +1 -1
  25. package/dist/index.d.ts +9 -5
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +52 -37
  28. package/dist/index.js.map +1 -1
  29. package/dist/latest-rows.d.ts +29 -0
  30. package/dist/latest-rows.d.ts.map +1 -0
  31. package/dist/latest-rows.js +51 -0
  32. package/dist/latest-rows.js.map +1 -0
  33. package/dist/mutation-request.d.ts +2 -1
  34. package/dist/mutation-request.d.ts.map +1 -1
  35. package/dist/mutation-request.js +2 -1
  36. package/dist/mutation-request.js.map +1 -1
  37. package/dist/page-env-script.d.ts +12 -0
  38. package/dist/page-env-script.d.ts.map +1 -0
  39. package/dist/page-env-script.js +30 -0
  40. package/dist/page-env-script.js.map +1 -0
  41. package/dist/preview.d.ts +2 -1
  42. package/dist/preview.d.ts.map +1 -1
  43. package/dist/preview.js +7 -3
  44. package/dist/preview.js.map +1 -1
  45. package/dist/query.d.ts +11 -5
  46. package/dist/query.d.ts.map +1 -1
  47. package/dist/query.js +22 -13
  48. package/dist/query.js.map +1 -1
  49. package/dist/realtime.d.ts +5 -2
  50. package/dist/realtime.d.ts.map +1 -1
  51. package/dist/realtime.js +13 -6
  52. package/dist/realtime.js.map +1 -1
  53. package/dist/runtime-env.d.ts +59 -0
  54. package/dist/runtime-env.d.ts.map +1 -0
  55. package/dist/runtime-env.js +167 -0
  56. package/dist/runtime-env.js.map +1 -0
  57. package/dist/setup-fault.d.ts +13 -0
  58. package/dist/setup-fault.d.ts.map +1 -0
  59. package/dist/setup-fault.js +17 -0
  60. package/dist/setup-fault.js.map +1 -0
  61. package/dist/storage.d.ts +10 -5
  62. package/dist/storage.d.ts.map +1 -1
  63. package/dist/storage.js +22 -13
  64. package/dist/storage.js.map +1 -1
  65. package/dist/table-subscription.d.ts +1 -1
  66. package/dist/table-subscription.d.ts.map +1 -1
  67. package/dist/table-subscription.js +3 -2
  68. package/dist/table-subscription.js.map +1 -1
  69. package/dist/thrown-error.d.ts +16 -0
  70. package/dist/thrown-error.d.ts.map +1 -0
  71. package/dist/thrown-error.js +31 -0
  72. package/dist/thrown-error.js.map +1 -0
  73. package/dist/types.d.ts +59 -15
  74. package/dist/types.d.ts.map +1 -1
  75. package/dist/types.js.map +1 -1
  76. package/package.json +2 -1
  77. package/src/auth.ts +106 -36
  78. package/src/bindings.ts +3 -0
  79. package/src/error-codes-doc.ts +9 -1
  80. package/src/errors.ts +155 -57
  81. package/src/graphql-transport.ts +5 -6
  82. package/src/index.ts +62 -44
  83. package/src/latest-rows.ts +78 -0
  84. package/src/mutation-request.ts +3 -2
  85. package/src/page-env-script.ts +27 -0
  86. package/src/preview.ts +8 -4
  87. package/src/query.ts +27 -16
  88. package/src/realtime.ts +15 -6
  89. package/src/runtime-env.ts +220 -0
  90. package/src/setup-fault.ts +18 -0
  91. package/src/storage.ts +26 -16
  92. package/src/table-subscription.ts +3 -3
  93. package/src/thrown-error.ts +31 -0
  94. package/src/types.ts +65 -14
  95. package/tests/auth-errors.test.ts +3 -3
  96. package/tests/auth-events.test.ts +3 -7
  97. package/tests/auth-sso.test.ts +260 -0
  98. package/tests/auth-url-session.test.ts +6 -25
  99. package/tests/entry-points.test.ts +9 -0
  100. package/tests/error-family.test.ts +79 -0
  101. package/tests/helpers/auth-unmount-binding.ts +63 -0
  102. package/tests/helpers/oauth-binding.ts +4 -3
  103. package/tests/helpers/stale-read-binding.ts +113 -0
  104. package/tests/helpers/thrown-error-binding.ts +127 -0
  105. package/tests/postgrest-error-codes.test.ts +4 -4
  106. package/tests/rate-limit-integration.test.ts +1 -1
  107. package/tests/result-error-class.test.ts +107 -0
  108. package/tests/retry-policy.test.ts +1 -1
  109. package/tests/runtime-env-bundle.test.ts +121 -0
  110. package/tests/runtime-env-page-script.test.ts +174 -0
  111. package/tests/runtime-env.test.ts +224 -0
  112. package/tests/server-bodies.test.ts +3 -3
  113. package/tests/support/browser.ts +28 -0
  114. package/tests/support/jwt.ts +5 -0
  115. package/tests/thrown-error.test.ts +59 -0
  116. package/tsconfig.tsbuildinfo +1 -1
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { TableRelationship } from "./select-types.js";
2
+ import type { SupatypeError } from "./errors.js";
2
3
  export interface UserIdentity {
3
4
  id: string;
4
5
  userId: string;
@@ -49,6 +50,45 @@ export type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "
49
50
  * React Native helpers should pass `pkce` (recommended default for mobile).
50
51
  */
51
52
  export type AuthFlowType = "pkce" | "implicit";
53
+ /** How `signInWithSSO` starts and ends. */
54
+ export interface SignInWithSSOOptions {
55
+ /** Where the browser lands once signed in; honoured on the site URL's host or the redirect allow list. */
56
+ redirectTo?: string | undefined;
57
+ /** The CAPTCHA token, when the project requires one. */
58
+ captchaToken?: string | undefined;
59
+ /** Return the identity provider's URL and leave the browser where it is. */
60
+ skipBrowserRedirect?: boolean | undefined;
61
+ /**
62
+ * Default: `pkce`, so the session comes back as a `?code=` only this browser can exchange, never
63
+ * as tokens in the URL. `implicit` returns tokens in the fragment. (`signInWithOAuth` defaults to
64
+ * `implicit`.) A sign-in the identity provider starts always comes back implicit, and the client
65
+ * accepts it either way.
66
+ */
67
+ flowType?: AuthFlowType | undefined;
68
+ }
69
+ /** Sign in through the SAML identity provider registered for the user's email domain. */
70
+ export interface SignInWithSSODomain {
71
+ /** The domain of the user's email address: `acme.com`. */
72
+ domain: string;
73
+ providerId?: never;
74
+ options?: SignInWithSSOOptions | undefined;
75
+ }
76
+ /** Sign in through one SAML identity provider, named by its ID. */
77
+ export interface SignInWithSSOProvider {
78
+ /** The provider's UUID, as the admin API reports it. */
79
+ providerId: string;
80
+ domain?: never;
81
+ options?: SignInWithSSOOptions | undefined;
82
+ }
83
+ /** What `signInWithSSO` takes: an email domain or a provider's ID, never both. */
84
+ export type SignInWithSSOCredentials = SignInWithSSODomain | SignInWithSSOProvider;
85
+ /** What `signInWithSSO` answers: the identity provider's URL, or why there is none. */
86
+ export interface SignInWithSSOResult {
87
+ data: {
88
+ url: string;
89
+ };
90
+ error: SupatypeError | null;
91
+ }
52
92
  export interface AuthMFAEnrollResponse {
53
93
  /** The MFA factor ID */
54
94
  id: string;
@@ -94,7 +134,10 @@ export interface AuthMFAListFactorsResponse {
94
134
  phone: Factor[];
95
135
  }
96
136
  export type OtpType = "signup" | "magiclink" | "recovery" | "invite" | "email_change" | "sms" | "phone_change" | "email";
97
- export interface SupatypeError {
137
+ /** The class every result error is; its fields are `SupatypeErrorFields`. */
138
+ export type { SupatypeError };
139
+ /** The fields a `SupatypeError` carries, as given to its constructor and as its JSON. */
140
+ export interface SupatypeErrorFields {
98
141
  message: string;
99
142
  status?: number | undefined;
100
143
  code?: string | undefined;
@@ -120,15 +163,8 @@ export interface SupatypeError {
120
163
  */
121
164
  details?: string | undefined;
122
165
  }
123
- /**
124
- * A sign-in the auth server refused and reported back in the redirect URL.
125
- *
126
- * `provider` names the OAuth provider this browser started the sign-in with, when the client
127
- * remembers one, so an app showing one button per provider can put the message by the right one.
128
- */
129
- export interface AuthRedirectError extends SupatypeError {
130
- provider?: string | undefined;
131
- }
166
+ /** A sign-in refused in the redirect URL: the class, with the provider it was started with. */
167
+ export type { AuthRedirectError } from "./errors.js";
132
168
  /**
133
169
  * A column in the response that carries a read restriction.
134
170
  *
@@ -340,10 +376,19 @@ export interface SelectQueryOptions {
340
376
  profile?: string | undefined;
341
377
  }
342
378
  export interface SupatypeClientConfig {
343
- /** Base URL of the Supatype gateway (e.g. http://localhost:18473) */
344
- url: string;
345
- /** Anon JWT key */
346
- anonKey: string;
379
+ /**
380
+ * Base URL of the Supatype gateway (e.g. http://localhost:18473). Left out, or empty as a bundler
381
+ * leaves an unset name, it is read from `window.__SUPATYPE_ENV__` (set by
382
+ * `<script src="/supatype-env.js">`) when the first request is made. It is never guessed from the
383
+ * page's own address: with neither, that request throws `MissingClientValuesError`.
384
+ */
385
+ url?: string | undefined;
386
+ /**
387
+ * Anon JWT key. Left out, or empty, it is read from `window.__SUPATYPE_ENV__` when the first
388
+ * request is made; with neither, that request throws `MissingClientValuesError` naming the
389
+ * variables to set. `createClient` itself never throws for either.
390
+ */
391
+ anonKey?: string | undefined;
347
392
  /**
348
393
  * Service role key: bypasses row-level security.
349
394
  * Only set this in trusted server-side or developer-tool contexts.
@@ -439,5 +484,4 @@ export interface SupatypeClientConfig {
439
484
  */
440
485
  headers?: Record<string, string> | (() => Record<string, string>) | undefined;
441
486
  }
442
- export {};
443
487
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAI1D,MAAM,WAAW,YAAY;IAC3B,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;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAA;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAA"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA2aA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAA;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supatype/client",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "license": "MIT",
5
5
  "description": "Supatype client SDK: typed REST, auth, storage, realtime",
6
6
  "type": "module",
@@ -22,6 +22,7 @@
22
22
  "devDependencies": {
23
23
  "@types/node": "^22",
24
24
  "typescript": "^5",
25
+ "vite": "^6",
25
26
  "vitest": "^4.0.18"
26
27
  },
27
28
  "dependencies": {
package/src/auth.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type {
2
2
  AuthChangeEvent,
3
3
  AuthFlowType,
4
- AuthRedirectError,
5
4
  AuthMFAChallengeResponse,
6
5
  AuthMFAEnrollResponse,
7
6
  AuthMFAListFactorsResponse,
@@ -9,7 +8,9 @@ import type {
9
8
  Factor,
10
9
  OtpType,
11
10
  Session,
12
- SupatypeError,
11
+ SignInWithSSOCredentials,
12
+ SignInWithSSOOptions,
13
+ SignInWithSSOResult,
13
14
  User,
14
15
  UserIdentity,
15
16
  } from "./types.js"
@@ -38,6 +39,9 @@ import {
38
39
  type Guard,
39
40
  } from "./json.js"
40
41
  import { decodeJwtPayload } from "./jwt.js"
42
+ import { rethrowSetupFault } from "./setup-fault.js"
43
+ import { settle, type Deferred } from "./runtime-env.js"
44
+ import { AuthRedirectError, SupatypeError } from "./errors.js"
41
45
 
42
46
  export type AuthListener = (event: AuthChangeEvent, session: Session | null) => void
43
47
 
@@ -63,6 +67,11 @@ const DEFAULT_COOKIE_PREFIX = "st"
63
67
  /** Storage key suffixes for the state an OAuth redirect has to survive. */
64
68
  const VERIFIER_SUFFIX = "-code-verifier"
65
69
  const PROVIDER_SUFFIX = "-oauth-provider"
70
+ /**
71
+ * What a SAML sign-in is remembered as: the `provider` of an `AuthRedirectError` the auth server
72
+ * sent back in the URL for a sign-in `signInWithSSO` started.
73
+ */
74
+ export const SSO_PROVIDER = "sso"
66
75
  const DEBUG_AUTH = typeof process !== "undefined" && process.env["NEXT_PUBLIC_SUPATYPE_DEBUG_AUTH"] === "1"
67
76
 
68
77
  /**
@@ -82,7 +91,7 @@ function authErrorFromBody(body: Record<string, unknown>, status: number): Supat
82
91
  const message =
83
92
  text("msg") ?? text("message") ?? text("error_description") ?? text("error") ??
84
93
  `Auth request failed (HTTP ${status})`
85
- return { message, status, ...(code !== undefined && { code }) }
94
+ return new SupatypeError({ message, status, ...(code !== undefined && { code }) })
86
95
  }
87
96
 
88
97
  /** The assurance levels the client reports; the server's unused `aal3` reads as unknown. */
@@ -135,8 +144,8 @@ function snakeCaseUser(user: Record<string, unknown>): Record<string, unknown> {
135
144
  }
136
145
 
137
146
  export class AuthClient {
138
- private readonly url: string
139
- private readonly baseHeaders: Record<string, string>
147
+ private readonly urlSource: Deferred<string>
148
+ private readonly baseHeadersSource: Deferred<Record<string, string>>
140
149
  private currentSession: Session | null = null
141
150
  private readonly listeners = new Map<string, AuthListener>()
142
151
  private listenerIdCounter = 0
@@ -163,9 +172,13 @@ export class AuthClient {
163
172
  /** In-memory PKCE code_verifier for the in-flight OAuth / OTP redirect. */
164
173
  private codeVerifier: string | null = null
165
174
 
166
- constructor(url: string, baseHeaders: Record<string, string>, opts: AuthClientOptions = {}) {
167
- this.url = url
168
- this.baseHeaders = baseHeaders
175
+ /**
176
+ * `url` and `baseHeaders` may be functions, read for each request. `createClient` passes
177
+ * functions, so a client made before the page has said where the API is fails only at a request.
178
+ */
179
+ constructor(url: Deferred<string>, baseHeaders: Deferred<Record<string, string>>, opts: AuthClientOptions = {}) {
180
+ this.urlSource = url
181
+ this.baseHeadersSource = baseHeaders
169
182
  this.persistSession = opts.persistSession ?? true
170
183
  this.autoRefreshToken = opts.autoRefreshToken ?? true
171
184
  this.refreshExpiredToken = opts.refreshExpiredToken ?? true
@@ -189,6 +202,16 @@ export class AuthClient {
189
202
  }
190
203
  }
191
204
 
205
+ /** The auth address, read now. */
206
+ private get url(): string {
207
+ return settle(this.urlSource)
208
+ }
209
+
210
+ /** The anon headers every auth request starts from, read now. */
211
+ private get baseHeaders(): Record<string, string> {
212
+ return settle(this.baseHeadersSource)
213
+ }
214
+
192
215
  /** The session the client starts with: the one passed in, else the persisted one. */
193
216
  private loadInitialSession(opts: AuthClientOptions): Promise<void> {
194
217
  if (opts.initialSession !== undefined) {
@@ -242,12 +265,12 @@ export class AuthClient {
242
265
  const provider = await this.takeFlowItem(PROVIDER_SUFFIX)
243
266
  this.currentSession = null
244
267
  const { error } = await this.getSessionFromUrl(href).catch((err: unknown) => ({
245
- error: { message: err instanceof Error ? err.message : "Could not finish the sign-in" },
268
+ error: new SupatypeError({ message: err instanceof Error ? err.message : "Could not finish the sign-in" }, { cause: err }),
246
269
  }))
247
270
  cleanBrowserUrl(href)
248
271
  if (error === null) return { error: null }
249
272
  this._setSession(null)
250
- return { error: { ...error, ...(provider !== null && { provider }) } }
273
+ return { error: new AuthRedirectError({ ...error.toJSON(), ...(provider !== null && { provider }) }, { cause: error }) }
251
274
  }
252
275
 
253
276
  /** A URL with tokens or a refusal, or with a `code` for a PKCE flow this client started. */
@@ -474,7 +497,7 @@ export class AuthClient {
474
497
  // navigating there shows as raw text; asking first lets the caller show a message instead.
475
498
  if (await this.providerDisabled(opts.provider)) {
476
499
  const message = `Sign-in with ${opts.provider} is not enabled for this project.`
477
- return { data: { url: "", provider: opts.provider }, error: { message, status: 400, code: "provider_disabled" } }
500
+ return { data: { url: "", provider: opts.provider }, error: new SupatypeError({ message, status: 400, code: "provider_disabled" }) }
478
501
  }
479
502
  await this.writeFlowItem(PROVIDER_SUFFIX, opts.provider)
480
503
  const url = this.endpoint("/authorize", opts.options?.redirectTo)
@@ -487,13 +510,53 @@ export class AuthClient {
487
510
  }
488
511
  const flowType = opts.options?.flowType ?? "implicit"
489
512
  if (flowType === "pkce") {
490
- await this.beginPkce()
491
- url.searchParams.set("code_challenge", createCodeChallengeS256(this.codeVerifier!))
492
- url.searchParams.set("code_challenge_method", PKCE_METHOD_S256)
513
+ for (const [key, value] of Object.entries(await this.beginPkce())) url.searchParams.set(key, value)
493
514
  }
494
515
  return { data: { url: url.toString(), provider: opts.provider }, error: null }
495
516
  }
496
517
 
518
+ /**
519
+ * Sign in with SAML single sign-on, through the identity provider registered for the user's email
520
+ * domain, or one named by its ID.
521
+ *
522
+ * Asks `POST /sso` for the identity provider's URL and sends the browser there, unless
523
+ * `skipBrowserRedirect` is set or there is no browser. The identity provider returns the user to
524
+ * the auth server, which sends them on to `redirectTo`; the client finishes the sign-in on start,
525
+ * as it does for OAuth. A refusal (no provider for the domain, a disabled one) is returned and the
526
+ * page stays put.
527
+ *
528
+ * PKCE by default (`flowType`), unlike `signInWithOAuth`: the sign-in comes back as a `?code=`
529
+ * this browser exchanges with its stored verifier.
530
+ */
531
+ async signInWithSSO(params: SignInWithSSOCredentials): Promise<SignInWithSSOResult> {
532
+ const res = await this.send(`${this.url}/sso`, {
533
+ method: "POST",
534
+ headers: this.baseHeaders,
535
+ body: JSON.stringify(await this.ssoRequestBody(params)),
536
+ })
537
+ if (!res.ok) return { data: { url: "" }, error: await this._parseError(res) }
538
+ const url = (await readJsonObject(res))["url"]
539
+ if (typeof url !== "string" || url === "") {
540
+ const message = "The auth server answered /sso without a sign-in URL"
541
+ return { data: { url: "" }, error: new SupatypeError({ message, status: res.status }) }
542
+ }
543
+ await this.writeFlowItem(PROVIDER_SUFFIX, SSO_PROVIDER)
544
+ if (params.options?.skipBrowserRedirect !== true && typeof window !== "undefined") window.location.assign(url)
545
+ return { data: { url }, error: null }
546
+ }
547
+
548
+ /** The `/sso` body: the domain or the provider's ID, the caller's options, and any PKCE challenge. */
549
+ private async ssoRequestBody(params: SignInWithSSOCredentials): Promise<Record<string, unknown>> {
550
+ const opts: SignInWithSSOOptions = params.options ?? {}
551
+ const body: Record<string, unknown> = params.domain !== undefined ? { domain: params.domain } : { provider_id: params.providerId }
552
+ // A fetch cannot follow the server's 303 to another origin, so ask for the URL as JSON.
553
+ body["skip_http_redirect"] = true
554
+ if (opts.redirectTo !== undefined) body["redirect_to"] = opts.redirectTo
555
+ if (opts.captchaToken !== undefined) body["supatype_meta_security"] = { captcha_token: opts.captchaToken }
556
+ const flowType = opts.flowType ?? "pkce"
557
+ return flowType === "pkce" ? { ...body, ...(await this.beginPkce()) } : body
558
+ }
559
+
497
560
  /**
498
561
  * True only when the server's `/settings` list the provider as off. A provider they do not list
499
562
  * (a `custom:` one) or settings that cannot be read leave the decision to `/authorize`. Looked up
@@ -552,8 +615,8 @@ export class AuthClient {
552
615
 
553
616
  /**
554
617
  * Exchange a PKCE auth code for a session (`POST /token?grant_type=pkce`).
555
- * Requires a prior `signInWithOAuth({ options: { flowType: "pkce" } })` (or OTP with PKCE)
556
- * so the matching `code_verifier` is available in memory / storage.
618
+ * Requires a prior PKCE sign-in in this browser (`signInWithSSO`, or `signInWithOAuth` or OTP with
619
+ * `flowType: "pkce"`), so the matching `code_verifier` is available in memory / storage.
557
620
  */
558
621
  async exchangeCodeForSession(authCode: string): Promise<{
559
622
  data: { session: Session | null; user: User | null }
@@ -563,10 +626,10 @@ export class AuthClient {
563
626
  if (verifier === null) {
564
627
  return {
565
628
  data: { session: null, user: null },
566
- error: {
567
- message: "Missing PKCE code_verifier. Start OAuth with flowType: \"pkce\" first.",
629
+ error: new SupatypeError({
630
+ message: "Missing PKCE code_verifier. Start the sign-in (SSO, or OAuth with flowType: \"pkce\") in this browser first.",
568
631
  status: 400,
569
- },
632
+ }),
570
633
  }
571
634
  }
572
635
  const res = await this.send(`${this.url}/token?grant_type=pkce`, {
@@ -593,7 +656,7 @@ export class AuthClient {
593
656
  if (params === null) {
594
657
  return {
595
658
  data: { session: null, user: null },
596
- error: { message: `Invalid redirect URL: ${url}`, status: 400 },
659
+ error: new SupatypeError({ message: `Invalid redirect URL: ${url}`, status: 400 }),
597
660
  }
598
661
  }
599
662
  const { query, fragment: hashParams } = params
@@ -633,10 +696,10 @@ export class AuthClient {
633
696
 
634
697
  return {
635
698
  data: { session: null, user: null },
636
- error: {
699
+ error: new SupatypeError({
637
700
  message: "No auth code or tokens found in redirect URL",
638
701
  status: 400,
639
- },
702
+ }),
640
703
  }
641
704
  }
642
705
 
@@ -741,11 +804,11 @@ export class AuthClient {
741
804
  error: SupatypeError | null
742
805
  }> {
743
806
  if (this.currentSession === null) {
744
- return { data: { session: null }, error: { message: "No active session" } }
807
+ return { data: { session: null }, error: new SupatypeError({ message: "No active session" }) }
745
808
  }
746
809
  if (!this.currentSession.refreshToken?.trim()) {
747
810
  this._setSession(null)
748
- return { data: { session: null }, error: { message: "No refresh token" } }
811
+ return { data: { session: null }, error: new SupatypeError({ message: "No refresh token" }) }
749
812
  }
750
813
  try {
751
814
  const res = await this.send(`${this.url}/token?grant_type=refresh_token`, {
@@ -760,9 +823,11 @@ export class AuthClient {
760
823
  }
761
824
  return await this._parseAuthResponse(res)
762
825
  } catch (err) {
826
+ // Not a refused refresh: nothing was sent, and the session may be perfectly good.
827
+ rethrowSetupFault(err)
763
828
  const message = err instanceof Error ? err.message : "Refresh failed"
764
829
  this._setSession(null)
765
- return { data: { session: null }, error: { message } }
830
+ return { data: { session: null }, error: new SupatypeError({ message }, { cause: err }) }
766
831
  }
767
832
  }
768
833
 
@@ -785,7 +850,7 @@ export class AuthClient {
785
850
  data?: Record<string, unknown> | undefined
786
851
  }): Promise<{ data: { user: User | null }; error: SupatypeError | null }> {
787
852
  if (this.currentSession === null) {
788
- return { data: { user: null }, error: { message: "Not authenticated" } }
853
+ return { data: { user: null }, error: new SupatypeError({ message: "Not authenticated" }) }
789
854
  }
790
855
  const res = await this.send(`${this.url}/user`, {
791
856
  method: "PUT",
@@ -926,7 +991,7 @@ export class AuthClient {
926
991
  error: SupatypeError | null
927
992
  }> => {
928
993
  if (this.currentSession === null) {
929
- return { data: null, error: { message: "Not authenticated" } }
994
+ return { data: null, error: new SupatypeError({ message: "Not authenticated" }) }
930
995
  }
931
996
  const body: Record<string, unknown> = {
932
997
  factor_type: params.factorType,
@@ -975,7 +1040,7 @@ export class AuthClient {
975
1040
  error: SupatypeError | null
976
1041
  }> => {
977
1042
  if (this.currentSession === null) {
978
- return { data: null, error: { message: "Not authenticated" } }
1043
+ return { data: null, error: new SupatypeError({ message: "Not authenticated" }) }
979
1044
  }
980
1045
  const body: Record<string, unknown> = {}
981
1046
  if (params.channel !== undefined) body["channel"] = params.channel
@@ -1019,7 +1084,7 @@ export class AuthClient {
1019
1084
  if (this.currentSession === null) {
1020
1085
  return {
1021
1086
  data: { session: null, user: null },
1022
- error: { message: "Not authenticated" },
1087
+ error: new SupatypeError({ message: "Not authenticated" }),
1023
1088
  }
1024
1089
  }
1025
1090
  const res = await this.send(
@@ -1079,7 +1144,7 @@ export class AuthClient {
1079
1144
  error: SupatypeError | null
1080
1145
  }> => {
1081
1146
  if (this.currentSession === null) {
1082
- return { data: null, error: { message: "Not authenticated" } }
1147
+ return { data: null, error: new SupatypeError({ message: "Not authenticated" }) }
1083
1148
  }
1084
1149
  const res = await this.send(
1085
1150
  `${this.url}/factors/${params.factorId}`,
@@ -1107,7 +1172,7 @@ export class AuthClient {
1107
1172
  }> => {
1108
1173
  const userResult = await this.getUser()
1109
1174
  if (userResult.error !== null || userResult.data.user === null) {
1110
- return { data: null, error: userResult.error ?? { message: "Could not get user" } }
1175
+ return { data: null, error: userResult.error ?? new SupatypeError({ message: "Could not get user" }) }
1111
1176
  }
1112
1177
  const allFactors: Factor[] = userResult.data.user.factors ?? []
1113
1178
  const verifiedFactors = allFactors.filter((f) => f.status === "verified")
@@ -1134,16 +1199,16 @@ export class AuthClient {
1134
1199
  error: SupatypeError | null
1135
1200
  }> => {
1136
1201
  if (this.currentSession === null) {
1137
- return { data: null, error: { message: "Not authenticated" } }
1202
+ return { data: null, error: new SupatypeError({ message: "Not authenticated" }) }
1138
1203
  }
1139
1204
  // Decode the JWT payload to read the aal and amr claims
1140
1205
  const parts = this.currentSession.accessToken.split(".")
1141
1206
  if (parts.length !== 3) {
1142
- return { data: null, error: { message: "Invalid access token format" } }
1207
+ return { data: null, error: new SupatypeError({ message: "Invalid access token format" }) }
1143
1208
  }
1144
1209
  const payload = decodeJwtPayload(parts[1]!)
1145
1210
  if (payload === null) {
1146
- return { data: null, error: { message: "Failed to decode access token" } }
1211
+ return { data: null, error: new SupatypeError({ message: "Failed to decode access token" }) }
1147
1212
  }
1148
1213
  const { currentLevel, methods } = assuranceClaims(payload)
1149
1214
  try {
@@ -1154,7 +1219,7 @@ export class AuthClient {
1154
1219
  const nextLevel = hasVerifiedFactors ? "aal2" : "aal1"
1155
1220
  return { data: { currentLevel, nextLevel, currentAuthenticationMethods: methods }, error: null }
1156
1221
  } catch {
1157
- return { data: null, error: { message: "Failed to decode access token" } }
1222
+ return { data: null, error: new SupatypeError({ message: "Failed to decode access token" }) }
1158
1223
  }
1159
1224
  },
1160
1225
  }
@@ -1234,10 +1299,15 @@ export class AuthClient {
1234
1299
  return value
1235
1300
  }
1236
1301
 
1237
- private async beginPkce(): Promise<void> {
1302
+ /**
1303
+ * Start a PKCE flow: a fresh verifier, kept for the redirect, and the challenge parameters the
1304
+ * auth server takes with it (as `/authorize` query parameters or `/sso` body fields).
1305
+ */
1306
+ private async beginPkce(): Promise<{ code_challenge: string; code_challenge_method: string }> {
1238
1307
  const verifier = generateCodeVerifier()
1239
1308
  this.codeVerifier = verifier
1240
1309
  await this.writeFlowItem(VERIFIER_SUFFIX, verifier)
1310
+ return { code_challenge: createCodeChallengeS256(verifier), code_challenge_method: PKCE_METHOD_S256 }
1241
1311
  }
1242
1312
 
1243
1313
  private async readCodeVerifier(): Promise<string | null> {
package/src/bindings.ts CHANGED
@@ -17,6 +17,9 @@ export type {
17
17
  export { startOAuthRedirect } from "./auth-redirect.js"
18
18
  export { isClientFor, isRowsOf, isCallerValue } from "./caller-types.js"
19
19
  export { runMutation } from "./mutation-request.js"
20
+ export { reportThrown } from "./thrown-error.js"
21
+ export { latestRowsReader } from "./latest-rows.js"
22
+ export type { RowsReadOptions, RowsView } from "./latest-rows.js"
20
23
  export type { MutationOperation, MutationOutcome, MutationRequest, MutationSelect } from "./mutation-request.js"
21
24
  export { livePreviewMessage, previewMessageOf, originOf } from "./live-preview.js"
22
25
  export type { LivePreviewMessage } from "./live-preview.js"
@@ -20,7 +20,7 @@ export interface ErrorCodeEntry {
20
20
  /** HTTP status code typically associated with this error. */
21
21
  httpStatus?: number | undefined
22
22
  /** Category grouping. */
23
- category: "auth" | "postgrest" | "storage" | "realtime" | "network"
23
+ category: "auth" | "postgrest" | "storage" | "realtime" | "network" | "setup"
24
24
  }
25
25
 
26
26
  export const ERROR_CODES_DOCUMENTATION: readonly ErrorCodeEntry[] = [
@@ -305,6 +305,14 @@ export const ERROR_CODES_DOCUMENTATION: readonly ErrorCodeEntry[] = [
305
305
  httpStatus: 429,
306
306
  category: "network",
307
307
  },
308
+ // ── Setup errors ─────────────────────────────────────────────────────────
309
+ {
310
+ code: "MISSING_CLIENT_VALUES",
311
+ description: "A request was made by a client with no API address or no anon key, so nothing was sent.",
312
+ suggestion:
313
+ "Pass url and anonKey to createClient, set them at build time, or load /supatype-env.js before the app. The error names each value and every name it can be set under.",
314
+ category: "setup",
315
+ },
308
316
  ] as const
309
317
 
310
318
  /**