@dupecom/botcha-cloudflare 0.3.3 → 0.10.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.
- package/dist/analytics.d.ts +60 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +130 -0
- package/dist/apps.d.ts +159 -0
- package/dist/apps.d.ts.map +1 -0
- package/dist/apps.js +307 -0
- package/dist/auth.d.ts +93 -6
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +251 -9
- package/dist/challenges.d.ts +31 -7
- package/dist/challenges.d.ts.map +1 -1
- package/dist/challenges.js +551 -144
- package/dist/dashboard/api.d.ts +70 -0
- package/dist/dashboard/api.d.ts.map +1 -0
- package/dist/dashboard/api.js +546 -0
- package/dist/dashboard/auth.d.ts +183 -0
- package/dist/dashboard/auth.d.ts.map +1 -0
- package/dist/dashboard/auth.js +401 -0
- package/dist/dashboard/device-code.d.ts +43 -0
- package/dist/dashboard/device-code.d.ts.map +1 -0
- package/dist/dashboard/device-code.js +77 -0
- package/dist/dashboard/index.d.ts +31 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +64 -0
- package/dist/dashboard/layout.d.ts +47 -0
- package/dist/dashboard/layout.d.ts.map +1 -0
- package/dist/dashboard/layout.js +38 -0
- package/dist/dashboard/pages.d.ts +11 -0
- package/dist/dashboard/pages.d.ts.map +1 -0
- package/dist/dashboard/pages.js +18 -0
- package/dist/dashboard/styles.d.ts +11 -0
- package/dist/dashboard/styles.d.ts.map +1 -0
- package/dist/dashboard/styles.js +633 -0
- package/dist/email.d.ts +44 -0
- package/dist/email.d.ts.map +1 -0
- package/dist/email.js +119 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +644 -50
- package/dist/rate-limit.d.ts +11 -1
- package/dist/rate-limit.d.ts.map +1 -1
- package/dist/rate-limit.js +13 -2
- package/dist/routes/stream.js +1 -1
- package/dist/static.d.ts +728 -0
- package/dist/static.d.ts.map +1 -0
- package/dist/static.js +818 -0
- package/package.json +1 -1
package/dist/rate-limit.d.ts
CHANGED
|
@@ -16,8 +16,18 @@ export interface RateLimitResult {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Check and enforce rate limits
|
|
19
|
+
*
|
|
20
|
+
* @param kv - KV namespace for rate limit storage
|
|
21
|
+
* @param identifier - IP address (used when app_id is not provided)
|
|
22
|
+
* @param limit - Requests per hour limit (default: 100)
|
|
23
|
+
* @param app_id - Optional app ID for app-scoped rate limiting
|
|
24
|
+
*
|
|
25
|
+
* When app_id is provided, rate limiting is scoped to the app (uses 'rate:app:{app_id}' key).
|
|
26
|
+
* When app_id is not provided, rate limiting is scoped to IP (uses 'ratelimit:{ip}' key).
|
|
27
|
+
*
|
|
28
|
+
* App-scoped rate limiting takes precedence over IP-based rate limiting.
|
|
19
29
|
*/
|
|
20
|
-
export declare function checkRateLimit(kv: KVNamespace | undefined, identifier: string, limit?: number): Promise<RateLimitResult>;
|
|
30
|
+
export declare function checkRateLimit(kv: KVNamespace | undefined, identifier: string, limit?: number, app_id?: string): Promise<RateLimitResult>;
|
|
21
31
|
/**
|
|
22
32
|
* Extract client IP from request
|
|
23
33
|
*/
|
package/dist/rate-limit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../src/rate-limit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../src/rate-limit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,EAAE,EAAE,WAAW,GAAG,SAAS,EAC3B,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,MAAY,EACnB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,CAAC,CA+E1B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAapD"}
|
package/dist/rate-limit.js
CHANGED
|
@@ -5,8 +5,18 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* Check and enforce rate limits
|
|
8
|
+
*
|
|
9
|
+
* @param kv - KV namespace for rate limit storage
|
|
10
|
+
* @param identifier - IP address (used when app_id is not provided)
|
|
11
|
+
* @param limit - Requests per hour limit (default: 100)
|
|
12
|
+
* @param app_id - Optional app ID for app-scoped rate limiting
|
|
13
|
+
*
|
|
14
|
+
* When app_id is provided, rate limiting is scoped to the app (uses 'rate:app:{app_id}' key).
|
|
15
|
+
* When app_id is not provided, rate limiting is scoped to IP (uses 'ratelimit:{ip}' key).
|
|
16
|
+
*
|
|
17
|
+
* App-scoped rate limiting takes precedence over IP-based rate limiting.
|
|
8
18
|
*/
|
|
9
|
-
export async function checkRateLimit(kv, identifier, limit = 100) {
|
|
19
|
+
export async function checkRateLimit(kv, identifier, limit = 100, app_id) {
|
|
10
20
|
if (!kv) {
|
|
11
21
|
// No KV = no rate limiting (local dev)
|
|
12
22
|
return {
|
|
@@ -15,7 +25,8 @@ export async function checkRateLimit(kv, identifier, limit = 100) {
|
|
|
15
25
|
resetAt: Date.now() + 3600000,
|
|
16
26
|
};
|
|
17
27
|
}
|
|
18
|
-
|
|
28
|
+
// Use app-scoped key if app_id provided, otherwise use IP-based key
|
|
29
|
+
const key = app_id ? `rate:app:${app_id}` : `ratelimit:${identifier}`;
|
|
19
30
|
const now = Date.now();
|
|
20
31
|
const windowStart = now - 3600000; // 1 hour ago
|
|
21
32
|
try {
|
package/dist/routes/stream.js
CHANGED
|
@@ -158,7 +158,7 @@ app.post('/v1/challenge/stream/:session', async (c) => {
|
|
|
158
158
|
problems,
|
|
159
159
|
timeLimit: 500,
|
|
160
160
|
timerStart, // Include so client can verify timing
|
|
161
|
-
instructions: 'Compute SHA256 of each number, return first 8 hex chars',
|
|
161
|
+
instructions: 'Compute SHA256 of each number, return first 8 hex chars. Tip: compute all hashes and submit in a single HTTP request.',
|
|
162
162
|
},
|
|
163
163
|
});
|
|
164
164
|
}
|