apitally 0.1.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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -0
  3. package/dist/common/client.d.ts +37 -0
  4. package/dist/common/client.d.ts.map +1 -0
  5. package/dist/common/client.js +243 -0
  6. package/dist/common/client.js.map +1 -0
  7. package/dist/common/index.d.ts +2 -0
  8. package/dist/common/index.d.ts.map +1 -0
  9. package/dist/common/index.js +6 -0
  10. package/dist/common/index.js.map +1 -0
  11. package/dist/common/keyRegistry.d.ts +29 -0
  12. package/dist/common/keyRegistry.d.ts.map +1 -0
  13. package/dist/common/keyRegistry.js +90 -0
  14. package/dist/common/keyRegistry.js.map +1 -0
  15. package/dist/common/logging.d.ts +8 -0
  16. package/dist/common/logging.d.ts.map +1 -0
  17. package/dist/common/logging.js +13 -0
  18. package/dist/common/logging.js.map +1 -0
  19. package/dist/common/requestLogger.d.ts +10 -0
  20. package/dist/common/requestLogger.d.ts.map +1 -0
  21. package/dist/common/requestLogger.js +49 -0
  22. package/dist/common/requestLogger.js.map +1 -0
  23. package/dist/common/types.d.ts +56 -0
  24. package/dist/common/types.d.ts.map +1 -0
  25. package/dist/common/types.js +3 -0
  26. package/dist/common/types.js.map +1 -0
  27. package/dist/common/utils.d.ts +4 -0
  28. package/dist/common/utils.d.ts.map +1 -0
  29. package/dist/common/utils.js +23 -0
  30. package/dist/common/utils.js.map +1 -0
  31. package/dist/common/validationErrorLogger.d.ts +9 -0
  32. package/dist/common/validationErrorLogger.d.ts.map +1 -0
  33. package/dist/common/validationErrorLogger.js +40 -0
  34. package/dist/common/validationErrorLogger.js.map +1 -0
  35. package/dist/express/auth.d.ts +6 -0
  36. package/dist/express/auth.d.ts.map +1 -0
  37. package/dist/express/auth.js +66 -0
  38. package/dist/express/auth.js.map +1 -0
  39. package/dist/express/index.d.ts +3 -0
  40. package/dist/express/index.d.ts.map +1 -0
  41. package/dist/express/index.js +8 -0
  42. package/dist/express/index.js.map +1 -0
  43. package/dist/express/listEndpoints.d.ts +3 -0
  44. package/dist/express/listEndpoints.d.ts.map +1 -0
  45. package/dist/express/listEndpoints.js +166 -0
  46. package/dist/express/listEndpoints.js.map +1 -0
  47. package/dist/express/middleware.d.ts +4 -0
  48. package/dist/express/middleware.d.ts.map +1 -0
  49. package/dist/express/middleware.js +164 -0
  50. package/dist/express/middleware.js.map +1 -0
  51. package/dist/fastify/auth.d.ts +6 -0
  52. package/dist/fastify/auth.d.ts.map +1 -0
  53. package/dist/fastify/auth.js +66 -0
  54. package/dist/fastify/auth.js.map +1 -0
  55. package/dist/fastify/index.d.ts +3 -0
  56. package/dist/fastify/index.d.ts.map +1 -0
  57. package/dist/fastify/index.js +11 -0
  58. package/dist/fastify/index.js.map +1 -0
  59. package/dist/fastify/plugin.d.ts +16 -0
  60. package/dist/fastify/plugin.d.ts.map +1 -0
  61. package/dist/fastify/plugin.js +122 -0
  62. package/dist/fastify/plugin.js.map +1 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +3 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/koa/auth.d.ts +6 -0
  68. package/dist/koa/auth.d.ts.map +1 -0
  69. package/dist/koa/auth.js +67 -0
  70. package/dist/koa/auth.js.map +1 -0
  71. package/dist/koa/index.d.ts +3 -0
  72. package/dist/koa/index.d.ts.map +1 -0
  73. package/dist/koa/index.js +8 -0
  74. package/dist/koa/index.js.map +1 -0
  75. package/dist/koa/middleware.d.ts +4 -0
  76. package/dist/koa/middleware.d.ts.map +1 -0
  77. package/dist/koa/middleware.js +108 -0
  78. package/dist/koa/middleware.js.map +1 -0
  79. package/dist/nestjs/auth.d.ts +10 -0
  80. package/dist/nestjs/auth.d.ts.map +1 -0
  81. package/dist/nestjs/auth.js +84 -0
  82. package/dist/nestjs/auth.js.map +1 -0
  83. package/dist/nestjs/index.d.ts +3 -0
  84. package/dist/nestjs/index.d.ts.map +1 -0
  85. package/dist/nestjs/index.js +9 -0
  86. package/dist/nestjs/index.js.map +1 -0
  87. package/package.json +128 -0
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class RequestLogger {
4
+ constructor() {
5
+ this.requestCounts = new Map();
6
+ this.responseTimes = new Map();
7
+ }
8
+ getKey(requestInfo) {
9
+ return [
10
+ requestInfo.consumer || "",
11
+ requestInfo.method.toUpperCase(),
12
+ requestInfo.path,
13
+ requestInfo.statusCode,
14
+ ].join("|");
15
+ }
16
+ logRequest(requestInfo) {
17
+ const key = this.getKey(requestInfo);
18
+ // Increment request count
19
+ this.requestCounts.set(key, (this.requestCounts.get(key) || 0) + 1);
20
+ // Log response time
21
+ if (!this.responseTimes.has(key)) {
22
+ this.responseTimes.set(key, new Map());
23
+ }
24
+ const responseTimeMap = this.responseTimes.get(key);
25
+ const responseTimeMsBin = Math.floor(requestInfo.responseTime / 10) * 10; // Rounded to nearest 10ms
26
+ responseTimeMap.set(responseTimeMsBin, (responseTimeMap.get(responseTimeMsBin) || 0) + 1);
27
+ }
28
+ getAndResetRequests() {
29
+ const data = [];
30
+ this.requestCounts.forEach((count, key) => {
31
+ const [consumer, method, path, statusCodeStr] = key.split("|");
32
+ const responseTimes = this.responseTimes.get(key) || new Map();
33
+ data.push({
34
+ consumer: consumer || null,
35
+ method,
36
+ path,
37
+ status_code: parseInt(statusCodeStr),
38
+ request_count: count,
39
+ response_times: Object.fromEntries(responseTimes),
40
+ });
41
+ });
42
+ // Reset the counts and times
43
+ this.requestCounts.clear();
44
+ this.responseTimes.clear();
45
+ return data;
46
+ }
47
+ }
48
+ exports.default = RequestLogger;
49
+ //# sourceMappingURL=requestLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestLogger.js","sourceRoot":"","sources":["../../src/common/requestLogger.ts"],"names":[],"mappings":";;AAEA,MAAqB,aAAa;IAIhC;QACE,IAAI,CAAC,aAAa,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M,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/D,MAAM,aAAa,GACjB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,EAAkB,CAAC;YAC3D,IAAI,CAAC,IAAI,CAAC;gBACR,QAAQ,EAAE,QAAQ,IAAI,IAAI;gBAC1B,MAAM;gBACN,IAAI;gBACJ,WAAW,EAAE,QAAQ,CAAC,aAAa,CAAC;gBACpC,aAAa,EAAE,KAAK;gBACpB,cAAc,EAAE,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC;aAClD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,6BAA6B;QAC7B,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAE3B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA1DD,gCA0DC"}
@@ -0,0 +1,56 @@
1
+ import { KeyCacheBase } from "./keyRegistry";
2
+ import { Logger } from "./logging";
3
+ export type ApitallyConfig = {
4
+ clientId: string;
5
+ env?: string;
6
+ syncApiKeys?: boolean;
7
+ openApiUrl?: string;
8
+ appVersion?: string;
9
+ logger?: Logger;
10
+ keyCacheClass?: new (clientId: string, env: string) => KeyCacheBase;
11
+ };
12
+ export type PathInfo = {
13
+ method: string;
14
+ path: string;
15
+ };
16
+ export type AppInfo = {
17
+ paths: Array<PathInfo>;
18
+ versions: Map<string, string>;
19
+ client: string;
20
+ };
21
+ export type AppInfoPayload = {
22
+ instance_uuid: string;
23
+ message_uuid: string;
24
+ } & AppInfo;
25
+ export type ConsumerMethodPath = {
26
+ consumer?: string | null;
27
+ method: string;
28
+ path: string;
29
+ };
30
+ export type RequestInfo = ConsumerMethodPath & {
31
+ statusCode: number;
32
+ responseTime: number;
33
+ };
34
+ export type RequestsItem = ConsumerMethodPath & {
35
+ status_code: number;
36
+ request_count: number;
37
+ response_times: Record<number, number>;
38
+ };
39
+ export type ValidationError = {
40
+ loc: string;
41
+ msg: string;
42
+ type: string;
43
+ };
44
+ export type ValidationErrorsItem = ConsumerMethodPath & {
45
+ loc: Array<string>;
46
+ error_count: number;
47
+ } & ValidationError;
48
+ export type RequestsDataPayload = {
49
+ time_offset: number;
50
+ instance_uuid: string;
51
+ message_uuid: string;
52
+ requests: Array<RequestsItem>;
53
+ validation_errors: Array<ValidationErrorsItem>;
54
+ api_key_usage: Record<number, number>;
55
+ };
56
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,YAAY,CAAC;CACrE,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;I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"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export declare function isValidClientId(clientId: string): boolean;
2
+ export declare function isValidEnv(env: string): boolean;
3
+ export declare function getPackageVersion(name: string): string | null;
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAIzD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG/C;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM7D"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPackageVersion = exports.isValidEnv = exports.isValidClientId = void 0;
4
+ function isValidClientId(clientId) {
5
+ const regexExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6
+ return regexExp.test(clientId);
7
+ }
8
+ exports.isValidClientId = isValidClientId;
9
+ function isValidEnv(env) {
10
+ const regexExp = /^[\w-]{1,32}$/;
11
+ return regexExp.test(env);
12
+ }
13
+ exports.isValidEnv = isValidEnv;
14
+ function getPackageVersion(name) {
15
+ try {
16
+ return require(`${name}/package.json`).version || null; // eslint-disable-line @typescript-eslint/no-var-requires
17
+ }
18
+ catch (error) {
19
+ return null;
20
+ }
21
+ }
22
+ exports.getPackageVersion = getPackageVersion;
23
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,QAAgB;IAC9C,MAAM,QAAQ,GACZ,0EAA0E,CAAC;IAC7E,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC;AAJD,0CAIC;AAED,SAAgB,UAAU,CAAC,GAAW;IACpC,MAAM,QAAQ,GAAG,eAAe,CAAC;IACjC,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAHD,gCAGC;AAED,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,IAAI;QACF,OAAO,OAAO,CAAC,GAAG,IAAI,eAAe,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,yDAAyD;KAClH;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAND,8CAMC"}
@@ -0,0 +1,9 @@
1
+ import { ConsumerMethodPath, ValidationError, ValidationErrorsItem } from "./types";
2
+ export default class ValidationErrorLogger {
3
+ private errorCounts;
4
+ constructor();
5
+ private getKey;
6
+ logValidationError(validationError: ConsumerMethodPath & ValidationError): void;
7
+ getAndResetValidationErrors(): Array<ValidationErrorsItem>;
8
+ }
9
+ //# sourceMappingURL=validationErrorLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validationErrorLogger.d.ts","sourceRoot":"","sources":["../../src/common/validationErrorLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,OAAO,qBAAqB;IACxC,OAAO,CAAC,WAAW,CAAsB;;IAMzC,OAAO,CAAC,MAAM;IAaP,kBAAkB,CACvB,eAAe,EAAE,kBAAkB,GAAG,eAAe,GACpD,IAAI;IAKA,2BAA2B,IAAI,KAAK,CAAC,oBAAoB,CAAC;CAiBlE"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ValidationErrorLogger {
4
+ constructor() {
5
+ this.errorCounts = new Map();
6
+ }
7
+ getKey(validationError) {
8
+ return [
9
+ validationError.consumer || "",
10
+ validationError.method.toUpperCase(),
11
+ validationError.path,
12
+ validationError.loc,
13
+ validationError.msg,
14
+ validationError.type,
15
+ ].join("|");
16
+ }
17
+ logValidationError(validationError) {
18
+ const key = this.getKey(validationError);
19
+ this.errorCounts.set(key, (this.errorCounts.get(key) || 0) + 1);
20
+ }
21
+ getAndResetValidationErrors() {
22
+ const data = [];
23
+ this.errorCounts.forEach((count, key) => {
24
+ const [consumer, method, path, loc, msg, type] = key.split("|");
25
+ data.push({
26
+ consumer: consumer || null,
27
+ method,
28
+ path,
29
+ loc: loc.split("."),
30
+ msg,
31
+ type,
32
+ error_count: count,
33
+ });
34
+ });
35
+ this.errorCounts.clear();
36
+ return data;
37
+ }
38
+ }
39
+ exports.default = ValidationErrorLogger;
40
+ //# sourceMappingURL=validationErrorLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validationErrorLogger.js","sourceRoot":"","sources":["../../src/common/validationErrorLogger.ts"],"names":[],"mappings":";;AAMA,MAAqB,qBAAqB;IAGxC;QACE,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC/C,CAAC;IAEO,MAAM,CACZ,eAAqD;QAErD,OAAO;YACL,eAAe,CAAC,QAAQ,IAAI,EAAE;YAC9B,eAAe,CAAC,MAAM,CAAC,WAAW,EAAE;YACpC,eAAe,CAAC,IAAI;YACpB,eAAe,CAAC,GAAG;YACnB,eAAe,CAAC,GAAG;YACnB,eAAe,CAAC,IAAI;SACrB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACd,CAAC;IAEM,kBAAkB,CACvB,eAAqD;QAErD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACzC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;IAEM,2BAA2B;QAChC,MAAM,IAAI,GAAe,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACtC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAChE,IAAI,CAAC,IAAI,CAAC;gBACR,QAAQ,EAAE,QAAQ,IAAI,IAAI;gBAC1B,MAAM;gBACN,IAAI;gBACJ,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;gBACnB,GAAG;gBACH,IAAI;gBACJ,WAAW,EAAE,KAAK;aACnB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5CD,wCA4CC"}
@@ -0,0 +1,6 @@
1
+ import { NextFunction, Request, Response } from "express";
2
+ export declare const requireApiKey: ({ scopes, customHeader, }?: {
3
+ scopes?: string | string[] | undefined;
4
+ customHeader?: string | undefined;
5
+ }) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
6
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/express/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI1D,eAAO,MAAM,aAAa;;;YAOL,OAAO,OAAO,QAAQ,QAAQ,YAAY,kBAoD9D,CAAC"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.requireApiKey = void 0;
13
+ const client_1 = require("../common/client");
14
+ const requireApiKey = ({ scopes, customHeader, } = {}) => {
15
+ return (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
16
+ let apiKey;
17
+ if (!customHeader) {
18
+ if (!req.headers.authorization) {
19
+ res
20
+ .status(401)
21
+ .set("WWW-Authenticate", "ApiKey")
22
+ .json({ error: "Missing authorization header" });
23
+ return;
24
+ }
25
+ const authorizationParts = req.headers.authorization.split(" ");
26
+ if (authorizationParts.length === 2 &&
27
+ authorizationParts[0].toLowerCase() === "apikey") {
28
+ apiKey = authorizationParts[1];
29
+ }
30
+ else {
31
+ res
32
+ .status(401)
33
+ .set("WWW-Authenticate", "ApiKey")
34
+ .json({ error: "Invalid authorization scheme" });
35
+ return;
36
+ }
37
+ }
38
+ else if (customHeader) {
39
+ const customHeaderValue = req.headers[customHeader.toLowerCase()];
40
+ if (typeof customHeaderValue === "string") {
41
+ apiKey = customHeaderValue;
42
+ }
43
+ else if (Array.isArray(customHeaderValue)) {
44
+ apiKey = customHeaderValue[0];
45
+ }
46
+ }
47
+ if (!apiKey) {
48
+ res.status(403).json({ error: "Missing API key" });
49
+ return;
50
+ }
51
+ const client = client_1.ApitallyClient.getInstance();
52
+ const keyInfo = yield client.keyRegistry.get(apiKey);
53
+ if (!keyInfo) {
54
+ res.status(403).json({ error: "Invalid API key" });
55
+ return;
56
+ }
57
+ if (scopes && !keyInfo.hasScopes(scopes)) {
58
+ res.status(403).json({ error: "Permission denied" });
59
+ return;
60
+ }
61
+ res.locals.keyInfo = keyInfo;
62
+ next();
63
+ });
64
+ };
65
+ exports.requireApiKey = requireApiKey;
66
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/express/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,6CAAkD;AAE3C,MAAM,aAAa,GAAG,CAAC,EAC5B,MAAM,EACN,YAAY,MAIV,EAAE,EAAE,EAAE;IACR,OAAO,CAAO,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;QAC/D,IAAI,MAA0B,CAAC;QAE/B,IAAI,CAAC,YAAY,EAAE;YACjB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE;gBAC9B,GAAG;qBACA,MAAM,CAAC,GAAG,CAAC;qBACX,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC;qBACjC,IAAI,CAAC,EAAE,KAAK,EAAE,8BAA8B,EAAE,CAAC,CAAC;gBACnD,OAAO;aACR;YACD,MAAM,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAChE,IACE,kBAAkB,CAAC,MAAM,KAAK,CAAC;gBAC/B,kBAAkB,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,QAAQ,EAChD;gBACA,MAAM,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;aAChC;iBAAM;gBACL,GAAG;qBACA,MAAM,CAAC,GAAG,CAAC;qBACX,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC;qBACjC,IAAI,CAAC,EAAE,KAAK,EAAE,8BAA8B,EAAE,CAAC,CAAC;gBACnD,OAAO;aACR;SACF;aAAM,IAAI,YAAY,EAAE;YACvB,MAAM,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;YAClE,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;gBACzC,MAAM,GAAG,iBAAiB,CAAC;aAC5B;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE;gBAC3C,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;aAC/B;SACF;QAED,IAAI,CAAC,MAAM,EAAE;YACX,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;YACnD,OAAO;SACR;QAED,MAAM,MAAM,GAAG,uBAAc,CAAC,WAAW,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,EAAE;YACZ,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;YACnD,OAAO;SACR;QACD,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;YACxC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CAAC;YACrD,OAAO;SACR;QAED,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAC7B,IAAI,EAAE,CAAC;IACT,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AA3DW,QAAA,aAAa,iBA2DxB"}
@@ -0,0 +1,3 @@
1
+ export { requireApiKey } from "./auth";
2
+ export { useApitally } from "./middleware";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/express/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useApitally = exports.requireApiKey = void 0;
4
+ var auth_1 = require("./auth");
5
+ Object.defineProperty(exports, "requireApiKey", { enumerable: true, get: function () { return auth_1.requireApiKey; } });
6
+ var middleware_1 = require("./middleware");
7
+ Object.defineProperty(exports, "useApitally", { enumerable: true, get: function () { return middleware_1.useApitally; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/express/index.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AAA9B,qGAAA,aAAa,OAAA;AACtB,2CAA2C;AAAlC,yGAAA,WAAW,OAAA"}
@@ -0,0 +1,3 @@
1
+ export = getEndpoints;
2
+ declare function getEndpoints(app: any): any[];
3
+ //# sourceMappingURL=listEndpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listEndpoints.d.ts","sourceRoot":"","sources":["../../src/express/listEndpoints.js"],"names":[],"mappings":";AAyMA,+CAQC"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ // Adapted from https://github.com/AlbertoFdzM/express-list-endpoints/blob/ed926dd5186761e7b721ad20938ce6eb52d104d3/src/index.js
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const regExpToParseExpressPathRegExp = /^\/\^\\\/(?:(:?[\w\\.-]*(?:\\\/:?[\w\\.-]*)*)|(\(\?:\(\[\^\\\/]\+\?\)\)))\\\/.*/;
5
+ const regExpToReplaceExpressPathRegExpParams = /\(\?:\(\[\^\\\/]\+\?\)\)/;
6
+ const regexpExpressParamRegexp = /\(\?:\(\[\^\\\/]\+\?\)\)/g;
7
+ const EXPRESS_ROOT_PATH_REGEXP_VALUE = "/^\\/?(?=\\/|$)/i";
8
+ const STACK_ITEM_VALID_NAMES = ["router", "bound dispatch", "mounted_app"];
9
+ /**
10
+ * Returns all the verbs detected for the passed route
11
+ */
12
+ const getRouteMethods = function (route) {
13
+ let methods = Object.keys(route.methods);
14
+ methods = methods.filter((method) => method !== "_all");
15
+ methods = methods.map((method) => method.toUpperCase());
16
+ return methods;
17
+ };
18
+ /**
19
+ * Returns the names (or anonymous) of all the middlewares attached to the
20
+ * passed route
21
+ * @param {Object} route
22
+ * @returns {string[]}
23
+ */
24
+ const getRouteMiddlewares = function (route) {
25
+ return route.stack.map((item) => {
26
+ return item.handle.name || "anonymous";
27
+ });
28
+ };
29
+ /**
30
+ * Returns true if found regexp related with express params
31
+ * @param {string} expressPathRegExp
32
+ * @returns {boolean}
33
+ */
34
+ const hasParams = function (expressPathRegExp) {
35
+ return regexpExpressParamRegexp.test(expressPathRegExp);
36
+ };
37
+ /**
38
+ * @param {Object} route Express route object to be parsed
39
+ * @param {string} basePath The basePath the route is on
40
+ * @return {Object[]} Endpoints info
41
+ */
42
+ const parseExpressRoute = function (route, basePath) {
43
+ const paths = [];
44
+ if (Array.isArray(route.path)) {
45
+ paths.push(...route.path);
46
+ }
47
+ else {
48
+ paths.push(route.path);
49
+ }
50
+ const endpoints = paths.map((path) => {
51
+ const completePath = basePath && path === "/" ? basePath : `${basePath}${path}`;
52
+ const endpoint = {
53
+ path: completePath,
54
+ methods: getRouteMethods(route),
55
+ middlewares: getRouteMiddlewares(route),
56
+ };
57
+ return endpoint;
58
+ });
59
+ return endpoints;
60
+ };
61
+ /**
62
+ * @param {RegExp} expressPathRegExp
63
+ * @param {Object[]} params
64
+ * @returns {string}
65
+ */
66
+ const parseExpressPath = function (expressPathRegExp, params) {
67
+ let expressPathRegExpExec = regExpToParseExpressPathRegExp.exec(expressPathRegExp);
68
+ let parsedRegExp = expressPathRegExp.toString();
69
+ let paramIndex = 0;
70
+ while (hasParams(parsedRegExp)) {
71
+ const paramName = params[paramIndex].name;
72
+ const paramId = `:${paramName}`;
73
+ parsedRegExp = parsedRegExp.replace(regExpToReplaceExpressPathRegExpParams, paramId);
74
+ paramIndex++;
75
+ }
76
+ if (parsedRegExp !== expressPathRegExp.toString()) {
77
+ expressPathRegExpExec = regExpToParseExpressPathRegExp.exec(parsedRegExp);
78
+ }
79
+ const parsedPath = expressPathRegExpExec[1].replace(/\\\//g, "/");
80
+ return parsedPath;
81
+ };
82
+ /**
83
+ * @param {Object} app
84
+ * @param {string} [basePath]
85
+ * @param {Object[]} [endpoints]
86
+ * @returns {Object[]}
87
+ */
88
+ const parseEndpoints = function (app, basePath, endpoints) {
89
+ const stack = app.stack || (app._router && app._router.stack);
90
+ endpoints = endpoints || [];
91
+ basePath = basePath || "";
92
+ if (!stack) {
93
+ endpoints = addEndpoints(endpoints, [
94
+ {
95
+ path: basePath,
96
+ methods: [],
97
+ middlewares: [],
98
+ },
99
+ ]);
100
+ }
101
+ else {
102
+ endpoints = parseStack(stack, basePath, endpoints);
103
+ }
104
+ return endpoints;
105
+ };
106
+ /**
107
+ * Ensures the path of the new endpoints isn't yet in the array.
108
+ * If the path is already in the array merges the endpoints with the existing
109
+ * one, if not, it adds them to the array.
110
+ *
111
+ * @param {Object[]} currentEndpoints Array of current endpoints
112
+ * @param {Object[]} endpointsToAdd New endpoints to be added to the array
113
+ * @returns {Object[]} Updated endpoints array
114
+ */
115
+ const addEndpoints = function (currentEndpoints, endpointsToAdd) {
116
+ endpointsToAdd.forEach((newEndpoint) => {
117
+ const existingEndpoint = currentEndpoints.find((item) => item.path === newEndpoint.path);
118
+ if (existingEndpoint !== undefined) {
119
+ const newMethods = newEndpoint.methods.filter((method) => !existingEndpoint.methods.includes(method));
120
+ existingEndpoint.methods = existingEndpoint.methods.concat(newMethods);
121
+ }
122
+ else {
123
+ currentEndpoints.push(newEndpoint);
124
+ }
125
+ });
126
+ return currentEndpoints;
127
+ };
128
+ /**
129
+ * @param {Object} stack
130
+ * @param {string} basePath
131
+ * @param {Object[]} endpoints
132
+ * @returns {Object[]}
133
+ */
134
+ const parseStack = function (stack, basePath, endpoints) {
135
+ stack.forEach((stackItem) => {
136
+ if (stackItem.route) {
137
+ const newEndpoints = parseExpressRoute(stackItem.route, basePath);
138
+ endpoints = addEndpoints(endpoints, newEndpoints);
139
+ }
140
+ else if (STACK_ITEM_VALID_NAMES.includes(stackItem.name)) {
141
+ const isExpressPathRegexp = regExpToParseExpressPathRegExp.test(stackItem.regexp);
142
+ let newBasePath = basePath;
143
+ if (isExpressPathRegexp) {
144
+ const parsedPath = parseExpressPath(stackItem.regexp, stackItem.keys);
145
+ newBasePath += `/${parsedPath}`;
146
+ }
147
+ else if (!stackItem.path &&
148
+ stackItem.regexp &&
149
+ stackItem.regexp.toString() !== EXPRESS_ROOT_PATH_REGEXP_VALUE) {
150
+ const regExpPath = ` RegExp(${stackItem.regexp}) `;
151
+ newBasePath += `/${regExpPath}`;
152
+ }
153
+ endpoints = parseEndpoints(stackItem.handle, newBasePath, endpoints);
154
+ }
155
+ });
156
+ return endpoints;
157
+ };
158
+ const getEndpoints = function (app) {
159
+ const endpoints = parseEndpoints(app);
160
+ return endpoints.flatMap((route) => route.methods.map((method) => ({
161
+ method,
162
+ path: route.path,
163
+ })));
164
+ };
165
+ module.exports = getEndpoints;
166
+ //# sourceMappingURL=listEndpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listEndpoints.js","sourceRoot":"","sources":["../../src/express/listEndpoints.js"],"names":[],"mappings":";AAAA,gIAAgI;;AAEhI,MAAM,8BAA8B,GAClC,iFAAiF,CAAC;AACpF,MAAM,sCAAsC,GAAG,0BAA0B,CAAC;AAC1E,MAAM,wBAAwB,GAAG,2BAA2B,CAAC;AAE7D,MAAM,8BAA8B,GAAG,mBAAmB,CAAC;AAC3D,MAAM,sBAAsB,GAAG,CAAC,QAAQ,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,eAAe,GAAG,UAAU,KAAK;IACrC,IAAI,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEzC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE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AAsB,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;YAC1D,MAAM,mBAAmB,GAAG,8BAA8B,CAAC,IAAI,CAC7D,SAAS,CAAC,MAAM,CACjB,CAAC;YAEF,IAAI,WAAW,GAAG,QAAQ,CAAC;YAE3B,IAAI,mBAAmB,EAAE;gBACvB,MAAM,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;gBAEtE,WAAW,IAAI,IAAI,UAAU,EAAE,CAAC;aACjC;iBAAM,IACL,CAAC,SAAS,CAAC,IAAI;gBACf,SAAS,CAAC,MAAM;gBAChB,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,8BAA8B,EAC9D;gBACA,MAAM,UAAU,GAAG,WAAW,SAAS,CAAC,MAAM,IAAI,CAAC;gBAEnD,WAAW,IAAI,IAAI,UAAU,EAAE,CAAC;aACjC;YAED,SAAS,GAAG,cAAc,CAAC,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;SACtE;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,UAAU,GAAG;IAChC,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CACjC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC7B,MAAM;QACN,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Express } from "express";
2
+ import { ApitallyConfig } from "../common/types";
3
+ export declare const useApitally: (app: Express, config: ApitallyConfig) => void;
4
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/express/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAmC,MAAM,SAAS,CAAC;AAKnE,OAAO,EAAE,cAAc,EAA4B,MAAM,iBAAiB,CAAC;AAI3E,eAAO,MAAM,WAAW,QAAS,OAAO,UAAU,cAAc,SAO/D,CAAC"}