@hoox-sh/hoox-shared 1.3.0 → 1.5.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/README.md +6 -0
- package/dist/agent-config-fields.js +23 -29
- package/dist/analytics.d.ts +3 -4
- package/dist/analytics.d.ts.map +1 -1
- package/dist/analytics.js +56 -16
- package/dist/api-client.js +12 -21
- package/dist/colors.js +5 -21
- package/dist/config.js +11 -27
- package/dist/cron-handler.js +0 -16
- package/dist/d1/index.js +12 -27
- package/dist/d1/repository.js +7 -21
- package/dist/d1/schemas.js +4 -20
- package/dist/dashboard-manifest.d.ts +2 -1
- package/dist/dashboard-manifest.d.ts.map +1 -1
- package/dist/dashboard-manifest.js +37 -33
- package/dist/entitlements.d.ts +46 -0
- package/dist/entitlements.d.ts.map +1 -0
- package/dist/entitlements.js +15 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +11 -25
- package/dist/exchange-client.js +2 -18
- package/dist/exchanges/base-exchange-client.js +0 -16
- package/dist/exchanges/index.js +0 -16
- package/dist/format-time.js +2 -18
- package/dist/formatters.js +12 -28
- package/dist/health.js +7 -21
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3895 -3653
- package/dist/kill-switch.js +14 -20
- package/dist/kvKeys.d.ts +11 -0
- package/dist/kvKeys.d.ts.map +1 -1
- package/dist/kvKeys.js +44 -45
- package/dist/kvUtils.d.ts +34 -1
- package/dist/kvUtils.d.ts.map +1 -1
- package/dist/kvUtils.js +60 -23
- package/dist/legal.js +5 -21
- package/dist/middleware/auth.d.ts +6 -3
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +27 -29
- package/dist/middleware/cors.js +4 -20
- package/dist/middleware/index.d.ts +3 -2
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +222 -164
- package/dist/middleware/logger.js +13 -27
- package/dist/middleware/rate-limit.js +2 -18
- package/dist/middleware/security-headers.js +2 -18
- package/dist/middleware/validate.d.ts +16 -0
- package/dist/middleware/validate.d.ts.map +1 -1
- package/dist/middleware/validate.js +39 -19
- package/dist/middleware/wait-until.d.ts +32 -0
- package/dist/middleware/wait-until.d.ts.map +1 -0
- package/dist/middleware/wait-until.js +30 -0
- package/dist/operator-transport.js +13 -17
- package/dist/path-utils.js +15 -31
- package/dist/queue-handler.d.ts +6 -0
- package/dist/queue-handler.d.ts.map +1 -1
- package/dist/queue-handler.js +51 -36
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +12 -18
- package/dist/schemas/index.d.ts +2 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +91 -38
- package/dist/schemas/registry.d.ts +13 -0
- package/dist/schemas/registry.d.ts.map +1 -1
- package/dist/schemas/registry.js +82 -30
- package/dist/schemas/types.d.ts +5 -0
- package/dist/schemas/types.d.ts.map +1 -1
- package/dist/schemas/validators.d.ts.map +1 -1
- package/dist/schemas/validators.js +8 -22
- package/dist/service-bindings.js +31 -34
- package/dist/session.js +2 -18
- package/dist/sse.js +10 -18
- package/dist/stores/config-store.js +8 -22
- package/dist/stores/service-store.js +17 -30
- package/dist/stores/ui-store.js +0 -16
- package/dist/tenant.d.ts +61 -0
- package/dist/tenant.d.ts.map +1 -0
- package/dist/tenant.js +56 -0
- package/dist/test-utils.js +11 -27
- package/dist/types.d.ts +26 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +16 -26
- package/dist/wizard/engine.d.ts.map +1 -1
- package/dist/wizard/engine.js +39 -56
- package/dist/wizard/index.d.ts +1 -0
- package/dist/wizard/index.d.ts.map +1 -1
- package/dist/wizard/index.js +54 -68
- package/dist/wizard/persistence.d.ts +4 -0
- package/dist/wizard/persistence.d.ts.map +1 -1
- package/dist/wizard/persistence.js +7 -19
- package/dist/wizard/presets.d.ts.map +1 -1
- package/dist/wizard/presets.js +16 -54
- package/dist/wizard/types.d.ts +6 -0
- package/dist/wizard/types.d.ts.map +1 -1
- package/dist/wizard/types.js +5 -0
- package/package.json +7 -2
package/dist/kill-switch.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
|
|
18
2
|
// src/kvKeys.ts
|
|
19
3
|
var KV_TRADE_DEFAULT_LEVERAGE = "trade:default_leverage";
|
|
20
4
|
var KV_TRADE_MAX_POSITION_SIZE = "trade:max_position_size";
|
|
@@ -26,6 +10,11 @@ var KV_BOT_ENABLED = "bot:enabled";
|
|
|
26
10
|
var KV_BOT_DEFAULT_CHAT_ID = "bot:default_chat_id";
|
|
27
11
|
var KV_BOT_NOTIFY_ON_EXECUTION = "bot:notify_on_execution";
|
|
28
12
|
var KV_BOT_NOTIFY_ON_ERROR = "bot:notify_on_error";
|
|
13
|
+
var KV_BOT_NOTIFY_ON_STARTUP = "bot:notify_on_startup";
|
|
14
|
+
var KV_BOT_AI_SUMMARIES_ENABLED = "bot:ai_summaries_enabled";
|
|
15
|
+
var KV_BOT_SUMMARY_STYLE = "bot:summary_style";
|
|
16
|
+
var KV_BOT_INCLUDE_PNL = "bot:include_pnl";
|
|
17
|
+
var KV_TELEGRAM_ALLOWED_CHAT_IDS = "telegram:allowed_chat_ids";
|
|
29
18
|
var KV_WEBHOOK_IP_CHECK_ENABLED = "webhook:tradingview:ip_check_enabled";
|
|
30
19
|
var KV_WEBHOOK_ALLOWED_IPS = "webhook:tradingview:allowed_ips";
|
|
31
20
|
var KV_WEBHOOK_QUEUE_MODE = "webhook:queue_mode";
|
|
@@ -56,6 +45,11 @@ var KVKeys = {
|
|
|
56
45
|
KV_BOT_DEFAULT_CHAT_ID,
|
|
57
46
|
KV_BOT_NOTIFY_ON_EXECUTION,
|
|
58
47
|
KV_BOT_NOTIFY_ON_ERROR,
|
|
48
|
+
KV_BOT_NOTIFY_ON_STARTUP,
|
|
49
|
+
KV_BOT_AI_SUMMARIES_ENABLED,
|
|
50
|
+
KV_BOT_SUMMARY_STYLE,
|
|
51
|
+
KV_BOT_INCLUDE_PNL,
|
|
52
|
+
KV_TELEGRAM_ALLOWED_CHAT_IDS,
|
|
59
53
|
KV_WEBHOOK_IP_CHECK_ENABLED,
|
|
60
54
|
KV_WEBHOOK_ALLOWED_IPS,
|
|
61
55
|
KV_WEBHOOK_QUEUE_MODE,
|
|
@@ -122,9 +116,9 @@ async function isTradingPaused(kv, options) {
|
|
|
122
116
|
return result.enabled;
|
|
123
117
|
}
|
|
124
118
|
export {
|
|
125
|
-
|
|
126
|
-
isTradingPaused,
|
|
127
|
-
checkKillSwitch,
|
|
119
|
+
KILL_SWITCH_ACTIVE_PREFIX,
|
|
128
120
|
KILL_SWITCH_KEYS,
|
|
129
|
-
|
|
121
|
+
checkKillSwitch,
|
|
122
|
+
isTradingPaused,
|
|
123
|
+
isTruthyKillSwitchFlag
|
|
130
124
|
};
|
package/dist/kvKeys.d.ts
CHANGED
|
@@ -25,6 +25,12 @@ export declare const KV_BOT_ENABLED = "bot:enabled";
|
|
|
25
25
|
export declare const KV_BOT_DEFAULT_CHAT_ID = "bot:default_chat_id";
|
|
26
26
|
export declare const KV_BOT_NOTIFY_ON_EXECUTION = "bot:notify_on_execution";
|
|
27
27
|
export declare const KV_BOT_NOTIFY_ON_ERROR = "bot:notify_on_error";
|
|
28
|
+
export declare const KV_BOT_NOTIFY_ON_STARTUP = "bot:notify_on_startup";
|
|
29
|
+
export declare const KV_BOT_AI_SUMMARIES_ENABLED = "bot:ai_summaries_enabled";
|
|
30
|
+
export declare const KV_BOT_SUMMARY_STYLE = "bot:summary_style";
|
|
31
|
+
export declare const KV_BOT_INCLUDE_PNL = "bot:include_pnl";
|
|
32
|
+
/** JSON array of string|number — gateway notify chatId allowlist (fail-closed). */
|
|
33
|
+
export declare const KV_TELEGRAM_ALLOWED_CHAT_IDS = "telegram:allowed_chat_ids";
|
|
28
34
|
export declare const KV_WEBHOOK_IP_CHECK_ENABLED = "webhook:tradingview:ip_check_enabled";
|
|
29
35
|
export declare const KV_WEBHOOK_ALLOWED_IPS = "webhook:tradingview:allowed_ips";
|
|
30
36
|
export declare const KV_WEBHOOK_QUEUE_MODE = "webhook:queue_mode";
|
|
@@ -55,6 +61,11 @@ export declare const KVKeys: {
|
|
|
55
61
|
KV_BOT_DEFAULT_CHAT_ID: string;
|
|
56
62
|
KV_BOT_NOTIFY_ON_EXECUTION: string;
|
|
57
63
|
KV_BOT_NOTIFY_ON_ERROR: string;
|
|
64
|
+
KV_BOT_NOTIFY_ON_STARTUP: string;
|
|
65
|
+
KV_BOT_AI_SUMMARIES_ENABLED: string;
|
|
66
|
+
KV_BOT_SUMMARY_STYLE: string;
|
|
67
|
+
KV_BOT_INCLUDE_PNL: string;
|
|
68
|
+
KV_TELEGRAM_ALLOWED_CHAT_IDS: string;
|
|
58
69
|
KV_WEBHOOK_IP_CHECK_ENABLED: string;
|
|
59
70
|
KV_WEBHOOK_ALLOWED_IPS: string;
|
|
60
71
|
KV_WEBHOOK_QUEUE_MODE: string;
|
package/dist/kvKeys.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kvKeys.d.ts","sourceRoot":"","sources":["../src/kvKeys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAGH,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAClE,eAAO,MAAM,0BAA0B,4BAA4B,CAAC;AACpE,eAAO,MAAM,mCAAmC,qCACZ,CAAC;AACrC,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAC5E,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AACxD,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAGhD,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAC5C,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;AAC5D,eAAO,MAAM,0BAA0B,4BAA4B,CAAC;AACpE,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"kvKeys.d.ts","sourceRoot":"","sources":["../src/kvKeys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAGH,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAClE,eAAO,MAAM,0BAA0B,4BAA4B,CAAC;AACpE,eAAO,MAAM,mCAAmC,qCACZ,CAAC;AACrC,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAC5E,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AACxD,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAGhD,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAC5C,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;AAC5D,eAAO,MAAM,0BAA0B,4BAA4B,CAAC;AACpE,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;AAC5D,eAAO,MAAM,wBAAwB,0BAA0B,CAAC;AAChE,eAAO,MAAM,2BAA2B,6BAA6B,CAAC;AACtE,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AACxD,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AACpD,mFAAmF;AACnF,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AAGxE,eAAO,MAAM,2BAA2B,yCACA,CAAC;AACzC,eAAO,MAAM,sBAAsB,oCAAoC,CAAC;AACxE,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAG1D,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAC1D,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAClD,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAC1D,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAC9D,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AAGxE,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAC9C,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AACtD,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;AAC5D,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAGtD,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAG5E,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAC1D,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAC9C,eAAO,MAAM,0BAA0B,4BAA4B,CAAC;AAGpE,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AACxD,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAKpD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmClB,CAAC"}
|
package/dist/kvKeys.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
|
|
18
2
|
// src/kvKeys.ts
|
|
19
3
|
var KV_TRADE_DEFAULT_LEVERAGE = "trade:default_leverage";
|
|
20
4
|
var KV_TRADE_MAX_POSITION_SIZE = "trade:max_position_size";
|
|
@@ -26,6 +10,11 @@ var KV_BOT_ENABLED = "bot:enabled";
|
|
|
26
10
|
var KV_BOT_DEFAULT_CHAT_ID = "bot:default_chat_id";
|
|
27
11
|
var KV_BOT_NOTIFY_ON_EXECUTION = "bot:notify_on_execution";
|
|
28
12
|
var KV_BOT_NOTIFY_ON_ERROR = "bot:notify_on_error";
|
|
13
|
+
var KV_BOT_NOTIFY_ON_STARTUP = "bot:notify_on_startup";
|
|
14
|
+
var KV_BOT_AI_SUMMARIES_ENABLED = "bot:ai_summaries_enabled";
|
|
15
|
+
var KV_BOT_SUMMARY_STYLE = "bot:summary_style";
|
|
16
|
+
var KV_BOT_INCLUDE_PNL = "bot:include_pnl";
|
|
17
|
+
var KV_TELEGRAM_ALLOWED_CHAT_IDS = "telegram:allowed_chat_ids";
|
|
29
18
|
var KV_WEBHOOK_IP_CHECK_ENABLED = "webhook:tradingview:ip_check_enabled";
|
|
30
19
|
var KV_WEBHOOK_ALLOWED_IPS = "webhook:tradingview:allowed_ips";
|
|
31
20
|
var KV_WEBHOOK_QUEUE_MODE = "webhook:queue_mode";
|
|
@@ -56,6 +45,11 @@ var KVKeys = {
|
|
|
56
45
|
KV_BOT_DEFAULT_CHAT_ID,
|
|
57
46
|
KV_BOT_NOTIFY_ON_EXECUTION,
|
|
58
47
|
KV_BOT_NOTIFY_ON_ERROR,
|
|
48
|
+
KV_BOT_NOTIFY_ON_STARTUP,
|
|
49
|
+
KV_BOT_AI_SUMMARIES_ENABLED,
|
|
50
|
+
KV_BOT_SUMMARY_STYLE,
|
|
51
|
+
KV_BOT_INCLUDE_PNL,
|
|
52
|
+
KV_TELEGRAM_ALLOWED_CHAT_IDS,
|
|
59
53
|
KV_WEBHOOK_IP_CHECK_ENABLED,
|
|
60
54
|
KV_WEBHOOK_ALLOWED_IPS,
|
|
61
55
|
KV_WEBHOOK_QUEUE_MODE,
|
|
@@ -77,34 +71,39 @@ var KVKeys = {
|
|
|
77
71
|
QUEUE_MODE_DISABLED
|
|
78
72
|
};
|
|
79
73
|
export {
|
|
80
|
-
|
|
81
|
-
QUEUE_MODE_EVERYWHERE,
|
|
82
|
-
QUEUE_MODE_DISABLED,
|
|
83
|
-
KV_WEBHOOK_QUEUE_MODE,
|
|
84
|
-
KV_WEBHOOK_IP_CHECK_ENABLED,
|
|
85
|
-
KV_WEBHOOK_ALLOWED_IPS,
|
|
86
|
-
KV_TRADE_TRAILING_STOP_PERCENT,
|
|
87
|
-
KV_TRADE_ROUTING,
|
|
88
|
-
KV_TRADE_MAX_POSITION_SIZE,
|
|
89
|
-
KV_TRADE_MAX_DAILY_DRAWDOWN_PERCENT,
|
|
90
|
-
KV_TRADE_KILL_SWITCH,
|
|
91
|
-
KV_TRADE_DEFAULT_LEVERAGE,
|
|
92
|
-
KV_HOUSEKEEPING_LAST_CHECK,
|
|
93
|
-
KV_HEALTH_CHECK,
|
|
94
|
-
KV_GLOBAL_KILL_SWITCH,
|
|
95
|
-
KV_EMAIL_USE_IMAP,
|
|
96
|
-
KV_EMAIL_SCAN_SUBJECT,
|
|
97
|
-
KV_EMAIL_QUANTITY_MULTIPLIER,
|
|
98
|
-
KV_EMAIL_COIN_PATTERN,
|
|
99
|
-
KV_EMAIL_ACTION_PATTERN,
|
|
100
|
-
KV_DASHBOARD_AI_HEALTH_SUMMARY,
|
|
101
|
-
KV_BOT_NOTIFY_ON_EXECUTION,
|
|
102
|
-
KV_BOT_NOTIFY_ON_ERROR,
|
|
103
|
-
KV_BOT_ENABLED,
|
|
104
|
-
KV_BOT_DEFAULT_CHAT_ID,
|
|
105
|
-
KV_AGENT_OPENAI_KEY,
|
|
106
|
-
KV_AGENT_GOOGLE_KEY,
|
|
107
|
-
KV_AGENT_CONFIG,
|
|
74
|
+
KVKeys,
|
|
108
75
|
KV_AGENT_ANTHROPIC_KEY,
|
|
109
|
-
|
|
76
|
+
KV_AGENT_CONFIG,
|
|
77
|
+
KV_AGENT_GOOGLE_KEY,
|
|
78
|
+
KV_AGENT_OPENAI_KEY,
|
|
79
|
+
KV_BOT_AI_SUMMARIES_ENABLED,
|
|
80
|
+
KV_BOT_DEFAULT_CHAT_ID,
|
|
81
|
+
KV_BOT_ENABLED,
|
|
82
|
+
KV_BOT_INCLUDE_PNL,
|
|
83
|
+
KV_BOT_NOTIFY_ON_ERROR,
|
|
84
|
+
KV_BOT_NOTIFY_ON_EXECUTION,
|
|
85
|
+
KV_BOT_NOTIFY_ON_STARTUP,
|
|
86
|
+
KV_BOT_SUMMARY_STYLE,
|
|
87
|
+
KV_DASHBOARD_AI_HEALTH_SUMMARY,
|
|
88
|
+
KV_EMAIL_ACTION_PATTERN,
|
|
89
|
+
KV_EMAIL_COIN_PATTERN,
|
|
90
|
+
KV_EMAIL_QUANTITY_MULTIPLIER,
|
|
91
|
+
KV_EMAIL_SCAN_SUBJECT,
|
|
92
|
+
KV_EMAIL_USE_IMAP,
|
|
93
|
+
KV_GLOBAL_KILL_SWITCH,
|
|
94
|
+
KV_HEALTH_CHECK,
|
|
95
|
+
KV_HOUSEKEEPING_LAST_CHECK,
|
|
96
|
+
KV_TELEGRAM_ALLOWED_CHAT_IDS,
|
|
97
|
+
KV_TRADE_DEFAULT_LEVERAGE,
|
|
98
|
+
KV_TRADE_KILL_SWITCH,
|
|
99
|
+
KV_TRADE_MAX_DAILY_DRAWDOWN_PERCENT,
|
|
100
|
+
KV_TRADE_MAX_POSITION_SIZE,
|
|
101
|
+
KV_TRADE_ROUTING,
|
|
102
|
+
KV_TRADE_TRAILING_STOP_PERCENT,
|
|
103
|
+
KV_WEBHOOK_ALLOWED_IPS,
|
|
104
|
+
KV_WEBHOOK_IP_CHECK_ENABLED,
|
|
105
|
+
KV_WEBHOOK_QUEUE_MODE,
|
|
106
|
+
QUEUE_MODE_DISABLED,
|
|
107
|
+
QUEUE_MODE_EVERYWHERE,
|
|
108
|
+
QUEUE_MODE_FAILOVER
|
|
110
109
|
};
|
package/dist/kvUtils.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Utility functions for KV operations
|
|
7
|
-
* Shared across workers that need KV timestamp logging
|
|
7
|
+
* Shared across workers that need KV timestamp logging and parallel I/O
|
|
8
8
|
*/
|
|
9
9
|
import type { KVNamespace } from "@cloudflare/workers-types";
|
|
10
10
|
/**
|
|
@@ -21,6 +21,39 @@ export interface EnvWithKV {
|
|
|
21
21
|
* @returns Promise that resolves when the operation completes
|
|
22
22
|
*/
|
|
23
23
|
export declare function logKvTimestamp(env: EnvWithKV, prefix?: string): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Max keys per Workers KV bulk read (platform limit).
|
|
26
|
+
* @see https://developers.cloudflare.com/kv/api/read-key-value-pairs/
|
|
27
|
+
*/
|
|
28
|
+
export declare const KV_BULK_GET_MAX_KEYS = 100;
|
|
29
|
+
/**
|
|
30
|
+
* Parallel / bulk KV gets — prefer over sequential `await kv.get` loops.
|
|
31
|
+
* Order of returned values matches `keys`.
|
|
32
|
+
*
|
|
33
|
+
* Uses native `kv.get(string[])` bulk reads (up to 100 keys per call) when
|
|
34
|
+
* available. Bulk reads count as a single operation against the Workers
|
|
35
|
+
* subrequest limit and avoid simultaneous-connection pressure.
|
|
36
|
+
* Falls back to `Promise.all` of individual gets for mocks / older runtimes.
|
|
37
|
+
*/
|
|
38
|
+
export declare function kvGetMany(kv: KVNamespace, keys: readonly string[]): Promise<Array<string | null>>;
|
|
39
|
+
/**
|
|
40
|
+
* Parallel KV gets as a record keyed by the original key names.
|
|
41
|
+
*/
|
|
42
|
+
export declare function kvGetManyAsRecord(kv: KVNamespace, keys: readonly string[]): Promise<Record<string, string | null>>;
|
|
43
|
+
export interface KvPutEntry {
|
|
44
|
+
key: string;
|
|
45
|
+
value: string;
|
|
46
|
+
options?: {
|
|
47
|
+
expirationTtl?: number;
|
|
48
|
+
expiration?: number;
|
|
49
|
+
metadata?: Record<string, unknown>;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Parallel KV puts — prefer over sequential `await kv.put` loops
|
|
54
|
+
* when writes are independent (no read-modify-write races).
|
|
55
|
+
*/
|
|
56
|
+
export declare function kvPutMany(kv: KVNamespace, entries: readonly KvPutEntry[]): Promise<void>;
|
|
24
57
|
/**
|
|
25
58
|
* Helper function to convert Headers to a plain object
|
|
26
59
|
* @param headers - The Headers object to convert
|
package/dist/kvUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kvUtils.d.ts","sourceRoot":"","sources":["../src/kvUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAG7D;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,WAAW,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,SAAS,EACd,MAAM,GAAE,MAAoB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAUf;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAClC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBxB"}
|
|
1
|
+
{"version":3,"file":"kvUtils.d.ts","sourceRoot":"","sources":["../src/kvUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAG7D;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,WAAW,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,SAAS,EACd,MAAM,GAAE,MAAoB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAUf;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAyBxC;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CA0B/B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAOxC;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,CAAC;CACH;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAC7B,EAAE,EAAE,WAAW,EACf,OAAO,EAAE,SAAS,UAAU,EAAE,GAC7B,OAAO,CAAC,IAAI,CAAC,CAKf;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAClC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBxB"}
|
package/dist/kvUtils.js
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
|
|
18
2
|
// src/errors.ts
|
|
19
3
|
function toError(err, fallback = "Unknown error") {
|
|
20
4
|
if (err instanceof Error)
|
|
21
5
|
return err.message;
|
|
22
6
|
if (typeof err === "string")
|
|
23
7
|
return err;
|
|
24
|
-
if (err && typeof err === "object" && "message" in err
|
|
25
|
-
|
|
8
|
+
if (err && typeof err === "object" && "message" in err) {
|
|
9
|
+
const message = err.message;
|
|
10
|
+
if (typeof message === "string")
|
|
11
|
+
return message;
|
|
26
12
|
}
|
|
27
13
|
if (err === null || err === undefined)
|
|
28
14
|
return fallback;
|
|
@@ -70,14 +56,14 @@ function sanitizeOutput(data) {
|
|
|
70
56
|
const obj = data;
|
|
71
57
|
const keys = Object.keys(obj);
|
|
72
58
|
if (keys.length < 10) {
|
|
73
|
-
const
|
|
59
|
+
const sanitized = {};
|
|
74
60
|
for (const k of keys) {
|
|
75
61
|
if (k === "stack" || k === "cause")
|
|
76
62
|
continue;
|
|
77
63
|
const v = obj[k];
|
|
78
|
-
|
|
64
|
+
sanitized[k] = v instanceof Error ? { name: v.name, message: v.message } : sanitizeOutput(v);
|
|
79
65
|
}
|
|
80
|
-
return
|
|
66
|
+
return sanitized;
|
|
81
67
|
}
|
|
82
68
|
if (!hasSensitiveFields(obj) && !hasErrorValues(obj)) {
|
|
83
69
|
return obj;
|
|
@@ -151,6 +137,53 @@ async function logKvTimestamp(env, prefix = "timestamp") {
|
|
|
151
137
|
console.error(`Failed to log timestamp to KV: ${toError(error, "Unknown error")}`);
|
|
152
138
|
}
|
|
153
139
|
}
|
|
140
|
+
var KV_BULK_GET_MAX_KEYS = 100;
|
|
141
|
+
async function tryBulkGetChunk(kv, chunk) {
|
|
142
|
+
try {
|
|
143
|
+
const result = await kv.get([...chunk]);
|
|
144
|
+
if (!(result instanceof Map)) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
return chunk.map((key) => result.get(key) ?? null);
|
|
148
|
+
} catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function kvGetMany(kv, keys) {
|
|
153
|
+
if (keys.length === 0)
|
|
154
|
+
return [];
|
|
155
|
+
const out = new Array(keys.length);
|
|
156
|
+
let offset = 0;
|
|
157
|
+
while (offset < keys.length) {
|
|
158
|
+
const chunk = keys.slice(offset, offset + KV_BULK_GET_MAX_KEYS);
|
|
159
|
+
const bulk = await tryBulkGetChunk(kv, chunk);
|
|
160
|
+
if (bulk === null) {
|
|
161
|
+
const rest = await Promise.all(keys.slice(offset).map((key) => kv.get(key)));
|
|
162
|
+
for (let i = 0;i < rest.length; i++) {
|
|
163
|
+
out[offset + i] = rest[i] ?? null;
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
for (let i = 0;i < bulk.length; i++) {
|
|
168
|
+
out[offset + i] = bulk[i] ?? null;
|
|
169
|
+
}
|
|
170
|
+
offset += chunk.length;
|
|
171
|
+
}
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
async function kvGetManyAsRecord(kv, keys) {
|
|
175
|
+
const values = await kvGetMany(kv, keys);
|
|
176
|
+
const out = {};
|
|
177
|
+
for (let i = 0;i < keys.length; i++) {
|
|
178
|
+
out[keys[i]] = values[i] ?? null;
|
|
179
|
+
}
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
182
|
+
async function kvPutMany(kv, entries) {
|
|
183
|
+
if (entries.length === 0)
|
|
184
|
+
return;
|
|
185
|
+
await Promise.all(entries.map((entry) => kv.put(entry.key, entry.value, entry.options)));
|
|
186
|
+
}
|
|
154
187
|
function headersToObject(headers) {
|
|
155
188
|
const result = {};
|
|
156
189
|
if (!headers)
|
|
@@ -165,6 +198,10 @@ function headersToObject(headers) {
|
|
|
165
198
|
return result;
|
|
166
199
|
}
|
|
167
200
|
export {
|
|
168
|
-
|
|
169
|
-
headersToObject
|
|
201
|
+
KV_BULK_GET_MAX_KEYS,
|
|
202
|
+
headersToObject,
|
|
203
|
+
kvGetMany,
|
|
204
|
+
kvGetManyAsRecord,
|
|
205
|
+
kvPutMany,
|
|
206
|
+
logKvTimestamp
|
|
170
207
|
};
|
package/dist/legal.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
|
|
18
2
|
// src/legal.ts
|
|
19
3
|
var COPYRIGHT = `Copyright (C) ${new Date().getFullYear()} Hoox Team. All rights reserved.`;
|
|
20
4
|
var TRADEMARKS = [
|
|
@@ -31,10 +15,10 @@ ${TRADEMARK_NOTICE}
|
|
|
31
15
|
${DISCLAIMER}`;
|
|
32
16
|
var DISCLAIMER_HEADER = "X-Disclaimer";
|
|
33
17
|
export {
|
|
34
|
-
|
|
35
|
-
TRADEMARKS,
|
|
36
|
-
FULL_LEGAL_NOTICE,
|
|
37
|
-
DISCLAIMER_HEADER,
|
|
18
|
+
COPYRIGHT,
|
|
38
19
|
DISCLAIMER,
|
|
39
|
-
|
|
20
|
+
DISCLAIMER_HEADER,
|
|
21
|
+
FULL_LEGAL_NOTICE,
|
|
22
|
+
TRADEMARKS,
|
|
23
|
+
TRADEMARK_NOTICE
|
|
40
24
|
};
|
|
@@ -11,14 +11,17 @@ import type { MiddlewareHandler } from "../types/router";
|
|
|
11
11
|
/**
|
|
12
12
|
* Constant-time string comparison to prevent timing attacks.
|
|
13
13
|
*
|
|
14
|
-
* Length is NOT short-circuited: both strings are
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Length is NOT short-circuited: both strings are padded to equal length
|
|
15
|
+
* and XOR-folded so unequal lengths do not leak via early return
|
|
16
|
+
* (length oracle). Prefer {@link timingSafeEqualAsync} when Web Crypto
|
|
17
|
+
* is available — it hashes both sides to fixed-size digests first
|
|
18
|
+
* (Cloudflare Workers best practice).
|
|
17
19
|
*
|
|
18
20
|
* Note: true crypto.subtle.timingSafeEqual needs equal-length ArrayBuffers;
|
|
19
21
|
* we pad both encodings to the same max length before XOR comparison.
|
|
20
22
|
*/
|
|
21
23
|
export declare function timingSafeEqual(a: string, b: string): boolean;
|
|
24
|
+
export declare function timingSafeEqualAsync(a: string, b: string): Promise<boolean>;
|
|
22
25
|
/**
|
|
23
26
|
* Environment bindings accepted for operator Bearer auth.
|
|
24
27
|
* Prefer OPERATOR_API_KEY; INTERNAL_API_KEY remains a legacy alias.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAe7D;AAmBD,wBAAsB,oBAAoB,CACxC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,OAAO,CAAC,OAAO,CAAC,CAelB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,eAAe,GAAG,GAAG,GACzB,MAAM,GAAG,SAAS,CAUpB;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,GAAG,eAAe,GACzB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAE1B;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,eAAe,GAAG,GAAG,GACzB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAyB1B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,IAAI,iBAAiB,CAAC,eAAe,CAAC,CAUjF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;AAS7D,6FAA6F;AAC7F,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,mBAAmB,GAC5B,MAAM,EAAE,CASV;AAiCD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,eAAe,EACpB,OAAO,GAAE,mBAA4C,GACpD,QAAQ,GAAG,IAAI,CAcjB;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,mBAA4C,GACpD,iBAAiB,CAAC,eAAe,CAAC,CAoBpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,eAAe,EACpB,OAAO,GAAE,mBAA4C,GACpD;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAezC"}
|
package/dist/middleware/auth.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
|
|
18
2
|
// src/middleware/auth.ts
|
|
19
3
|
function timingSafeEqual(a, b) {
|
|
20
4
|
const encoder = new TextEncoder;
|
|
@@ -23,12 +7,24 @@ function timingSafeEqual(a, b) {
|
|
|
23
7
|
const len = Math.max(aBuf.length, bBuf.length);
|
|
24
8
|
let result = aBuf.length === bBuf.length ? 0 : 1;
|
|
25
9
|
for (let i = 0;i < len; i++) {
|
|
26
|
-
const av =
|
|
27
|
-
const bv =
|
|
10
|
+
const av = aBuf[i] ?? 0;
|
|
11
|
+
const bv = bBuf[i] ?? 0;
|
|
28
12
|
result |= av ^ bv;
|
|
29
13
|
}
|
|
30
14
|
return result === 0;
|
|
31
15
|
}
|
|
16
|
+
async function timingSafeEqualAsync(a, b) {
|
|
17
|
+
const subtle = globalThis.crypto?.subtle;
|
|
18
|
+
if (!subtle || typeof subtle.digest !== "function" || typeof subtle.timingSafeEqual !== "function") {
|
|
19
|
+
return timingSafeEqual(a, b);
|
|
20
|
+
}
|
|
21
|
+
const encoder = new TextEncoder;
|
|
22
|
+
const [providedHash, expectedHash] = await Promise.all([
|
|
23
|
+
subtle.digest("SHA-256", encoder.encode(a)),
|
|
24
|
+
subtle.digest("SHA-256", encoder.encode(b))
|
|
25
|
+
]);
|
|
26
|
+
return subtle.timingSafeEqual(providedHash, expectedHash);
|
|
27
|
+
}
|
|
32
28
|
function resolveOperatorApiKey(env) {
|
|
33
29
|
const preferred = env.OPERATOR_API_KEY;
|
|
34
30
|
if (typeof preferred === "string" && preferred.length > 0) {
|
|
@@ -53,7 +49,7 @@ async function requireOperatorAuth(request, env) {
|
|
|
53
49
|
}
|
|
54
50
|
const authHeader = request.headers.get("Authorization");
|
|
55
51
|
const expectedHeader = `Bearer ${apiKey}`;
|
|
56
|
-
if (!authHeader || !
|
|
52
|
+
if (!authHeader || !await timingSafeEqualAsync(authHeader, expectedHeader)) {
|
|
57
53
|
return new Response(JSON.stringify({ error: "Unauthorized" }), {
|
|
58
54
|
status: 401,
|
|
59
55
|
headers: { "Content-Type": "application/json" }
|
|
@@ -86,12 +82,13 @@ function collectInternalAuthKeys(env, keyNames) {
|
|
|
86
82
|
return keys;
|
|
87
83
|
}
|
|
88
84
|
function matchesAnyInternalAuthKey(providedKey, expectedKeys) {
|
|
85
|
+
let matched = false;
|
|
89
86
|
for (const expected of expectedKeys) {
|
|
90
87
|
if (timingSafeEqual(providedKey, expected)) {
|
|
91
|
-
|
|
88
|
+
matched = true;
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
|
-
return
|
|
91
|
+
return matched;
|
|
95
92
|
}
|
|
96
93
|
function internalAuthNotConfiguredResponse(keyNames) {
|
|
97
94
|
const label = normalizeKeyNames(keyNames).join(" | ");
|
|
@@ -139,13 +136,14 @@ function checkInternalAuth(request, env, keyName = "INTERNAL_KEY_BINDING") {
|
|
|
139
136
|
return { authorized: true };
|
|
140
137
|
}
|
|
141
138
|
export {
|
|
142
|
-
|
|
143
|
-
resolveOperatorApiKey,
|
|
144
|
-
requireOperatorAuth,
|
|
145
|
-
requireInternalAuth,
|
|
146
|
-
requireAuth,
|
|
147
|
-
createOperatorAuthMiddleware,
|
|
148
|
-
createInternalAuthMiddleware,
|
|
139
|
+
checkInternalAuth,
|
|
149
140
|
collectInternalAuthKeys,
|
|
150
|
-
|
|
141
|
+
createInternalAuthMiddleware,
|
|
142
|
+
createOperatorAuthMiddleware,
|
|
143
|
+
requireAuth,
|
|
144
|
+
requireInternalAuth,
|
|
145
|
+
requireOperatorAuth,
|
|
146
|
+
resolveOperatorApiKey,
|
|
147
|
+
timingSafeEqual,
|
|
148
|
+
timingSafeEqualAsync
|
|
151
149
|
};
|
package/dist/middleware/cors.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
|
|
18
2
|
// src/middleware/cors.ts
|
|
19
3
|
var DEFAULT_OPTIONS = {
|
|
20
4
|
allowOrigin: "",
|
|
@@ -69,9 +53,9 @@ function handleCorsPreflightRequest(request, options) {
|
|
|
69
53
|
});
|
|
70
54
|
}
|
|
71
55
|
export {
|
|
72
|
-
|
|
73
|
-
publicCorsHeaders,
|
|
74
|
-
internalCorsHeaders,
|
|
56
|
+
corsHeaders,
|
|
75
57
|
handleCorsPreflightRequest,
|
|
76
|
-
|
|
58
|
+
internalCorsHeaders,
|
|
59
|
+
publicCorsHeaders,
|
|
60
|
+
resolveCorsOptions
|
|
77
61
|
};
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* Barrel exports for shared middleware
|
|
7
7
|
*/
|
|
8
8
|
export { createLogger, withRequestLog, type Logger, type LogContext, } from "./logger";
|
|
9
|
-
export { requireAuth, requireOperatorAuth, createOperatorAuthMiddleware, resolveOperatorApiKey, requireInternalAuth, createInternalAuthMiddleware, checkInternalAuth, timingSafeEqual, collectInternalAuthKeys, type InternalAuthEnv, type InternalAuthKeyName, type OperatorAuthEnv, } from "./auth";
|
|
9
|
+
export { requireAuth, requireOperatorAuth, createOperatorAuthMiddleware, resolveOperatorApiKey, requireInternalAuth, createInternalAuthMiddleware, checkInternalAuth, timingSafeEqual, timingSafeEqualAsync, collectInternalAuthKeys, type InternalAuthEnv, type InternalAuthKeyName, type OperatorAuthEnv, } from "./auth";
|
|
10
10
|
export { createRateLimiter, type RateLimiter, type RateLimitConfig, } from "./rate-limit";
|
|
11
|
-
export { validateJson, validateJsonLegacy, requireField, optionalField, } from "./validate";
|
|
11
|
+
export { validateJson, validateJsonLegacy, parseJsonBody, requireField, optionalField, DEFAULT_MAX_JSON_BODY_BYTES, type ParseJsonBodyOptions, } from "./validate";
|
|
12
|
+
export { safeWaitUntil, waitUntilAll, type WaitUntilHost } from "./wait-until";
|
|
12
13
|
export { corsHeaders, resolveCorsOptions, type CorsEnv, publicCorsHeaders, internalCorsHeaders, handleCorsPreflightRequest, type CorsOptions, } from "./cors";
|
|
13
14
|
export { secureHeaders, wrapWithSecurityHeaders, type SecurityHeadersOptions, SECURITY_HEADERS_DEFAULTS, } from "./security-headers";
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,KAAK,MAAM,EACX,KAAK,UAAU,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,4BAA4B,EAC5B,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,eAAe,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,KAAK,MAAM,EACX,KAAK,UAAU,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,4BAA4B,EAC5B,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,eAAe,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,2BAA2B,EAC3B,KAAK,oBAAoB,GAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,KAAK,OAAO,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,KAAK,WAAW,GACjB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC"}
|