@abyss-project/monitor 14.0.0 → 15.0.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/middlewares/rate-limit/identifier-resolver.d.ts +3 -0
- package/dist/middlewares/rate-limit/identifier-resolver.js +15 -5
- package/dist/middlewares/rate-limit/identifier-resolver.js.map +1 -1
- package/dist/middlewares/rate-limit/index.d.ts +1 -1
- package/dist/middlewares/rate-limit/index.js +4 -1
- package/dist/middlewares/rate-limit/index.js.map +1 -1
- package/dist/types/interface/api/responses/rum-read.response.d.ts +3 -1
- package/dist/types/interface/api/responses/rum-socket-messages.response.d.ts +1 -0
- package/dist/types/interface/api/type-message/keyset-paginate.d.ts +1 -0
- package/package.json +1 -1
|
@@ -19,4 +19,7 @@ export declare function hashCredential(value: string): string;
|
|
|
19
19
|
export declare const RATE_LIMIT_INTERNAL_APPLICATION_LOCAL = "rateLimitInternalApplicationId";
|
|
20
20
|
export declare function setRateLimitInternalApplication(res: Response, applicationId: string): void;
|
|
21
21
|
export declare function readRateLimitInternalApplication(res: Response): string | undefined;
|
|
22
|
+
export declare const RATE_LIMIT_API_KEY_FINGERPRINT_LOCAL = "apiKeyFingerprint";
|
|
23
|
+
export declare function setRateLimitApiKey(res: Response, apiKey: string): void;
|
|
24
|
+
export declare function readRateLimitApiKeyFingerprint(res: Response): string | undefined;
|
|
22
25
|
export declare function resolveIdentifiers(req: Request, res: Response): ResolvedIdentifier;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RATE_LIMIT_INTERNAL_APPLICATION_LOCAL = void 0;
|
|
3
|
+
exports.RATE_LIMIT_API_KEY_FINGERPRINT_LOCAL = exports.RATE_LIMIT_INTERNAL_APPLICATION_LOCAL = void 0;
|
|
4
4
|
exports.hashCredential = hashCredential;
|
|
5
5
|
exports.setRateLimitInternalApplication = setRateLimitInternalApplication;
|
|
6
6
|
exports.readRateLimitInternalApplication = readRateLimitInternalApplication;
|
|
7
|
+
exports.setRateLimitApiKey = setRateLimitApiKey;
|
|
8
|
+
exports.readRateLimitApiKeyFingerprint = readRateLimitApiKeyFingerprint;
|
|
7
9
|
exports.resolveIdentifiers = resolveIdentifiers;
|
|
8
10
|
const node_require_1 = require("../../utils/node-require");
|
|
9
|
-
const api_key_header_1 = require("../../utils/api-key-header");
|
|
10
11
|
function hashCredential(value) {
|
|
11
12
|
const { createHash } = (0, node_require_1.nodeRequire)('crypto');
|
|
12
13
|
return createHash('sha256').update(value).digest('hex').slice(0, 16);
|
|
@@ -19,13 +20,22 @@ function readRateLimitInternalApplication(res) {
|
|
|
19
20
|
const value = res.locals?.[exports.RATE_LIMIT_INTERNAL_APPLICATION_LOCAL];
|
|
20
21
|
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
21
22
|
}
|
|
23
|
+
exports.RATE_LIMIT_API_KEY_FINGERPRINT_LOCAL = 'apiKeyFingerprint';
|
|
24
|
+
function setRateLimitApiKey(res, apiKey) {
|
|
25
|
+
res.locals[exports.RATE_LIMIT_API_KEY_FINGERPRINT_LOCAL] =
|
|
26
|
+
hashCredential(apiKey);
|
|
27
|
+
}
|
|
28
|
+
function readRateLimitApiKeyFingerprint(res) {
|
|
29
|
+
const value = res.locals?.[exports.RATE_LIMIT_API_KEY_FINGERPRINT_LOCAL];
|
|
30
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
31
|
+
}
|
|
22
32
|
function resolveIdentifiers(req, res) {
|
|
23
33
|
const locals = (res.locals ?? {});
|
|
24
34
|
if (locals.isAdmin)
|
|
25
35
|
return { kind: 'admin' };
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
return { kind: 'apikey', apiKeyId
|
|
36
|
+
const apiKeyId = readRateLimitApiKeyFingerprint(res);
|
|
37
|
+
if (apiKeyId)
|
|
38
|
+
return { kind: 'apikey', apiKeyId };
|
|
29
39
|
if (locals.currentUser?.id) {
|
|
30
40
|
if (locals.organization?.id) {
|
|
31
41
|
return { kind: 'userOrg', userId: locals.currentUser.id, orgId: locals.organization.id };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier-resolver.js","sourceRoot":"","sources":["../../../src/middlewares/rate-limit/identifier-resolver.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"identifier-resolver.js","sourceRoot":"","sources":["../../../src/middlewares/rate-limit/identifier-resolver.ts"],"names":[],"mappings":";;;AAcA,wCAMC;AAWD,0EAEC;AAGD,4EAKC;AAYD,gDAGC;AAGD,wEAKC;AAED,gDAsBC;AAvFD,2DAAuD;AAavD,SAAgB,cAAc,CAAC,KAAa;IAI1C,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,0BAAW,EAA0B,QAAQ,CAAC,CAAC;IACtE,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvE,CAAC;AAGY,QAAA,qCAAqC,GAAG,gCAAgC,CAAC;AAQtF,SAAgB,+BAA+B,CAAC,GAAa,EAAE,aAAqB;IACjF,GAAG,CAAC,MAAkC,CAAC,6CAAqC,CAAC,GAAG,aAAa,CAAC;AACjG,CAAC;AAGD,SAAgB,gCAAgC,CAAC,GAAa;IAC5D,MAAM,KAAK,GAAI,GAAG,CAAC,MAA8C,EAAE,CACjE,6CAAqC,CACtC,CAAC;IACF,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC;AAGY,QAAA,oCAAoC,GAAG,mBAAmB,CAAC;AASxE,SAAgB,kBAAkB,CAAC,GAAa,EAAE,MAAc;IAC7D,GAAG,CAAC,MAAkC,CAAC,4CAAoC,CAAC;QAC3E,cAAc,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAGD,SAAgB,8BAA8B,CAAC,GAAa;IAC1D,MAAM,KAAK,GAAI,GAAG,CAAC,MAA8C,EAAE,CACjE,4CAAoC,CACrC,CAAC;IACF,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC;AAED,SAAgB,kBAAkB,CAAC,GAAY,EAAE,GAAa;IAC5D,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAI/B,CAAC;IAEF,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAI7C,MAAM,QAAQ,GAAG,8BAA8B,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAElD,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC;QAC3B,IAAI,MAAM,CAAC,YAAY,EAAE,EAAE,EAAE,CAAC;YAC5B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;QAC3F,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC;IACzD,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,SAAS,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -3,7 +3,7 @@ export type { RouteRateLimiterContext } from './rate-limit.middleware';
|
|
|
3
3
|
export { RateLimit, readRateLimitOptions } from './rate-limit.decorator';
|
|
4
4
|
export { TokenBucketStore } from './token-bucket.store';
|
|
5
5
|
export type { ConsumeArgs, ConsumeDualArgs, SingleResult, DualResult } from './token-bucket.store';
|
|
6
|
-
export { resolveIdentifiers, setRateLimitInternalApplication, readRateLimitInternalApplication, RATE_LIMIT_INTERNAL_APPLICATION_LOCAL, } from './identifier-resolver';
|
|
6
|
+
export { resolveIdentifiers, setRateLimitInternalApplication, readRateLimitInternalApplication, RATE_LIMIT_INTERNAL_APPLICATION_LOCAL, setRateLimitApiKey, readRateLimitApiKeyFingerprint, RATE_LIMIT_API_KEY_FINGERPRINT_LOCAL, } from './identifier-resolver';
|
|
7
7
|
export type { ResolvedIdentifier } from './identifier-resolver';
|
|
8
8
|
export { parseWindow } from './parse-window';
|
|
9
9
|
export type { RateLimitWindow } from './parse-window';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseWindow = exports.RATE_LIMIT_INTERNAL_APPLICATION_LOCAL = exports.readRateLimitInternalApplication = exports.setRateLimitInternalApplication = exports.resolveIdentifiers = exports.TokenBucketStore = exports.readRateLimitOptions = exports.RateLimit = exports.createRouteRateLimiter = void 0;
|
|
3
|
+
exports.parseWindow = exports.RATE_LIMIT_API_KEY_FINGERPRINT_LOCAL = exports.readRateLimitApiKeyFingerprint = exports.setRateLimitApiKey = exports.RATE_LIMIT_INTERNAL_APPLICATION_LOCAL = exports.readRateLimitInternalApplication = exports.setRateLimitInternalApplication = exports.resolveIdentifiers = exports.TokenBucketStore = exports.readRateLimitOptions = exports.RateLimit = exports.createRouteRateLimiter = void 0;
|
|
4
4
|
var rate_limit_middleware_1 = require("./rate-limit.middleware");
|
|
5
5
|
Object.defineProperty(exports, "createRouteRateLimiter", { enumerable: true, get: function () { return rate_limit_middleware_1.createRouteRateLimiter; } });
|
|
6
6
|
var rate_limit_decorator_1 = require("./rate-limit.decorator");
|
|
@@ -13,6 +13,9 @@ Object.defineProperty(exports, "resolveIdentifiers", { enumerable: true, get: fu
|
|
|
13
13
|
Object.defineProperty(exports, "setRateLimitInternalApplication", { enumerable: true, get: function () { return identifier_resolver_1.setRateLimitInternalApplication; } });
|
|
14
14
|
Object.defineProperty(exports, "readRateLimitInternalApplication", { enumerable: true, get: function () { return identifier_resolver_1.readRateLimitInternalApplication; } });
|
|
15
15
|
Object.defineProperty(exports, "RATE_LIMIT_INTERNAL_APPLICATION_LOCAL", { enumerable: true, get: function () { return identifier_resolver_1.RATE_LIMIT_INTERNAL_APPLICATION_LOCAL; } });
|
|
16
|
+
Object.defineProperty(exports, "setRateLimitApiKey", { enumerable: true, get: function () { return identifier_resolver_1.setRateLimitApiKey; } });
|
|
17
|
+
Object.defineProperty(exports, "readRateLimitApiKeyFingerprint", { enumerable: true, get: function () { return identifier_resolver_1.readRateLimitApiKeyFingerprint; } });
|
|
18
|
+
Object.defineProperty(exports, "RATE_LIMIT_API_KEY_FINGERPRINT_LOCAL", { enumerable: true, get: function () { return identifier_resolver_1.RATE_LIMIT_API_KEY_FINGERPRINT_LOCAL; } });
|
|
16
19
|
var parse_window_1 = require("./parse-window");
|
|
17
20
|
Object.defineProperty(exports, "parseWindow", { enumerable: true, get: function () { return parse_window_1.parseWindow; } });
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middlewares/rate-limit/index.ts"],"names":[],"mappings":";;;AAAA,iEAAiE;AAAxD,+HAAA,sBAAsB,OAAA;AAE/B,+DAAyE;AAAhE,iHAAA,SAAS,OAAA;AAAE,4HAAA,oBAAoB,OAAA;AACxC,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AAEzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middlewares/rate-limit/index.ts"],"names":[],"mappings":";;;AAAA,iEAAiE;AAAxD,+HAAA,sBAAsB,OAAA;AAE/B,+DAAyE;AAAhE,iHAAA,SAAS,OAAA;AAAE,4HAAA,oBAAoB,OAAA;AACxC,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AAEzB,6DAQ+B;AAP7B,yHAAA,kBAAkB,OAAA;AAClB,sIAAA,+BAA+B,OAAA;AAC/B,uIAAA,gCAAgC,OAAA;AAChC,4IAAA,qCAAqC,OAAA;AACrC,yHAAA,kBAAkB,OAAA;AAClB,qIAAA,8BAA8B,OAAA;AAC9B,2IAAA,oCAAoC,OAAA;AAGtC,+CAA6C;AAApC,2GAAA,WAAW,OAAA"}
|
|
@@ -177,7 +177,9 @@ export interface IRumLiveRoute {
|
|
|
177
177
|
p75LcpMs: number | null;
|
|
178
178
|
}
|
|
179
179
|
export type IGetRumLiveRoutesResponse = IResponse<IRumLiveRoute[]>;
|
|
180
|
-
export type IRumRequestListItem = Omit<IRumRequest, 'dateValue' | 'applicationId'
|
|
180
|
+
export type IRumRequestListItem = Omit<IRumRequest, 'dateValue' | 'applicationId' | 'createdAt'> & {
|
|
181
|
+
createdAt: Date;
|
|
182
|
+
};
|
|
181
183
|
export interface IRumRequestPage {
|
|
182
184
|
items: IRumRequestListItem[];
|
|
183
185
|
nextCursor: string | null;
|
|
@@ -44,6 +44,7 @@ export interface IRumSocketMessageItem {
|
|
|
44
44
|
binaryType: RumSocketBinaryType | null;
|
|
45
45
|
payload: string | null;
|
|
46
46
|
json: boolean;
|
|
47
|
+
createdAt: Date;
|
|
47
48
|
}
|
|
48
49
|
export interface IRumSocketMessageSearchItem extends IRumSocketMessageItem {
|
|
49
50
|
connectionKind: RumSocketConnectionKind | null;
|