@vsaas/loopback 12.2.2 → 12.2.4
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.
|
@@ -154,8 +154,10 @@ var init_limiter = require_runtime.__esmMin((() => {
|
|
|
154
154
|
}
|
|
155
155
|
async selectSubject(rule, store) {
|
|
156
156
|
const keyring = this.registry.getKeyring(rule.subjectKeyring);
|
|
157
|
+
const keyIds = Object.keys(keyring.keys);
|
|
158
|
+
if (keyIds.length === 1) return require_subject.withBucket(require_subject.hashRateLimitSubject(rule.subject, keyring, keyIds[0]), rule.bucket, rule.policy.policyId, rule.policy.policyVersion);
|
|
157
159
|
const candidates = [];
|
|
158
|
-
for (const keyId of
|
|
160
|
+
for (const keyId of keyIds) {
|
|
159
161
|
const subject = require_subject.withBucket(require_subject.hashRateLimitSubject(rule.subject, keyring, keyId), rule.bucket, rule.policy.policyId, rule.policy.policyVersion);
|
|
160
162
|
const decision = await store.inspect({
|
|
161
163
|
subject,
|
|
@@ -35,7 +35,7 @@ function normalizeNamedPolicy(name, input) {
|
|
|
35
35
|
}
|
|
36
36
|
function installRemoteRateLimiting(app) {
|
|
37
37
|
const resolvers = /* @__PURE__ */ new Map();
|
|
38
|
-
const installed = /* @__PURE__ */ new
|
|
38
|
+
const installed = /* @__PURE__ */ new Set();
|
|
39
39
|
const staticRules = /* @__PURE__ */ new WeakMap();
|
|
40
40
|
app.registerRateLimitResolver = function(name, resolver) {
|
|
41
41
|
if (!name || typeof resolver !== "function" || resolvers.has(name)) throw require_errors.rateLimitConfigurationError(`Rate limit resolver ${name || "(missing)"} is invalid`);
|
|
@@ -99,9 +99,10 @@ function installRemoteRateLimiting(app) {
|
|
|
99
99
|
if (!Model?.sharedClass?.methods) return;
|
|
100
100
|
for (const method of Model.sharedClass.methods()) {
|
|
101
101
|
const metadata = method.rateLimit;
|
|
102
|
-
if (!metadata || installed.has(method)) continue;
|
|
103
|
-
installed.add(method);
|
|
104
102
|
const methodName = method.isStatic ? method.name : `prototype.${method.name}`;
|
|
103
|
+
const installedKey = `${Model.modelName}.${methodName}`;
|
|
104
|
+
if (!metadata || installed.has(installedKey)) continue;
|
|
105
|
+
installed.add(installedKey);
|
|
105
106
|
Model.beforeRemote(methodName, function(ctx, unused, next) {
|
|
106
107
|
Promise.resolve().then(async () => {
|
|
107
108
|
if (!app.rateLimitReadiness.ready) throw require_errors.rateLimitConfigurationError("Rate limiting is not initialized");
|
package/dist/package.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var require_package = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
|
|
3
3
|
module.exports = {
|
|
4
4
|
"name": "@vsaas/loopback",
|
|
5
|
-
"version": "12.2.
|
|
5
|
+
"version": "12.2.4",
|
|
6
6
|
"description": "Fork of LoopBack 3 framework for building APIs and microservices in Node.js",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"StrongLoop",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vsaas/loopback",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.4",
|
|
4
4
|
"description": "Fork of LoopBack 3 framework for building APIs and microservices in Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"StrongLoop",
|
|
@@ -104,9 +104,9 @@
|
|
|
104
104
|
"nodemailer": "^9.0.5",
|
|
105
105
|
"otplib": "13.4.1",
|
|
106
106
|
"serve-favicon": "^2.5.1",
|
|
107
|
-
"@vsaas/
|
|
108
|
-
"@vsaas/
|
|
109
|
-
"@vsaas/loopback-datasource-juggler": "^
|
|
107
|
+
"@vsaas/remoting": "^13.0.1",
|
|
108
|
+
"@vsaas/loopback-connector-remote": "^12.0.2",
|
|
109
|
+
"@vsaas/loopback-datasource-juggler": "^13.0.0"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"@types/node": "25.5.0",
|