@hemia/auth-sdk 0.0.2 → 0.0.3

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 @@
1
+ export * from "./internal.adapter";
@@ -0,0 +1,13 @@
1
+ import { ISessionStorage } from "../types";
2
+ export interface IHemiaCacheService {
3
+ setObject<T>(key: string, value: T, expireTime?: number): Promise<void>;
4
+ getObject<T>(key: string): Promise<T | null>;
5
+ deleteKey(key: string): Promise<void>;
6
+ }
7
+ export declare class AuthCacheAdapter implements ISessionStorage {
8
+ private externalCache;
9
+ constructor(externalCache: IHemiaCacheService);
10
+ set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
11
+ get<T>(key: string): Promise<T | null>;
12
+ delete(key: string): Promise<void>;
13
+ }
@@ -0,0 +1 @@
1
+ export declare const AUTH_SERVICE_ID = "AuthService";
@@ -6,7 +6,7 @@ import { AuthService } from "../services/auth.service";
6
6
  */
7
7
  export declare abstract class AbstractAuthController {
8
8
  protected readonly authService: AuthService;
9
- protected constructor(authService: AuthService);
9
+ protected constructor();
10
10
  login(req: Request, res: Response): Promise<void>;
11
11
  callback(req: Request, res: Response): Promise<void>;
12
12
  me(req: Request, res: Response): Promise<Response>;
@@ -4,3 +4,4 @@ export * from "./services";
4
4
  export * from "./types";
5
5
  export * from "./errors";
6
6
  export * from "./ioc";
7
+ export * from "./constants";
@@ -1,4 +1,5 @@
1
- import { Container } from "inversify";
2
- import { IAuthConfig, IJwtManager } from "./types";
3
- import { AuthCacheService } from "./services";
4
- export declare const registerAuthSdk: (container: Container, config: IAuthConfig, cacheService: AuthCacheService, jwtManager: IJwtManager) => void;
1
+ import { Bind, ResolutionContext } from "inversify";
2
+ import { IAuthConfig } from "./types";
3
+ import { IHemiaCacheService } from "./adapters";
4
+ export type CacheFactory = (context: ResolutionContext) => Promise<IHemiaCacheService> | IHemiaCacheService;
5
+ export declare const registerAuthSdk: (bind: Bind, config: IAuthConfig, cacheFactory: CacheFactory) => void;
@@ -1,11 +1,12 @@
1
- import { IAuthConfig, ICallbackResponse, IJwtManager, ILoginParams, ISessionUser, IStoredState } from '../types';
2
- import { AuthCacheService } from './cache.service';
1
+ import { HMNetworkServices } from '@hemia/network-services';
2
+ import { JwtManager } from '@hemia/jwt-manager';
3
+ import { IAuthConfig, ICallbackResponse, ILoginParams, ISessionStorage, ISessionUser, IStoredState } from '../types';
3
4
  export declare class AuthService {
4
- private config;
5
- private storage;
6
- private jwtManager;
7
- private networkServices;
8
- constructor(config: IAuthConfig, storage: AuthCacheService, jwtManager: IJwtManager);
5
+ private readonly config;
6
+ private readonly storage;
7
+ private readonly networkServices;
8
+ private readonly jwtManager;
9
+ constructor(config: IAuthConfig, storage: ISessionStorage, networkServices: HMNetworkServices, jwtManager: JwtManager);
9
10
  /**
10
11
  * Genera los parámetros necesarios para iniciar el login SSO
11
12
  * @param auto
@@ -1,2 +1 @@
1
1
  export * from "./auth.service";
2
- export * from "./cache.service";
@@ -8,3 +8,4 @@ export * from "./session-user-response.interface";
8
8
  export * from "./jwt-manager.interface";
9
9
  export * from "./standard-claims.interface";
10
10
  export * from "./session-data.interface";
11
+ export * from "./session-storage.interface";
@@ -0,0 +1,5 @@
1
+ export interface ISessionStorage {
2
+ set(key: string, value: any, ttlSeconds: number): Promise<void>;
3
+ get<T>(key: string): Promise<T | null>;
4
+ delete(key: string): Promise<void>;
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hemia/auth-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Hemia SDK for authentication",
5
5
  "main": "dist/hemia-auth-sdk.js",
6
6
  "module": "dist/hemia-auth-sdk.esm.js",
@@ -1,8 +0,0 @@
1
- import { CacheService as CacheServiceClient } from "@hemia/cache-manager";
2
- export declare class AuthCacheService {
3
- private cacheClient;
4
- constructor(cacheClient: CacheServiceClient);
5
- set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
6
- get<T>(key: string): Promise<T | null>;
7
- delete(key: string): Promise<void>;
8
- }