@mitreka/coreflow-types 0.0.6 → 0.0.9
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/auth.ts +38 -9
- package/error.ts +30 -0
- package/index.ts +1 -0
- package/package.json +1 -1
- package/resource.ts +16 -6
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,27 @@ 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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
auth_code: string;
|
|
109
|
+
redirect_uri: string;
|
|
110
|
+
expired_at?: Date;
|
|
111
|
+
granted_at?: Date;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export type OAuthLogin = {
|
|
115
|
+
username: string;
|
|
116
|
+
password: string;
|
|
117
|
+
client_id: string;
|
|
118
|
+
redirect_uri: string;
|
|
119
|
+
scope: string;
|
|
102
120
|
}
|
|
103
121
|
|
|
104
122
|
export interface OAuthScope extends BaseEntity, OAuthScopeEntity {
|
|
@@ -110,6 +128,17 @@ export interface OAuthScopeEntity {
|
|
|
110
128
|
description?: string;
|
|
111
129
|
}
|
|
112
130
|
|
|
131
|
+
export interface OAuthSession extends OAuthSessionEntity {
|
|
132
|
+
id: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface OAuthSessionEntity {
|
|
136
|
+
user_id: string;
|
|
137
|
+
ip_address: string;
|
|
138
|
+
user_agent: string;
|
|
139
|
+
expires_at?: Date;
|
|
140
|
+
}
|
|
141
|
+
|
|
113
142
|
export type RedirectUriOptions = {
|
|
114
143
|
client_id: string;
|
|
115
144
|
code_challenge: string;
|
|
@@ -133,6 +162,11 @@ export type RefreshTokenOptions = {
|
|
|
133
162
|
scope?: string;
|
|
134
163
|
}
|
|
135
164
|
|
|
165
|
+
export type SessionList = {
|
|
166
|
+
active: string;
|
|
167
|
+
list: string[];
|
|
168
|
+
}
|
|
169
|
+
|
|
136
170
|
export type TokenExpires = {
|
|
137
171
|
accessExpiresIn: string;
|
|
138
172
|
refreshExpiresIn: string;
|
|
@@ -143,11 +177,6 @@ export type TokenPair = {
|
|
|
143
177
|
refresh_token: string;
|
|
144
178
|
}
|
|
145
179
|
|
|
146
|
-
export type UserCredentials = {
|
|
147
|
-
username: string;
|
|
148
|
-
password: string;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
180
|
export type UserSession = {
|
|
152
181
|
company: AccessCompany;
|
|
153
182
|
roles: AccessRole[];
|
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
package/package.json
CHANGED
package/resource.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
+
export type PageMetaData = {
|
|
2
|
+
page: number;
|
|
3
|
+
limit: number;
|
|
4
|
+
total: number;
|
|
5
|
+
total_pages: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
1
8
|
export type ResourceCollection<T> = {
|
|
2
9
|
message: string;
|
|
3
10
|
data: T[];
|
|
4
|
-
meta:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
meta: PageMetaData;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type ResourceListRequest = {
|
|
15
|
+
order: string;
|
|
16
|
+
page: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
search: string;
|
|
19
|
+
where: string;
|
|
10
20
|
}
|
|
11
21
|
|
|
12
22
|
export type ResourceEntity<T> = {
|