@riocrypto/common-server 1.0.2278 → 1.0.2280

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.
@@ -47,7 +47,6 @@
47
47
  /// <reference types="mongoose/types/virtuals" />
48
48
  /// <reference types="mongoose" />
49
49
  /// <reference types="mongoose/types/inferschematype" />
50
- /// <reference types="mongoose/types/inferrawdoctype" />
51
50
  /// <reference types="mongoose/types/inferschematype" />
52
51
  /// <reference types="mongoose/types/inferrawdoctype" />
53
52
  import { BankAccountDoc } from "@riocrypto/common-server";
@@ -47,7 +47,6 @@
47
47
  /// <reference types="mongoose/types/virtuals" />
48
48
  /// <reference types="mongoose" />
49
49
  /// <reference types="mongoose/types/inferschematype" />
50
- /// <reference types="mongoose/types/inferrawdoctype" />
51
50
  /// <reference types="mongoose/types/inferschematype" />
52
51
  /// <reference types="mongoose/types/inferrawdoctype" />
53
52
  import { CryptoAddressDoc } from "@riocrypto/common-server";
@@ -47,7 +47,6 @@
47
47
  /// <reference types="mongoose/types/virtuals" />
48
48
  /// <reference types="mongoose" />
49
49
  /// <reference types="mongoose/types/inferschematype" />
50
- /// <reference types="mongoose/types/inferrawdoctype" />
51
50
  /// <reference types="mongoose/types/inferschematype" />
52
51
  /// <reference types="mongoose/types/inferrawdoctype" />
53
52
  import { OrderDoc } from "@riocrypto/common-server";
@@ -47,7 +47,6 @@
47
47
  /// <reference types="mongoose/types/virtuals" />
48
48
  /// <reference types="mongoose" />
49
49
  /// <reference types="mongoose/types/inferschematype" />
50
- /// <reference types="mongoose/types/inferrawdoctype" />
51
50
  /// <reference types="mongoose/types/inferschematype" />
52
51
  /// <reference types="mongoose/types/inferrawdoctype" />
53
52
  import { UserDoc } from "@riocrypto/common-server";
@@ -25,8 +25,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.createDynamicRateLimiter = void 0;
27
27
  const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
28
- // Removed path-to-regexp import
29
- // Adjust the import path according to your project structure
30
28
  const custom_rate_limit_1 = require("../models/custom-rate-limit");
31
29
  // Cache for rate limiter instances
32
30
  const limiterInstanceCache = new Map();
@@ -86,15 +84,30 @@ function createDynamicRateLimiter(options) {
86
84
  (customIpRulesCache.size === 0 && lastCacheRefreshTime === 0)) {
87
85
  yield refreshCustomIpRulesCache(CustomRateLimit, req.path);
88
86
  }
89
- let clientIp = req.ip;
87
+ // Determine the client's IP address, prioritizing Cloudflare/proxy headers
88
+ let rawClientIp;
89
+ const cfConnectingIp = req.headers["cf-connecting-ip"];
90
+ const xForwardedForHeader = req.headers["x-forwarded-for"];
91
+ if (cfConnectingIp) {
92
+ rawClientIp = cfConnectingIp;
93
+ }
94
+ else if (xForwardedForHeader) {
95
+ // X-Forwarded-For can be a comma-separated list (client, proxy1, proxy2)
96
+ // The first IP is the original client IP
97
+ rawClientIp = xForwardedForHeader.split(",")[0].trim();
98
+ }
99
+ else {
100
+ rawClientIp = req.ip; // Fallback to Express's req.ip
101
+ }
90
102
  let normalizedIp;
91
- if (clientIp) {
92
- // Normalize IPv4-mapped IPv6 addresses (::ffff:x.x.x.x)
93
- if (clientIp.startsWith("::ffff:")) {
94
- normalizedIp = clientIp.substring(7);
103
+ if (rawClientIp) {
104
+ // Normalize IPv4-mapped IPv6 addresses (e.g., ::ffff:192.0.2.1 -> 192.0.2.1)
105
+ // Also handles direct IPv4 and standard IPv6 addresses
106
+ if (rawClientIp.startsWith("::ffff:")) {
107
+ normalizedIp = rawClientIp.substring(7);
95
108
  }
96
109
  else {
97
- normalizedIp = clientIp;
110
+ normalizedIp = rawClientIp;
98
111
  }
99
112
  }
100
113
  let currentLimit = defaultMax;
@@ -4,12 +4,14 @@ interface AdminAuthDashboardSettingsAttrs {
4
4
  hideBackgroundAnimation?: boolean;
5
5
  pwaInstallBannerDismissedDesktop?: boolean;
6
6
  pwaInstallBannerDismissedMobile?: boolean;
7
+ notificationBannerDismissedMobile?: boolean;
7
8
  }
8
9
  interface AdminAuthDashboardSettingsDoc extends mongoose.Document {
9
10
  adminAuthId: string;
10
11
  hideBackgroundAnimation?: boolean;
11
12
  pwaInstallBannerDismissedDesktop?: boolean;
12
13
  pwaInstallBannerDismissedMobile?: boolean;
14
+ notificationBannerDismissedMobile?: boolean;
13
15
  }
14
16
  interface AdminAuthDashboardSettingsModel extends mongoose.Model<AdminAuthDashboardSettingsDoc> {
15
17
  build(attrs: AdminAuthDashboardSettingsAttrs): AdminAuthDashboardSettingsDoc;
@@ -22,6 +22,10 @@ const buildAdminAuthDashboardSettings = (mongoose) => {
22
22
  type: Boolean,
23
23
  default: false,
24
24
  },
25
+ notificationBannerDismissedMobile: {
26
+ type: Boolean,
27
+ default: false,
28
+ },
25
29
  }, {
26
30
  toJSON: {
27
31
  transform(doc, ret) {
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Mongoose, Model, Document } from "mongoose";
4
3
  import { AdminAuthDoc } from "./admin-auth";
5
4
  export interface AdminWebAuthnCredentialAttrs {
@@ -4,12 +4,14 @@ interface AuthDashboardSettingsAttrs {
4
4
  hideBackgroundAnimation?: boolean;
5
5
  pwaInstallBannerDismissedDesktop?: boolean;
6
6
  pwaInstallBannerDismissedMobile?: boolean;
7
+ notificationBannerDismissedMobile?: boolean;
7
8
  }
8
9
  interface AuthDashboardSettingsDoc extends mongoose.Document {
9
10
  authId: string;
10
11
  hideBackgroundAnimation?: boolean;
11
12
  pwaInstallBannerDismissedDesktop?: boolean;
12
13
  pwaInstallBannerDismissedMobile?: boolean;
14
+ notificationBannerDismissedMobile?: boolean;
13
15
  }
14
16
  interface AuthDashboardSettingsModel extends mongoose.Model<AuthDashboardSettingsDoc> {
15
17
  build(attrs: AuthDashboardSettingsAttrs): AuthDashboardSettingsDoc;
@@ -22,6 +22,10 @@ const buildAuthDashboardSettings = (mongoose) => {
22
22
  type: Boolean,
23
23
  default: false,
24
24
  },
25
+ notificationBannerDismissedMobile: {
26
+ type: Boolean,
27
+ default: false,
28
+ },
25
29
  }, {
26
30
  toJSON: {
27
31
  transform(doc, ret) {
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { Mongoose, Model, Document } from "mongoose";
4
3
  import { AuthDoc } from "./auth";
5
4
  export interface WebAuthnCredentialAttrs {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2278",
3
+ "version": "1.0.2280",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@google-cloud/secret-manager": "^5.3.0",
29
29
  "@google-cloud/storage": "^6.9.5",
30
30
  "@hyperdx/node-opentelemetry": "^0.7.0",
31
- "@riocrypto/common": "^1.0.1994",
31
+ "@riocrypto/common": "^1.0.1995",
32
32
  "@types/express": "^4.17.13",
33
33
  "axios": "^1.7.4",
34
34
  "crypto-js": "^4.2.0",