@bool-ts/guard-sdk 1.0.0-beta.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -0
  3. package/dist/constants/enums.d.ts +3 -0
  4. package/dist/constants/index.d.ts +2 -0
  5. package/dist/constants/keys.d.ts +4 -0
  6. package/dist/decorators/actionGuard.decorator.d.ts +1 -0
  7. package/dist/decorators/authState.decorator.d.ts +1 -0
  8. package/dist/decorators/controllerGuard.decorator.d.ts +1 -0
  9. package/dist/decorators/index.d.ts +3 -0
  10. package/dist/entities/index.d.ts +2 -0
  11. package/dist/entities/interceptor.d.ts +5 -0
  12. package/dist/entities/loader.d.ts +4 -0
  13. package/dist/entities/middleware.d.ts +19 -0
  14. package/dist/index.d.ts +5 -0
  15. package/dist/index.js +39 -0
  16. package/dist/index.js.map +57 -0
  17. package/dist/instances/client.d.ts +47 -0
  18. package/dist/instances/index.d.ts +1 -0
  19. package/dist/interfaces/account.interface.d.ts +6 -0
  20. package/dist/interfaces/accountCredential.interface.d.ts +7 -0
  21. package/dist/interfaces/base.d.ts +3 -0
  22. package/dist/interfaces/client.interface.d.ts +48 -0
  23. package/dist/interfaces/index.d.ts +4 -0
  24. package/package.json +50 -0
  25. package/src/constants/enums.ts +3 -0
  26. package/src/constants/index.ts +2 -0
  27. package/src/constants/keys.ts +4 -0
  28. package/src/decorators/actionGuard.decorator.ts +5 -0
  29. package/src/decorators/authState.decorator.ts +4 -0
  30. package/src/decorators/controllerGuard.decorator.ts +5 -0
  31. package/src/decorators/index.ts +3 -0
  32. package/src/entities/index.ts +2 -0
  33. package/src/entities/interceptor.ts +47 -0
  34. package/src/entities/loader.ts +20 -0
  35. package/src/entities/middleware.ts +73 -0
  36. package/src/index.ts +6 -0
  37. package/src/instances/client.ts +314 -0
  38. package/src/instances/index.ts +1 -0
  39. package/src/interfaces/account.interface.ts +7 -0
  40. package/src/interfaces/accountCredential.interface.ts +7 -0
  41. package/src/interfaces/base.ts +3 -0
  42. package/src/interfaces/client.interface.ts +52 -0
  43. package/src/interfaces/index.ts +4 -0
@@ -0,0 +1 @@
1
+ export { Client } from "./client";
@@ -0,0 +1,7 @@
1
+ export type TDefaultAccountMetadata = Record<string, string | number | Date | null | undefined>;
2
+
3
+ export interface IAccount<T = TDefaultAccountMetadata> {
4
+ uuid: string;
5
+ status: string;
6
+ metadata?: T | null;
7
+ }
@@ -0,0 +1,7 @@
1
+ export interface IAccountCredential {
2
+ uuid: string;
3
+ identity: string;
4
+ status: string;
5
+ type: string;
6
+ isVerified: boolean;
7
+ }
@@ -0,0 +1,3 @@
1
+ export type TApiResponse<T> = Readonly<{
2
+ data: Awaited<ReturnType<T extends (...args: any) => Promise<infer R> ? () => R : never>>;
3
+ }>;
@@ -0,0 +1,52 @@
1
+ import type { IAccount, TDefaultAccountMetadata } from "./account.interface";
2
+ import type { IAccountCredential } from "./accountCredential.interface";
3
+
4
+ export type TClientConfigs = {
5
+ tenantId: string;
6
+ appId: string;
7
+ modeId: string;
8
+ secretKey: string;
9
+ };
10
+
11
+ export type TClientOptions = {
12
+ version?: 1;
13
+ logs?: boolean;
14
+ };
15
+
16
+ export interface IClient<
17
+ TAccountMetadata extends TDefaultAccountMetadata = TDefaultAccountMetadata
18
+ > {
19
+ createPlainAccount(args: {
20
+ identity: string;
21
+ password: string;
22
+ metadata?: TAccountMetadata | null;
23
+ }): Promise<
24
+ Readonly<{
25
+ account: IAccount<TAccountMetadata>;
26
+ credential: IAccountCredential;
27
+ }>
28
+ >;
29
+ createEmailAccount(args: {
30
+ identity: string;
31
+ password: string | null;
32
+ metadata?: TAccountMetadata | null;
33
+ }): Promise<
34
+ Readonly<{
35
+ account: IAccount<TAccountMetadata>;
36
+ credential: IAccountCredential;
37
+ }>
38
+ >;
39
+ authenticate(args: { identity: string; password?: string | null }): Promise<{
40
+ token: string;
41
+ account: IAccount<TAccountMetadata>;
42
+ credential: IAccountCredential;
43
+ }>;
44
+ verifyToken(args: {
45
+ token: string;
46
+ }): Promise<{ account: IAccount<TAccountMetadata>; credential: IAccountCredential }>;
47
+ }
48
+
49
+ export type TAuthState = {
50
+ account: IAccount;
51
+ credential: IAccountCredential;
52
+ };
@@ -0,0 +1,4 @@
1
+ export type { IAccount } from "./account.interface";
2
+ export type { IAccountCredential } from "./accountCredential.interface";
3
+ export type { TApiResponse } from "./base";
4
+ export type { IClient, TAuthState, TClientConfigs, TClientOptions } from "./client.interface";