apitally 0.2.1 → 0.4.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/README.md +5 -9
- package/lib/cjs/common/client.cjs +19 -98
- package/lib/cjs/common/client.cjs.map +1 -1
- package/lib/cjs/common/serverErrorCounter.cjs +104 -0
- package/lib/cjs/common/serverErrorCounter.cjs.map +1 -0
- package/lib/cjs/common/validationErrorCounter.cjs +26 -23
- package/lib/cjs/common/validationErrorCounter.cjs.map +1 -1
- package/lib/cjs/express/index.cjs +0 -14
- package/lib/cjs/express/index.cjs.map +1 -1
- package/lib/cjs/express/middleware.cjs +26 -12
- package/lib/cjs/express/middleware.cjs.map +1 -1
- package/lib/cjs/fastify/index.cjs +0 -14
- package/lib/cjs/fastify/index.cjs.map +1 -1
- package/lib/cjs/fastify/plugin.cjs +20 -11
- package/lib/cjs/fastify/plugin.cjs.map +1 -1
- package/lib/cjs/koa/index.cjs +0 -14
- package/lib/cjs/koa/index.cjs.map +1 -1
- package/lib/cjs/koa/middleware.cjs +33 -24
- package/lib/cjs/koa/middleware.cjs.map +1 -1
- package/lib/cjs/nestjs/index.cjs +0 -26
- package/lib/cjs/nestjs/index.cjs.map +1 -1
- package/lib/esm/common/client.js +19 -98
- package/lib/esm/common/client.js.map +1 -1
- package/lib/esm/common/serverErrorCounter.js +98 -0
- package/lib/esm/common/serverErrorCounter.js.map +1 -0
- package/lib/esm/common/validationErrorCounter.js +26 -23
- package/lib/esm/common/validationErrorCounter.js.map +1 -1
- package/lib/esm/express/index.js +1 -4
- package/lib/esm/express/index.js.map +1 -1
- package/lib/esm/express/middleware.js +26 -12
- package/lib/esm/express/middleware.js.map +1 -1
- package/lib/esm/fastify/index.js +1 -4
- package/lib/esm/fastify/index.js.map +1 -1
- package/lib/esm/fastify/plugin.js +20 -11
- package/lib/esm/fastify/plugin.js.map +1 -1
- package/lib/esm/koa/index.js +1 -4
- package/lib/esm/koa/index.js.map +1 -1
- package/lib/esm/koa/middleware.js +33 -24
- package/lib/esm/koa/middleware.js.map +1 -1
- package/lib/esm/nestjs/index.js +1 -4
- package/lib/esm/nestjs/index.js.map +1 -1
- package/lib/types/common/client.d.ts +3 -9
- package/lib/types/common/client.d.ts.map +1 -1
- package/lib/types/common/serverErrorCounter.d.ts +12 -0
- package/lib/types/common/serverErrorCounter.d.ts.map +1 -0
- package/lib/types/common/types.d.ts +12 -4
- package/lib/types/common/types.d.ts.map +1 -1
- package/lib/types/common/validationErrorCounter.d.ts +2 -1
- package/lib/types/common/validationErrorCounter.d.ts.map +1 -1
- package/lib/types/express/index.d.ts +0 -2
- package/lib/types/express/index.d.ts.map +1 -1
- package/lib/types/express/middleware.d.ts +0 -2
- package/lib/types/express/middleware.d.ts.map +1 -1
- package/lib/types/fastify/index.d.ts +0 -2
- package/lib/types/fastify/index.d.ts.map +1 -1
- package/lib/types/fastify/plugin.d.ts +2 -3
- package/lib/types/fastify/plugin.d.ts.map +1 -1
- package/lib/types/koa/index.d.ts +0 -2
- package/lib/types/koa/index.d.ts.map +1 -1
- package/lib/types/koa/middleware.d.ts.map +1 -1
- package/lib/types/nestjs/index.d.ts +0 -2
- package/lib/types/nestjs/index.d.ts.map +1 -1
- package/package.json +2 -4
- package/lib/cjs/common/index.cjs +0 -13
- package/lib/cjs/common/index.cjs.map +0 -1
- package/lib/cjs/common/keyRegistry.cjs +0 -162
- package/lib/cjs/common/keyRegistry.cjs.map +0 -1
- package/lib/cjs/express/auth.cjs +0 -105
- package/lib/cjs/express/auth.cjs.map +0 -1
- package/lib/cjs/fastify/auth.cjs +0 -105
- package/lib/cjs/fastify/auth.cjs.map +0 -1
- package/lib/cjs/koa/auth.cjs +0 -113
- package/lib/cjs/koa/auth.cjs.map +0 -1
- package/lib/cjs/nestjs/auth.cjs +0 -132
- package/lib/cjs/nestjs/auth.cjs.map +0 -1
- package/lib/esm/common/index.js +0 -1
- package/lib/esm/common/index.js.map +0 -1
- package/lib/esm/common/keyRegistry.js +0 -155
- package/lib/esm/common/keyRegistry.js.map +0 -1
- package/lib/esm/express/auth.js +0 -98
- package/lib/esm/express/auth.js.map +0 -1
- package/lib/esm/fastify/auth.js +0 -98
- package/lib/esm/fastify/auth.js.map +0 -1
- package/lib/esm/koa/auth.js +0 -106
- package/lib/esm/koa/auth.js.map +0 -1
- package/lib/esm/nestjs/auth.js +0 -126
- package/lib/esm/nestjs/auth.js.map +0 -1
- package/lib/types/common/index.d.ts +0 -2
- package/lib/types/common/index.d.ts.map +0 -1
- package/lib/types/common/keyRegistry.d.ts +0 -29
- package/lib/types/common/keyRegistry.d.ts.map +0 -1
- package/lib/types/express/auth.d.ts +0 -6
- package/lib/types/express/auth.d.ts.map +0 -1
- package/lib/types/fastify/auth.d.ts +0 -6
- package/lib/types/fastify/auth.d.ts.map +0 -1
- package/lib/types/koa/auth.d.ts +0 -6
- package/lib/types/koa/auth.d.ts.map +0 -1
- package/lib/types/nestjs/auth.d.ts +0 -12
- package/lib/types/nestjs/auth.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare class KeyInfo {
|
|
2
|
-
readonly keyId: number;
|
|
3
|
-
readonly apiKeyId: number;
|
|
4
|
-
readonly name: string;
|
|
5
|
-
readonly scopes: string[];
|
|
6
|
-
readonly expiresAt: Date | null;
|
|
7
|
-
constructor(keyId: number, apiKeyId: number, name?: string, scopes?: string[], expiresInSeconds?: number | null);
|
|
8
|
-
get isExpired(): boolean;
|
|
9
|
-
hasScopes(scopes: string | string[]): boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare class KeyRegistry {
|
|
12
|
-
salt: string | null;
|
|
13
|
-
private keys;
|
|
14
|
-
private usageCounts;
|
|
15
|
-
constructor();
|
|
16
|
-
get(apiKey: string): Promise<KeyInfo | null>;
|
|
17
|
-
private hashApiKey;
|
|
18
|
-
update(keys: Record<string, any>): void;
|
|
19
|
-
getAndResetUsageCounts(): Record<number, number>;
|
|
20
|
-
}
|
|
21
|
-
export declare abstract class KeyCacheBase {
|
|
22
|
-
private clientId;
|
|
23
|
-
private env;
|
|
24
|
-
constructor(clientId: string, env: string);
|
|
25
|
-
get cacheKey(): string;
|
|
26
|
-
abstract store(data: string): void;
|
|
27
|
-
abstract retrieve(): string | null;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=keyRegistry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyRegistry.d.ts","sourceRoot":"","sources":["../../../src/common/keyRegistry.ts"],"names":[],"mappings":"AAEA,qBAAa,OAAO;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;gBAG9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,MAAW,EACjB,MAAM,GAAE,MAAM,EAAO,EACrB,gBAAgB,GAAE,MAAM,GAAG,IAAW;IAYxC,IAAI,SAAS,YAEZ;IAED,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;CAMpC;AAED,qBAAa,WAAW;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAuB;IACnC,OAAO,CAAC,WAAW,CAAsB;;IAQ5B,GAAG,CAAC,MAAM,EAAE,MAAM;YAajB,UAAU;IAkBjB,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAgBhC,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAKxD;AAED,8BAAsB,YAAY;IAChC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,GAAG,CAAS;gBAER,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAKzC,IAAI,QAAQ,WAEX;IAED,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAElC,QAAQ,CAAC,QAAQ,IAAI,MAAM,GAAG,IAAI;CACnC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { 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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/express/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI/D,eAAO,MAAM,aAAa;;;YAOL,OAAO,OAAO,QAAQ,QAAQ,YAAY,kBAoD9D,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { DoneFuncWithErrOrRes, FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
-
export declare const requireApiKey: ({ scopes, customHeader, }?: {
|
|
3
|
-
scopes?: string | string[] | undefined;
|
|
4
|
-
customHeader?: string | undefined;
|
|
5
|
-
}) => (request: FastifyRequest, reply: FastifyReply, done: DoneFuncWithErrOrRes) => Promise<void>;
|
|
6
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/fastify/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACf,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,aAAa;;;gBAQb,cAAc,SAChB,YAAY,QACb,oBAAoB,kBAqD7B,CAAC"}
|
package/lib/types/koa/auth.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/koa/auth.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAItB,eAAO,MAAM,aAAa;;;YAOL,IAAI,OAAO,QAAQ,IAAI,IAAI,kBAqD/C,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CanActivate, ExecutionContext } from "@nestjs/common";
|
|
2
|
-
import { Reflector } from "@nestjs/core";
|
|
3
|
-
import { KeyInfo } from "../common/keyRegistry.js";
|
|
4
|
-
export declare const Scopes: (...scopes: string[]) => import("@nestjs/common").CustomDecorator<string>;
|
|
5
|
-
export declare class ApitallyApiKeyGuard implements CanActivate {
|
|
6
|
-
private reflector;
|
|
7
|
-
static customHeader?: string;
|
|
8
|
-
constructor(reflector: Reflector);
|
|
9
|
-
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
10
|
-
}
|
|
11
|
-
export declare const GetKeyInfo: (...dataOrPipes: (KeyInfo | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>> | undefined)[]) => ParameterDecorator;
|
|
12
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/nestjs/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAMjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,eAAO,MAAM,MAAM,cAAe,MAAM,EAAE,qDAAkC,CAAC;AAE7E,qBACa,mBAAoB,YAAW,WAAW;IAGzC,OAAO,CAAC,SAAS;IAF7B,OAAc,YAAY,CAAC,EAAE,MAAM,CAAC;gBAEhB,SAAS,EAAE,SAAS;IAElC,WAAW,CAAC,OAAO,EAAE,gBAAgB;CA+C5C;AAED,eAAO,MAAM,UAAU,sMAKtB,CAAC"}
|