@oxyhq/core 3.4.2 → 3.4.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/core",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.3",
|
|
4
4
|
"description": "OxyHQ SDK Foundation — API client, authentication, cryptographic identity, and shared utilities",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"@biomejs/biome": "^1.9.4",
|
|
128
128
|
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
129
129
|
"@types/elliptic": "^6.4.18",
|
|
130
|
-
"@types/express": "^
|
|
130
|
+
"@types/express": "^4.17.21",
|
|
131
131
|
"@types/invariant": "^2.2.34",
|
|
132
132
|
"@types/node": "^20.19.9",
|
|
133
133
|
"expo-crypto": "~56.0.3",
|
package/src/server/rateLimit.ts
CHANGED
|
@@ -107,7 +107,7 @@ function resolveKey(req: OxyAuthedRequest): string {
|
|
|
107
107
|
if (userId) {
|
|
108
108
|
return `user:${userId}`;
|
|
109
109
|
}
|
|
110
|
-
const ip = req.ip ||
|
|
110
|
+
const ip = req.ip || req.socket.remoteAddress || 'unknown';
|
|
111
111
|
return ipKeyGenerator(ip);
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -138,19 +138,19 @@ export function createOxyRateLimit(
|
|
|
138
138
|
const limiter = rateLimit({
|
|
139
139
|
windowMs,
|
|
140
140
|
...(store ? { store } : {}),
|
|
141
|
-
max: (
|
|
141
|
+
max: (req: Request): number => {
|
|
142
142
|
const authed = req as OxyAuthedRequest;
|
|
143
143
|
const userId = authed.userId ?? authed.user?.id ?? authed.user?._id;
|
|
144
144
|
return userId ? authenticatedMax : anonymousMax;
|
|
145
|
-
}
|
|
146
|
-
keyGenerator: (
|
|
145
|
+
},
|
|
146
|
+
keyGenerator: (req: Request): string => resolveKey(req as OxyAuthedRequest),
|
|
147
147
|
message,
|
|
148
148
|
standardHeaders: true,
|
|
149
149
|
legacyHeaders: false,
|
|
150
|
-
skip
|
|
151
|
-
}
|
|
150
|
+
skip,
|
|
151
|
+
});
|
|
152
152
|
|
|
153
|
-
return (
|
|
153
|
+
return (req, res, next) => {
|
|
154
154
|
// Skipped paths bypass BOTH session resolution and limiting — cheap and
|
|
155
155
|
// safe for static/streaming/health traffic.
|
|
156
156
|
if (skip(req)) {
|
|
@@ -166,5 +166,5 @@ export function createOxyRateLimit(
|
|
|
166
166
|
}
|
|
167
167
|
limiter(req, res, next);
|
|
168
168
|
});
|
|
169
|
-
}
|
|
169
|
+
};
|
|
170
170
|
}
|