@intelicity/gates-sdk 0.1.0 → 0.1.1

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/auth/middleware.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ export declare function jwksUrl(region: string, userPoolId: string): string;
2
+ /**
3
+ * Retorna um RemoteJWKSet cacheado por (region + userPoolId).
4
+ */
5
+ export declare function getJwks(region: string, userPoolId: string, ttlMs?: number): {
6
+ (protectedHeader?: import("jose").JWSHeaderParameters, token?: import("jose").FlattenedJWSInput): Promise<import("jose").CryptoKey>;
7
+ coolingDown: boolean;
8
+ fresh: boolean;
9
+ reloading: boolean;
10
+ reload: () => Promise<void>;
11
+ jwks: () => import("jose").JSONWebKeySet | undefined;
12
+ };
13
+ //# sourceMappingURL=jwks-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwks-cache.d.ts","sourceRoot":"","sources":["../../src/cache/jwks-cache.ts"],"names":[],"mappings":"AAWA,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAEzD;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,MAAuB;;;;;;;EAa/B"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Base error class for authentication-related errors
3
+ */
4
+ export declare class AuthenticationError extends Error {
5
+ readonly code?: string | undefined;
6
+ constructor(message: string, code?: string | undefined);
7
+ }
8
+ /**
9
+ * Error thrown when a token has expired
10
+ */
11
+ export declare class TokenExpiredError extends AuthenticationError {
12
+ constructor(message?: string);
13
+ }
14
+ /**
15
+ * Error thrown when a token is invalid
16
+ */
17
+ export declare class InvalidTokenError extends AuthenticationError {
18
+ constructor(message?: string);
19
+ }
20
+ /**
21
+ * Error thrown when authorization header is missing
22
+ */
23
+ export declare class MissingAuthorizationError extends AuthenticationError {
24
+ constructor(message?: string);
25
+ }
26
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/errors/error.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;aACC,IAAI,CAAC,EAAE,MAAM;gBAA9C,OAAO,EAAE,MAAM,EAAkB,IAAI,CAAC,EAAE,MAAM,YAAA;CAK3D;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,mBAAmB;gBAC5C,OAAO,SAAsB;CAK1C;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,mBAAmB;gBAC5C,OAAO,SAAkB;CAKtC;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,mBAAmB;gBACpD,OAAO,SAAiC;CAKrD"}
@@ -0,0 +1,5 @@
1
+ export type { GatesUser } from "./models/user.js";
2
+ export { UserService, type Profile, type UserListResponse, type GetAllUsersOptions, type ProfileAttribute, } from "./services/user-service.js";
3
+ export { AuthService, type VerifyOptions } from "./services/auth-service.js";
4
+ export { AuthenticationError, TokenExpiredError, InvalidTokenError, MissingAuthorizationError, } from "./errors/error.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,WAAW,EACX,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Tipagem base do payload que sai do Cognito.
3
+ * Você pode estender com claims próprias (ex.: permissions, system_access).
4
+ */
5
+ export type GatesUser = {
6
+ user_id: string;
7
+ email: string;
8
+ name: string;
9
+ role: string;
10
+ exp: number;
11
+ iat: number;
12
+ };
13
+ //# sourceMappingURL=user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/models/user.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { GatesUser } from "../models/user.js";
2
+ export type VerifyOptions = {
3
+ region: string;
4
+ userPoolId: string;
5
+ audience: string;
6
+ requiredGroup?: string | string[];
7
+ };
8
+ export declare class AuthService {
9
+ private readonly region;
10
+ private readonly userPoolId;
11
+ private readonly audience;
12
+ private readonly requiredGroup?;
13
+ constructor(region: string, userPoolId: string, audience: string, requiredGroup?: string | string[]);
14
+ private get issuer();
15
+ isMemberOf(groups?: string[]): boolean;
16
+ verifyToken(token: string): Promise<GatesUser>;
17
+ }
18
+ //# sourceMappingURL=auth-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-service.d.ts","sourceRoot":"","sources":["../../src/services/auth-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAoB;gBAGjD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAiCnC,OAAO,KAAK,MAAM,GAEjB;IAED,UAAU,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,OAAO;IAgBpC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAiDrD"}
@@ -0,0 +1,46 @@
1
+ export interface UserListResponse {
2
+ profiles: Profile[];
3
+ total?: number;
4
+ page?: number;
5
+ limit?: number;
6
+ nextToken?: string;
7
+ }
8
+ export interface Profile {
9
+ user_id: string;
10
+ email: string;
11
+ name: string;
12
+ enabled: boolean;
13
+ profile_attributes: ProfileAttribute[];
14
+ }
15
+ export interface ProfileAttribute {
16
+ attribute_name: string;
17
+ value: string | boolean | number;
18
+ }
19
+ export interface GetAllUsersOptions {
20
+ page?: number;
21
+ limit?: number;
22
+ filter?: string;
23
+ group?: string;
24
+ }
25
+ export declare class UserService {
26
+ private readonly baseUrl;
27
+ private readonly system;
28
+ private readonly defaultHeaders;
29
+ constructor(baseUrl: string, system: string);
30
+ private readonly endpoints;
31
+ /**
32
+ * Busca todos os usuários do Cognito através do backend
33
+ * @param idToken Token de autenticação (ID Token do Cognito)
34
+ * @param options Opções de paginação e filtro
35
+ * @returns Lista de usuários
36
+ */
37
+ getAllUsers(idToken: string): Promise<UserListResponse>;
38
+ /**
39
+ * Busca um usuário específico por ID
40
+ * @param idToken Token de autenticação
41
+ * @param userId ID do usuário
42
+ * @returns Dados do usuário
43
+ */
44
+ getUserById(idToken: string, userId: string): Promise<Profile>;
45
+ }
46
+ //# sourceMappingURL=user-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-service.d.ts","sourceRoot":"","sources":["../../src/services/user-service.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,EAAE,gBAAgB,EAAE,CAAC;CACxC;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;gBAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAQ3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAExB;IAEF;;;;;OAKG;IACG,WAAW,CACf,OAAO,EAAE,MAAM,GAEd,OAAO,CAAC,gBAAgB,CAAC;IAiD5B;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAgCrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intelicity/gates-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Simple SDK for authenticating users with AWS Cognito JWT tokens",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",