@protobase/server 0.26.4 → 0.26.6

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/api-cors.js CHANGED
@@ -16,7 +16,10 @@ const allowHeaders = [
16
16
  "authorization",
17
17
  "content-type",
18
18
  "if-match",
19
- "if-none-match"
19
+ "if-none-match",
20
+ "apikey",
21
+ "x-client-info",
22
+ "x-supabase-api-version"
20
23
  ];
21
24
  const exposeHeaders = [
22
25
  "location",
@@ -1,7 +1,7 @@
1
1
  import { jwtAuthenticator } from "../auth/jwt.js";
2
2
  import { noGlobalRole } from "./organizations/role-definitions.js";
3
- import { withTrustedApps } from "./app-tokens.js";
4
3
  import { cachedKeys } from "./jwks-cache.js";
4
+ import { withTrustedApps } from "./app-tokens.js";
5
5
  //#region src/better-auth/authenticator.ts
6
6
  /** How the tokens of this Better Auth instance verify: its key set, and its issuer as both issuer and audience. */
7
7
  const betterAuthTokens = (options) => {
@@ -60,7 +60,7 @@ export type CreateAdminInput = {
60
60
  formsDifficulty?: Difficulty;
61
61
  /** @internal The users comments name, mention and mail, which tests fake; from `auth` otherwise. */
62
62
  commentUsers?: CommentUsers;
63
- /** @internal Verifies a user's token on `/realtime/v1` and gives its claims, which tests fake; `auth`'s tokens otherwise. */
63
+ /** @internal Verifies a user's token on `/realtime/v1` and gives its claims, which tests fake; those `/auth/v1` signs otherwise. */
64
64
  verifyToken?: (token: string) => Promise<JWTPayload>;
65
65
  /**
66
66
  * The host's WebSocket upgrade, such as `@hono/node-server`'s, with which an app with keys and live resources serves
@@ -14,13 +14,13 @@ import { apiCors, readCorsOrigins } from "./api-cors.js";
14
14
  import { apiKeySettings } from "./api-keys/api-key-settings.js";
15
15
  import { apiKeyCaller } from "./api-keys/resolve-caller.js";
16
16
  import { jwtVerifier } from "./auth/jwt.js";
17
+ import { realtimeApp } from "./realtime/realtime-app.js";
17
18
  import { readAppName } from "./app-name.js";
18
19
  import { goTruePath } from "./gotrue/keys.js";
19
20
  import { authBasePath } from "./better-auth/auth-base-path.js";
20
- import { betterAuthTokens } from "./better-auth/authenticator.js";
21
- import { realtimeApp } from "./realtime/realtime-app.js";
22
21
  import { organizationRoutes } from "./better-auth/organizations/admin-routes.js";
23
22
  import { statusRoute } from "./better-auth/status-route.js";
23
+ import { goTrueTokens } from "./gotrue/access-tokens.js";
24
24
  import { goTrueRoutes } from "./gotrue/routes.js";
25
25
  import { changesSchema } from "./changes/events-options.js";
26
26
  import { appOrigin } from "./comments/app-origin.js";
@@ -223,11 +223,13 @@ const createAdmin = ({ resources: appResources, views: appViews = [], pages = []
223
223
  if (corsOrigins !== void 0 || ownOrigins.length > 1) {
224
224
  const answering = [authBasePath, ...Object.entries(apiFunctions).filter(([, fn]) => fn.options.cors).map(([name]) => `${systemPath}/functions/${name}`)];
225
225
  const skip = (path) => answering.some((prefix) => path === prefix || path.startsWith(`${prefix}/`));
226
- app.use(`${systemPath}/*`, apiCors({
226
+ const cors = apiCors({
227
227
  own: ownOrigins,
228
228
  allowed: corsOrigins ?? [],
229
229
  skip
230
- }));
230
+ });
231
+ app.use(`${systemPath}/*`, cors);
232
+ if (auth && !"/auth/v1".startsWith(`${systemPath}/`)) app.use(`${goTruePath}/*`, cors);
231
233
  }
232
234
  if (auth) {
233
235
  app.route(authBasePath, statusRoute(auth, {
@@ -278,7 +280,7 @@ const createAdmin = ({ resources: appResources, views: appViews = [], pages = []
278
280
  });
279
281
  if (appModels.some((model) => model.live)) app.route(systemPath || "/", guarded((live) => void live.route("/", liveRoutes(feed, (session) => visibleNotices(deps, session))), withAnonymous(authenticate, options.roles)));
280
282
  if (upgradeWebSocket && (apiKeys.publishable || apiKeys.secret)) {
281
- const verify = verifyToken ?? (auth ? jwtVerifier(betterAuthTokens({ auth })) : () => Promise.reject(unauthorized("This app signs no user tokens")));
283
+ const verify = verifyToken ?? (auth ? jwtVerifier(goTrueTokens({ auth })) : () => Promise.reject(unauthorized("This app signs no user tokens")));
282
284
  app.route("/realtime/v1", realtimeApp({
283
285
  deps,
284
286
  feed,
@@ -2,10 +2,10 @@ import { effectiveSignInPolicy } from "../better-auth/sign-in-policy.js";
2
2
  import { readSignInPolicy } from "../better-auth/policy-store.js";
3
3
  import { goTrueUser, userMetadata } from "./user-json.js";
4
4
  import { checkNewAccountPassword } from "../better-auth/new-account-password.js";
5
+ import { goTrueTokens } from "./access-tokens.js";
5
6
  import { GoTrueError } from "./errors.js";
6
7
  import { readBody } from "./request-body.js";
7
8
  import { accessClaimsOf } from "./bearer.js";
8
- import { goTrueTokens } from "./access-tokens.js";
9
9
  import { Hono } from "hono";
10
10
  import * as z$1 from "zod";
11
11
  //#region src/gotrue/user-routes.ts
package/dist/index.js CHANGED
@@ -26,8 +26,6 @@ import { parseRoles } from "./better-auth/parse-roles.js";
26
26
  import { readOperatorSettings } from "./better-auth/operator-provider.js";
27
27
  import { readPlatformSignIn } from "./better-auth/platform-sign-in.js";
28
28
  import { createAuth, normalizeRoles } from "./better-auth/create-auth.js";
29
- import { withTrustedApps } from "./better-auth/app-tokens.js";
30
- import { betterAuthAuthenticator, betterAuthTokens } from "./better-auth/authenticator.js";
31
29
  import { addAppRoleToOwners, addMember, createOrganization, listOrganizations, removeMember, setMemberRoles } from "./better-auth/organizations/host.js";
32
30
  import { createUser, deleteUser, hasUsers, listUsers, roleChoices, setUserBanned, setUserRole } from "./better-auth/users.js";
33
31
  import { changesMigration, checkChanges, migrationCommand } from "./changes/capture-schema.js";
@@ -55,6 +53,8 @@ import { handleDroppedConnections } from "./dropped-connections.js";
55
53
  import { configExports } from "./resource-source.js";
56
54
  import { checkViewQueries } from "./check-view-queries.js";
57
55
  import { defineConfig, mergeConfig } from "./project-config.js";
56
+ import { withTrustedApps } from "./better-auth/app-tokens.js";
57
+ import { betterAuthAuthenticator, betterAuthTokens } from "./better-auth/authenticator.js";
58
58
  import { issueToken, maxTokenTtlSeconds } from "./better-auth/tokens.js";
59
59
  import { authSchemaMigration, checkAuthSchema } from "./better-auth/auth-schema.js";
60
60
  import { checkComputed, computedMigration } from "./computed/computed-schema.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.26.4",
3
+ "version": "0.26.6",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -32,9 +32,9 @@
32
32
  "dependencies": {
33
33
  "@better-auth/passkey": "^1.7.7",
34
34
  "@better-auth/sso": "^1.7.7",
35
- "@protobase/layout": "0.26.4",
36
- "@protobase/query": "0.26.4",
37
- "@protobase/schema": "0.26.4",
35
+ "@protobase/layout": "0.26.6",
36
+ "@protobase/query": "0.26.6",
37
+ "@protobase/schema": "0.26.6",
38
38
  "@react-email/render": "^2.1.0",
39
39
  "@scalar/hono-api-reference": "^0.12.10",
40
40
  "@sentry/core": "^11.7.0",