@rebasepro/server 0.9.1-canary.a57c262 → 0.9.1-canary.ad25bc0
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/auth/index.d.ts +1 -4
- package/dist/auth/jwt.d.ts +1 -12
- package/dist/auth/middleware.d.ts +0 -21
- package/dist/auth/rate-limiter.d.ts +6 -54
- package/dist/index.es.js +114 -312
- package/dist/index.es.js.map +1 -1
- package/dist/init.d.ts +0 -27
- package/dist/{jwt-BJzQOa8a.js → jwt-BwIn8xmk.js} +5 -173
- package/dist/jwt-BwIn8xmk.js.map +1 -0
- package/dist/ms-DnYXB-Wd.js +162 -0
- package/dist/ms-DnYXB-Wd.js.map +1 -0
- package/dist/src-B9tjYmqP.js +24598 -0
- package/dist/src-B9tjYmqP.js.map +1 -0
- package/dist/src-CsHhSKbi.js.map +1 -1
- package/package.json +5 -5
- package/dist/api/rest/write-validation.d.ts +0 -19
- package/dist/auth/collection-callback-warning.d.ts +0 -21
- package/dist/auth/rate-limit-store.d.ts +0 -49
- package/dist/jwt-BJzQOa8a.js.map +0 -1
package/dist/auth/index.d.ts
CHANGED
|
@@ -28,10 +28,7 @@ export type { AuthModuleConfig, CookieAuthConfig } from "./routes";
|
|
|
28
28
|
export { mountMagicLinkRoutes } from "./magic-link-routes";
|
|
29
29
|
export { createResetPasswordRoute } from "./reset-password-admin";
|
|
30
30
|
export type { ResetPasswordRouteConfig } from "./reset-password-admin";
|
|
31
|
-
export { createRateLimiter, defaultAuthLimiter, strictAuthLimiter, createApiKeyRateLimiter,
|
|
32
|
-
export type { DataRateLimitConfig } from "./rate-limiter";
|
|
33
|
-
export { MemoryRateLimitStore } from "./rate-limit-store";
|
|
34
|
-
export type { RateLimitStore, RateLimitDecision } from "./rate-limit-store";
|
|
31
|
+
export { createRateLimiter, defaultAuthLimiter, strictAuthLimiter, createApiKeyRateLimiter, apiKeyKeyGenerator } from "./rate-limiter";
|
|
35
32
|
export { createApiKeyStore, createApiKeyRoutes, isApiKeyToken, validateApiKey, httpMethodToOperation, isOperationAllowed } from "./api-keys";
|
|
36
33
|
export type { ApiKey, ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, UpdateApiKeyRequest, ApiKeyStore, ApiKeyOperation } from "./api-keys";
|
|
37
34
|
export { createBuiltinAuthAdapter } from "./builtin-auth-adapter";
|
package/dist/auth/jwt.d.ts
CHANGED
|
@@ -38,18 +38,7 @@ export declare function getAccessTokenExpiryMs(): number;
|
|
|
38
38
|
*/
|
|
39
39
|
export declare function getAccessTokenExpiry(): number;
|
|
40
40
|
/**
|
|
41
|
-
* Verify and decode an access token
|
|
42
|
-
*
|
|
43
|
-
* Every token this server issues is signed with the same secret, so what a
|
|
44
|
-
* token *is* comes from its claims, not from its signature. A download token
|
|
45
|
-
* ({@link generateDownloadToken}) is therefore a validly-signed string that
|
|
46
|
-
* must never authenticate anybody: it is scoped to one file path and handed out
|
|
47
|
-
* in URLs, which is a far weaker thing to hold than a session.
|
|
48
|
-
*
|
|
49
|
-
* Today it is rejected below for want of an id — but only by luck, since
|
|
50
|
-
* nothing stops a future download token from carrying one. So the purpose is
|
|
51
|
-
* checked explicitly: a token minted for reading a file is not a token for
|
|
52
|
-
* being a user.
|
|
41
|
+
* Verify and decode an access token
|
|
53
42
|
*/
|
|
54
43
|
export declare function verifyAccessToken(token: string): AccessTokenPayload | null;
|
|
55
44
|
/**
|
|
@@ -150,27 +150,6 @@ export declare const queryTokenAuth: MiddlewareHandler<HonoEnv>;
|
|
|
150
150
|
* untouched, so they still require a valid token.
|
|
151
151
|
*/
|
|
152
152
|
export declare const publicObjectAuth: MiddlewareHandler<HonoEnv>;
|
|
153
|
-
/**
|
|
154
|
-
* Helper to match paths for scoped file tokens.
|
|
155
|
-
* Matches exact paths or prefixes (exact folder prefixes or ending with /).
|
|
156
|
-
*
|
|
157
|
-
* The traversal check is defence in depth, not the load-bearing defence.
|
|
158
|
-
*
|
|
159
|
-
* A prefix comparison is a lie for any path containing `..`: `user1/../user2/x`
|
|
160
|
-
* starts with `user1/`, so a token scoped to `user1/` would authorize reading
|
|
161
|
-
* user2's file — and the storage controller would not object, because its own
|
|
162
|
-
* guard stops a path escaping the *bucket*, and that one resolves to `user2/x`,
|
|
163
|
-
* comfortably inside it. The grant is what would be escaped, and this is the
|
|
164
|
-
* only layer that knows what was granted.
|
|
165
|
-
*
|
|
166
|
-
* Nothing arrives here in that shape today: the URL parser resolves `..` (and
|
|
167
|
-
* `%2e%2e`, which the WHATWG spec treats as a dot for normalization) before
|
|
168
|
-
* Hono routes the request, so this comparison already runs on a resolved path.
|
|
169
|
-
* But that is a guarantee of the runtime rather than of this code, and it is
|
|
170
|
-
* one line to not depend on it. The same rule already guards the public-object
|
|
171
|
-
* path — see `isPublicStoragePath`.
|
|
172
|
-
*/
|
|
173
|
-
export declare function isPathMatch(requested: string, allowed: string): boolean;
|
|
174
153
|
/**
|
|
175
154
|
* Middleware that authenticates file-serving routes using scoped download tokens.
|
|
176
155
|
* It enforces that only scoped "file-read" tokens can access "/file/*" and "?token=" query params.
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { MiddlewareHandler } from "hono";
|
|
2
2
|
import { HonoEnv } from "../api/types";
|
|
3
|
-
import { RateLimitStore } from "./rate-limit-store";
|
|
4
|
-
/**
|
|
5
|
-
* Sliding-window rate limiting for Hono.
|
|
6
|
-
*
|
|
7
|
-
* The counting lives in a {@link RateLimitStore} — in this process's memory by
|
|
8
|
-
* default, which is a per-replica limit and says so. See `rate-limit-store.ts`.
|
|
9
|
-
*/
|
|
10
3
|
interface RateLimiterOptions {
|
|
11
4
|
/** Time window in milliseconds (default: 15 minutes) */
|
|
12
5
|
windowMs?: number;
|
|
@@ -16,22 +9,13 @@ interface RateLimiterOptions {
|
|
|
16
9
|
keyGenerator?: (c: Parameters<MiddlewareHandler<HonoEnv>>[0]) => string;
|
|
17
10
|
/** Custom message for rate limit responses */
|
|
18
11
|
message?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Where to keep the counts. Defaults to a private in-memory store — pass a
|
|
21
|
-
* shared one to have several limiters (or several processes) agree.
|
|
22
|
-
*/
|
|
23
|
-
store?: RateLimitStore;
|
|
24
|
-
/**
|
|
25
|
-
* Per-request limit override, for buckets whose allowance is data rather
|
|
26
|
-
* than config (an API key's own `rate_limit`). Returning `undefined` uses
|
|
27
|
-
* `limit`; returning `null` skips the limiter for this request.
|
|
28
|
-
*/
|
|
29
|
-
resolveLimit?: (c: Parameters<MiddlewareHandler<HonoEnv>>[0]) => number | null | undefined;
|
|
30
12
|
}
|
|
31
13
|
/**
|
|
32
14
|
* Create a rate-limiting middleware.
|
|
33
15
|
*
|
|
34
|
-
* Uses a sliding window: only
|
|
16
|
+
* Uses a sliding window algorithm: only timestamps within the last
|
|
17
|
+
* `windowMs` milliseconds are counted. Old entries are garbage-collected
|
|
18
|
+
* every `windowMs` to prevent unbounded memory growth.
|
|
35
19
|
*/
|
|
36
20
|
export declare function createRateLimiter(options?: RateLimiterOptions): MiddlewareHandler<HonoEnv>;
|
|
37
21
|
/**
|
|
@@ -52,44 +36,12 @@ export declare const strictAuthLimiter: MiddlewareHandler<HonoEnv>;
|
|
|
52
36
|
* via an API key.
|
|
53
37
|
*/
|
|
54
38
|
export declare function apiKeyKeyGenerator(c: Parameters<MiddlewareHandler<HonoEnv>>[0]): string;
|
|
55
|
-
/** How the data API's limits are apportioned. All fields optional. */
|
|
56
|
-
export interface DataRateLimitConfig {
|
|
57
|
-
/** Turn the whole thing off — for a deployment whose proxy already does it. */
|
|
58
|
-
enabled?: boolean;
|
|
59
|
-
windowMs?: number;
|
|
60
|
-
/** Fallback for an API key with no `rate_limit` of its own. Default 1000. */
|
|
61
|
-
apiKey?: number;
|
|
62
|
-
/** Per signed-in user. Default 1000. */
|
|
63
|
-
user?: number;
|
|
64
|
-
/** Per IP, for requests with no principal at all. Default 300. */
|
|
65
|
-
anonymous?: number;
|
|
66
|
-
/** Share counts across replicas. Defaults to this process's memory. */
|
|
67
|
-
store?: RateLimitStore;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Rate limiting for the data API.
|
|
71
|
-
*
|
|
72
|
-
* Every request is in exactly one bucket, resolved most-specific first: an API
|
|
73
|
-
* key by its id, a signed-in user by their uid, anyone else by IP. Previously
|
|
74
|
-
* only the first of those was limited at all — the middleware returned early
|
|
75
|
-
* for any request without an API key — so JWT and anonymous traffic to
|
|
76
|
-
* `/api/data/*` was unbounded, which is most of the traffic a BaaS gets.
|
|
77
|
-
*
|
|
78
|
-
* Per bucket, not per route: the point is to bound what one caller costs, and
|
|
79
|
-
* they can spend it wherever they like.
|
|
80
|
-
*
|
|
81
|
-
* The defaults are deliberately loose. This is a floor against a runaway client
|
|
82
|
-
* or a naive scraper, not a quota — a deployment that wants real quotas should
|
|
83
|
-
* set them, and one that already has a proxy doing this should pass
|
|
84
|
-
* `enabled: false` rather than pay for it twice.
|
|
85
|
-
*/
|
|
86
|
-
export declare function createDataRateLimiter(config?: DataRateLimitConfig): MiddlewareHandler<HonoEnv>;
|
|
87
39
|
/**
|
|
88
40
|
* Create a rate limiter specifically for API key requests.
|
|
89
41
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
42
|
+
* When a request is authenticated via an API key that has a `rate_limit`
|
|
43
|
+
* configured, this limiter enforces per-key limits using the key's ID
|
|
44
|
+
* as the rate limit bucket.
|
|
93
45
|
*
|
|
94
46
|
* @param defaultLimit - Fallback limit when the key has no `rate_limit` set.
|
|
95
47
|
* @param windowMs - Time window in milliseconds (default: 15 minutes).
|