@rebasepro/server 0.9.1-canary.f2f61da → 0.9.1-canary.faee831

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/init.d.ts CHANGED
@@ -287,6 +287,27 @@ export interface RebaseBackendConfig {
287
287
  * external storage) that the backend does not proxy.
288
288
  */
289
289
  storageSources?: import("@rebasepro/types").StorageSourceDefinition[];
290
+ /**
291
+ * Per-object access control for storage — the analogue of a collection's
292
+ * security rules, and the thing `requireAuth` / `publicRead` cannot
293
+ * express because they are global switches.
294
+ *
295
+ * Called after authentication on every storage route with the key, bucket,
296
+ * operation (`read` / `write` / `delete` / `list`) and resolved user.
297
+ * Return false to deny with a 403; throwing denies too.
298
+ *
299
+ * ```ts
300
+ * storageAuthorize: async ({ key, user, operation }) => {
301
+ * if (!user) return false;
302
+ * const [ownerId] = key.split("/");
303
+ * return ownerId === user.userId || operation === "read";
304
+ * }
305
+ * ```
306
+ *
307
+ * Without it, any authenticated caller may read any key they can name, so
308
+ * multi-tenant apps should treat this as required rather than optional.
309
+ */
310
+ storageAuthorize?: import("./storage/types").StorageAuthorize;
290
311
  /**
291
312
  * Entity history / audit-log configuration.
292
313
  *
@@ -4218,10 +4218,10 @@ function configureJwt(config) {
4218
4218
  /**
4219
4219
  * Generate an access token (short-lived, 1 hour by default)
4220
4220
  */
4221
- function generateAccessToken(userId, roles, aal = "aal1", customClaims) {
4221
+ function generateAccessToken(uid, roles, aal = "aal1", customClaims) {
4222
4222
  if (!jwtConfig.secret) throw new Error("JWT secret not configured. Call configureJwt() first.");
4223
4223
  const payload = {
4224
- userId,
4224
+ uid,
4225
4225
  roles,
4226
4226
  aal,
4227
4227
  ...customClaims
@@ -4274,14 +4274,14 @@ function verifyAccessToken(token) {
4274
4274
  logger.error("[JWT] Verification failed: a purpose-scoped token is not an access token", { purpose: decoded.purpose });
4275
4275
  return null;
4276
4276
  }
4277
- const id = decoded.userId || decoded.uid || decoded.sub;
4277
+ const id = decoded.uid || decoded.userId || decoded.sub;
4278
4278
  if (!id) {
4279
4279
  logger.error("[JWT] Verification failed: missing id in payload", { detail: decoded });
4280
4280
  return null;
4281
4281
  }
4282
4282
  const aal = decoded.aal === "aal1" || decoded.aal === "aal2" ? decoded.aal : "aal1";
4283
4283
  return {
4284
- userId: id,
4284
+ uid: id,
4285
4285
  roles: decoded.roles || [],
4286
4286
  aal
4287
4287
  };
@@ -4365,4 +4365,4 @@ function verifyDownloadToken(token) {
4365
4365
  //#endregion
4366
4366
  export { getAccessTokenExpiry as a, jwt_exports as c, require_jsonwebtoken as d, __commonJSMin as f, __toESM as h, generateRefreshToken as i, verifyAccessToken as l, __require as m, generateAccessToken as n, getRefreshTokenExpiry as o, __exportAll as p, generateDownloadToken as r, hashRefreshToken as s, configureJwt as t, verifyDownloadToken as u };
4367
4367
 
4368
- //# sourceMappingURL=jwt-BJzQOa8a.js.map
4368
+ //# sourceMappingURL=jwt-B3zjddCa.js.map