@mitreka/coreflow-types 0.0.6 → 0.0.8

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 (4) hide show
  1. package/auth.ts +24 -4
  2. package/error.ts +30 -0
  3. package/index.ts +1 -0
  4. package/package.json +1 -1
package/auth.ts CHANGED
@@ -63,6 +63,11 @@ export type AuthorizationRequest = {
63
63
  redirect_uri: string;
64
64
  }
65
65
 
66
+ export type ClientDetail = {
67
+ name: string;
68
+ description?: string;
69
+ }
70
+
66
71
  export type IDToken = {
67
72
  iss: string;
68
73
  aud: string; // Client ID
@@ -91,14 +96,17 @@ export interface OAuthClientEntity {
91
96
  expired_at: Date;
92
97
  }
93
98
 
94
- export interface OAuthGrant {
99
+ export interface OAuthGrant extends OAuthGrantEntity {
95
100
  id: string;
101
+ }
102
+
103
+ export interface OAuthGrantEntity {
96
104
  client_id: string;
97
105
  user_id: string;
106
+ code: string;
98
107
  scopes: string;
99
- is_granted: boolean;
100
- expires_at?: Date;
101
- granted_at: Date;
108
+ expired_at?: Date;
109
+ granted_at?: Date;
102
110
  }
103
111
 
104
112
  export interface OAuthScope extends BaseEntity, OAuthScopeEntity {
@@ -110,6 +118,17 @@ export interface OAuthScopeEntity {
110
118
  description?: string;
111
119
  }
112
120
 
121
+ export interface OAuthSession extends OAuthSessionEntity {
122
+ id: string;
123
+ }
124
+
125
+ export interface OAuthSessionEntity {
126
+ user_id: string;
127
+ ip_address: string;
128
+ user_agent: string;
129
+ expires_at?: Date;
130
+ }
131
+
113
132
  export type RedirectUriOptions = {
114
133
  client_id: string;
115
134
  code_challenge: string;
@@ -146,6 +165,7 @@ export type TokenPair = {
146
165
  export type UserCredentials = {
147
166
  username: string;
148
167
  password: string;
168
+ client_id?: string;
149
169
  }
150
170
 
151
171
  export type UserSession = {
package/error.ts ADDED
@@ -0,0 +1,30 @@
1
+ export class HttpError extends Error {
2
+ public readonly status: number;
3
+
4
+ constructor(status: number, message: string) {
5
+ super(message);
6
+ this.name = 'HttpError';
7
+ this.status = status;
8
+ }
9
+ }
10
+
11
+ export class BadRequestError extends HttpError {
12
+ constructor(message: string = 'Bad Request') {
13
+ super(400, message);
14
+ this.name = 'BadRequestError';
15
+ }
16
+ }
17
+
18
+ export class UnauthorizedError extends HttpError {
19
+ constructor(message = 'Unauthorized') {
20
+ super(401, message);
21
+ this.name = 'UnauthorizedError';
22
+ }
23
+ }
24
+
25
+ export class NotFoundError extends HttpError {
26
+ constructor(message: string = 'Not Found') {
27
+ super(404, message);
28
+ this.name = 'NotFoundError';
29
+ }
30
+ }
package/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from './company.js';
4
4
  export * from './coreflow.js';
5
5
  export * from './cryptor.js';
6
6
  export * from './entity.js';
7
+ export * from './error.js';
7
8
  export * from './find.js';
8
9
  export * from './hr.js';
9
10
  export * from './resource.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitreka/coreflow-types",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "CoreFlow Types Definition",
5
5
  "author": {
6
6
  "name": "Riyan Widiyanto",