alepha 0.9.3 → 0.9.5
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/LICENSE +21 -21
- package/README.md +93 -47
- package/batch.d.ts +492 -19
- package/bucket.d.ts +449 -19
- package/cache/redis.d.ts +7 -7
- package/cache.d.ts +134 -7
- package/command.d.ts +11 -9
- package/core.d.ts +184 -291
- package/datetime.d.ts +3 -7
- package/email.cjs +8 -0
- package/email.d.ts +246 -0
- package/email.js +1 -0
- package/file.d.ts +0 -3
- package/lock/redis.d.ts +2 -5
- package/lock.d.ts +420 -38
- package/logger.cjs +8 -0
- package/logger.d.ts +227 -0
- package/logger.js +1 -0
- package/package.json +57 -42
- package/postgres.d.ts +1827 -344
- package/queue/redis.d.ts +0 -2
- package/queue.d.ts +662 -21
- package/react/auth.d.ts +214 -134
- package/react/form.d.ts +119 -71
- package/react/head.d.ts +8 -15
- package/react/i18n.d.ts +27 -29
- package/react.d.ts +412 -349
- package/redis.d.ts +12 -12
- package/retry.d.ts +0 -4
- package/router.d.ts +1 -1
- package/scheduler.d.ts +9 -13
- package/security.d.ts +68 -86
- package/server/cache.d.ts +3 -5
- package/server/compress.d.ts +0 -3
- package/server/cookies.d.ts +4 -7
- package/server/cors.d.ts +1 -5
- package/server/health.d.ts +0 -3
- package/server/helmet.d.ts +28 -28
- package/server/links.d.ts +143 -30
- package/server/metrics.d.ts +1 -5
- package/server/multipart.d.ts +0 -2
- package/server/proxy.d.ts +195 -7
- package/server/security.d.ts +6 -7
- package/server/static.d.ts +4 -8
- package/server/swagger.d.ts +2 -6
- package/server.d.ts +656 -108
- package/topic/redis.d.ts +3 -6
- package/topic.d.ts +808 -24
- package/vite.d.ts +7 -5
package/react/auth.d.ts
CHANGED
|
@@ -1,123 +1,219 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import * as _alepha_core0 from "alepha";
|
|
4
|
-
import { Alepha, Async, Descriptor, KIND, Static } from "alepha";
|
|
1
|
+
import * as _alepha_core4 from "alepha";
|
|
2
|
+
import { Alepha, AlephaError, Async, Descriptor, KIND, Static } from "alepha";
|
|
5
3
|
import * as _alepha_server_cookies0 from "alepha/server/cookies";
|
|
6
4
|
import { Cookies, ServerCookiesProvider } from "alepha/server/cookies";
|
|
7
5
|
import { DateTimeProvider } from "alepha/datetime";
|
|
8
|
-
import { AccessTokenResponse, RealmDescriptor, SecurityProvider,
|
|
6
|
+
import { AccessTokenResponse, RealmDescriptor, SecurityProvider, UserAccount, UserAccountToken } from "alepha/security";
|
|
9
7
|
import { Configuration } from "openid-client";
|
|
8
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
10
9
|
import * as _alepha_server0 from "alepha/server";
|
|
11
10
|
import { HttpClient } from "alepha/server";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import * as _sinclair_typebox92 from "@sinclair/typebox";
|
|
15
|
-
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
11
|
+
import { HttpVirtualClient, ServerLinksProvider } from "alepha/server/links";
|
|
12
|
+
import * as _sinclair_typebox155 from "@sinclair/typebox";
|
|
16
13
|
|
|
17
14
|
//#region src/schemas/tokensSchema.d.ts
|
|
18
|
-
declare const tokensSchema:
|
|
19
|
-
provider:
|
|
20
|
-
access_token:
|
|
21
|
-
issued_at:
|
|
22
|
-
expires_in:
|
|
23
|
-
refresh_token:
|
|
24
|
-
refresh_token_expires_in:
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
declare const tokensSchema: _sinclair_typebox155.TObject<{
|
|
16
|
+
provider: _sinclair_typebox155.TString;
|
|
17
|
+
access_token: _sinclair_typebox155.TString;
|
|
18
|
+
issued_at: _sinclair_typebox155.TNumber;
|
|
19
|
+
expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
20
|
+
refresh_token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
21
|
+
refresh_token_expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
22
|
+
refresh_expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
23
|
+
id_token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
24
|
+
scope: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
25
|
+
token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
26
|
+
realm: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
27
27
|
}>;
|
|
28
28
|
type Tokens = Static<typeof tokensSchema>;
|
|
29
|
-
//#
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/services/ReactAuth.d.ts
|
|
31
|
+
/**
|
|
32
|
+
* Browser, SSR friendly, service to handle authentication.
|
|
33
|
+
*/
|
|
34
|
+
declare class ReactAuth {
|
|
35
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
36
|
+
protected readonly alepha: Alepha;
|
|
37
|
+
protected readonly httpClient: HttpClient;
|
|
38
|
+
static path: {
|
|
39
|
+
login: string;
|
|
40
|
+
callback: string;
|
|
41
|
+
logout: string;
|
|
42
|
+
token: string;
|
|
43
|
+
refresh: string;
|
|
44
|
+
userinfo: string;
|
|
45
|
+
};
|
|
46
|
+
protected readonly onBeginTransition: _alepha_core4.HookDescriptor<"react:transition:begin">;
|
|
47
|
+
protected readonly onFetchRequest: _alepha_core4.HookDescriptor<"client:onRequest">;
|
|
48
|
+
get user(): UserAccountToken | undefined;
|
|
49
|
+
ping(): Promise<{
|
|
50
|
+
name?: string | undefined;
|
|
51
|
+
email?: string | undefined;
|
|
52
|
+
username?: string | undefined;
|
|
53
|
+
picture?: string | undefined;
|
|
54
|
+
sessionId?: string | undefined;
|
|
55
|
+
organizations?: string[] | undefined;
|
|
56
|
+
roles?: string[] | undefined;
|
|
57
|
+
id: string;
|
|
58
|
+
} | undefined>;
|
|
59
|
+
login(provider: string, options: {
|
|
60
|
+
hostname?: string;
|
|
61
|
+
username?: string;
|
|
62
|
+
password?: string;
|
|
63
|
+
redirect?: string;
|
|
64
|
+
[extra: string]: any;
|
|
65
|
+
}): Promise<Tokens>;
|
|
66
|
+
logout(): void;
|
|
67
|
+
}
|
|
30
68
|
//#endregion
|
|
31
69
|
//#region src/providers/ReactAuthProvider.d.ts
|
|
32
70
|
declare class ReactAuthProvider {
|
|
33
|
-
protected readonly log:
|
|
71
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
34
72
|
protected readonly alepha: Alepha;
|
|
35
73
|
protected readonly serverCookiesProvider: ServerCookiesProvider;
|
|
36
|
-
protected readonly securityProvider: SecurityProvider;
|
|
37
74
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
38
75
|
protected readonly serverLinksProvider: ServerLinksProvider;
|
|
39
|
-
protected readonly
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
76
|
+
protected readonly reactAuth: ReactAuth;
|
|
77
|
+
protected readonly authorizationCode: _alepha_server_cookies0.AbstractCookieDescriptor<_sinclair_typebox155.TObject<{
|
|
78
|
+
provider: _sinclair_typebox155.TString;
|
|
79
|
+
codeVerifier: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
80
|
+
redirectUri: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
81
|
+
state: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
82
|
+
nonce: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
45
83
|
}>>;
|
|
46
|
-
readonly tokens: _alepha_server_cookies0.AbstractCookieDescriptor<
|
|
47
|
-
provider:
|
|
48
|
-
access_token:
|
|
49
|
-
issued_at:
|
|
50
|
-
expires_in:
|
|
51
|
-
refresh_token:
|
|
52
|
-
refresh_token_expires_in:
|
|
53
|
-
|
|
54
|
-
|
|
84
|
+
readonly tokens: _alepha_server_cookies0.AbstractCookieDescriptor<_sinclair_typebox155.TObject<{
|
|
85
|
+
provider: _sinclair_typebox155.TString;
|
|
86
|
+
access_token: _sinclair_typebox155.TString;
|
|
87
|
+
issued_at: _sinclair_typebox155.TNumber;
|
|
88
|
+
expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
89
|
+
refresh_token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
90
|
+
refresh_token_expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
91
|
+
refresh_expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
92
|
+
id_token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
93
|
+
scope: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
94
|
+
token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
95
|
+
realm: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
55
96
|
}>>;
|
|
56
|
-
readonly onRender:
|
|
97
|
+
readonly onRender: _alepha_core4.HookDescriptor<"react:server:render:begin">;
|
|
57
98
|
get identities(): Array<AuthDescriptor>;
|
|
58
|
-
protected readonly configure:
|
|
99
|
+
protected readonly configure: _alepha_core4.HookDescriptor<"configure">;
|
|
59
100
|
protected getAccessTokens(tokens: Tokens): string | undefined;
|
|
60
101
|
/**
|
|
61
102
|
* Fill request headers with access token from cookies or fallback to provider's fallback function.
|
|
62
103
|
*/
|
|
63
|
-
protected readonly onRequest:
|
|
104
|
+
protected readonly onRequest: _alepha_core4.HookDescriptor<"server:onRequest">;
|
|
64
105
|
/**
|
|
65
106
|
* Convert cookies to tokens.
|
|
66
107
|
* If the tokens are expired, try to refresh them using the refresh token.
|
|
67
108
|
*/
|
|
68
109
|
protected cookiesToTokens(cookies: Cookies): Promise<Tokens | undefined>;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
110
|
+
protected refreshTokens(tokens: Tokens): Promise<Tokens | undefined>;
|
|
111
|
+
/**
|
|
112
|
+
* Get user information.
|
|
113
|
+
*/
|
|
114
|
+
readonly userinfo: _alepha_server0.RouteDescriptor<{
|
|
115
|
+
response: _sinclair_typebox155.TObject<{
|
|
116
|
+
user: _sinclair_typebox155.TOptional<_sinclair_typebox155.TObject<{
|
|
117
|
+
id: _sinclair_typebox155.TString;
|
|
118
|
+
name: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
119
|
+
email: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
120
|
+
username: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
121
|
+
picture: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
122
|
+
sessionId: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
123
|
+
organizations: _sinclair_typebox155.TOptional<_sinclair_typebox155.TArray<_sinclair_typebox155.TString>>;
|
|
124
|
+
roles: _sinclair_typebox155.TOptional<_sinclair_typebox155.TArray<_sinclair_typebox155.TString>>;
|
|
125
|
+
}>>;
|
|
126
|
+
api: _sinclair_typebox155.TObject<{
|
|
127
|
+
prefix: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
128
|
+
links: _sinclair_typebox155.TArray<_sinclair_typebox155.TObject<{
|
|
129
|
+
name: _sinclair_typebox155.TString;
|
|
130
|
+
group: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
131
|
+
path: _sinclair_typebox155.TString;
|
|
132
|
+
method: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
133
|
+
requestBodyType: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
134
|
+
service: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
135
|
+
}>>;
|
|
136
|
+
}>;
|
|
137
|
+
}>;
|
|
138
|
+
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Refresh a token for internal providers.
|
|
141
|
+
*/
|
|
142
|
+
readonly refresh: _alepha_server0.RouteDescriptor<{
|
|
143
|
+
query: _sinclair_typebox155.TObject<{
|
|
144
|
+
provider: _sinclair_typebox155.TString;
|
|
145
|
+
}>;
|
|
146
|
+
body: _sinclair_typebox155.TObject<{
|
|
147
|
+
refresh_token: _sinclair_typebox155.TString;
|
|
148
|
+
access_token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
149
|
+
}>;
|
|
150
|
+
response: _sinclair_typebox155.TObject<{
|
|
151
|
+
provider: _sinclair_typebox155.TString;
|
|
152
|
+
access_token: _sinclair_typebox155.TString;
|
|
153
|
+
issued_at: _sinclair_typebox155.TNumber;
|
|
154
|
+
expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
155
|
+
refresh_token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
156
|
+
refresh_token_expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
157
|
+
refresh_expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
158
|
+
id_token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
159
|
+
scope: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
160
|
+
token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
161
|
+
realm: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
77
162
|
}>;
|
|
78
163
|
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Login for local password-based authentication.
|
|
166
|
+
*/
|
|
79
167
|
readonly token: _alepha_server0.RouteDescriptor<{
|
|
80
|
-
query:
|
|
81
|
-
provider:
|
|
168
|
+
query: _sinclair_typebox155.TObject<{
|
|
169
|
+
provider: _sinclair_typebox155.TString;
|
|
82
170
|
}>;
|
|
83
|
-
body:
|
|
84
|
-
username:
|
|
85
|
-
password:
|
|
171
|
+
body: _sinclair_typebox155.TObject<{
|
|
172
|
+
username: _sinclair_typebox155.TString;
|
|
173
|
+
password: _sinclair_typebox155.TString;
|
|
86
174
|
}>;
|
|
87
|
-
response:
|
|
88
|
-
provider:
|
|
89
|
-
access_token:
|
|
90
|
-
issued_at:
|
|
91
|
-
expires_in:
|
|
92
|
-
refresh_token:
|
|
93
|
-
refresh_token_expires_in:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
175
|
+
response: _sinclair_typebox155.TObject<{
|
|
176
|
+
provider: _sinclair_typebox155.TString;
|
|
177
|
+
access_token: _sinclair_typebox155.TString;
|
|
178
|
+
issued_at: _sinclair_typebox155.TNumber;
|
|
179
|
+
expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
180
|
+
refresh_token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
181
|
+
refresh_token_expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
182
|
+
refresh_expires_in: _sinclair_typebox155.TOptional<_sinclair_typebox155.TNumber>;
|
|
183
|
+
id_token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
184
|
+
scope: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
185
|
+
token: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
186
|
+
realm: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
187
|
+
user: _sinclair_typebox155.TObject<{
|
|
188
|
+
id: _sinclair_typebox155.TString;
|
|
189
|
+
name: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
190
|
+
email: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
191
|
+
username: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
192
|
+
picture: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
193
|
+
sessionId: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
194
|
+
organizations: _sinclair_typebox155.TOptional<_sinclair_typebox155.TArray<_sinclair_typebox155.TString>>;
|
|
195
|
+
roles: _sinclair_typebox155.TOptional<_sinclair_typebox155.TArray<_sinclair_typebox155.TString>>;
|
|
103
196
|
}>;
|
|
104
|
-
|
|
105
|
-
prefix:
|
|
106
|
-
links:
|
|
107
|
-
name:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
requestBodyType:
|
|
112
|
-
service:
|
|
197
|
+
api: _sinclair_typebox155.TObject<{
|
|
198
|
+
prefix: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
199
|
+
links: _sinclair_typebox155.TArray<_sinclair_typebox155.TObject<{
|
|
200
|
+
name: _sinclair_typebox155.TString;
|
|
201
|
+
group: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
202
|
+
path: _sinclair_typebox155.TString;
|
|
203
|
+
method: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
204
|
+
requestBodyType: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
205
|
+
service: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
113
206
|
}>>;
|
|
114
207
|
}>;
|
|
115
208
|
}>;
|
|
116
209
|
}>;
|
|
210
|
+
/**
|
|
211
|
+
* Oauth2/OIDC login route.
|
|
212
|
+
*/
|
|
117
213
|
readonly login: _alepha_server0.RouteDescriptor<{
|
|
118
|
-
query:
|
|
119
|
-
provider:
|
|
120
|
-
redirect_uri:
|
|
214
|
+
query: _sinclair_typebox155.TObject<{
|
|
215
|
+
provider: _sinclair_typebox155.TString;
|
|
216
|
+
redirect_uri: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
121
217
|
}>;
|
|
122
218
|
}>;
|
|
123
219
|
/**
|
|
@@ -125,9 +221,12 @@ declare class ReactAuthProvider {
|
|
|
125
221
|
* It handles the authorization code flow and retrieves the access token.
|
|
126
222
|
*/
|
|
127
223
|
readonly callback: _alepha_server0.RouteDescriptor<_alepha_server0.RequestConfigSchema>;
|
|
224
|
+
/**
|
|
225
|
+
* Logout route for OAuth2/OIDC providers.
|
|
226
|
+
*/
|
|
128
227
|
readonly logout: _alepha_server0.RouteDescriptor<{
|
|
129
|
-
query:
|
|
130
|
-
post_logout_redirect_uri:
|
|
228
|
+
query: _sinclair_typebox155.TObject<{
|
|
229
|
+
post_logout_redirect_uri: _sinclair_typebox155.TOptional<_sinclair_typebox155.TString>;
|
|
131
230
|
}>;
|
|
132
231
|
}>;
|
|
133
232
|
protected provider(opts: string | {
|
|
@@ -135,8 +234,9 @@ declare class ReactAuthProvider {
|
|
|
135
234
|
}): AuthDescriptor;
|
|
136
235
|
protected setTokens(tokens: Tokens, cookies?: Cookies): void;
|
|
137
236
|
}
|
|
138
|
-
interface
|
|
237
|
+
interface OAuth2Profile {
|
|
139
238
|
sub: string;
|
|
239
|
+
email?: string;
|
|
140
240
|
name?: string;
|
|
141
241
|
given_name?: string;
|
|
142
242
|
family_name?: string;
|
|
@@ -146,7 +246,6 @@ interface OAuth2UserInfo {
|
|
|
146
246
|
profile?: string;
|
|
147
247
|
picture?: string;
|
|
148
248
|
website?: string;
|
|
149
|
-
email?: string;
|
|
150
249
|
email_verified?: boolean;
|
|
151
250
|
gender?: string;
|
|
152
251
|
birthdate?: string;
|
|
@@ -165,7 +264,6 @@ interface OAuth2UserInfo {
|
|
|
165
264
|
updated_at?: number;
|
|
166
265
|
[key: string]: unknown;
|
|
167
266
|
}
|
|
168
|
-
//# sourceMappingURL=ReactAuthProvider.d.ts.map
|
|
169
267
|
//#endregion
|
|
170
268
|
//#region src/descriptors/$auth.d.ts
|
|
171
269
|
declare const $auth: {
|
|
@@ -245,10 +343,10 @@ type AuthInternal = {
|
|
|
245
343
|
oidc: OidcOptions;
|
|
246
344
|
});
|
|
247
345
|
type CredentialsOptions = {
|
|
248
|
-
|
|
346
|
+
account: (credentials: {
|
|
249
347
|
username: string;
|
|
250
348
|
password: string;
|
|
251
|
-
}) => Async<
|
|
349
|
+
}) => Async<UserAccount>;
|
|
252
350
|
};
|
|
253
351
|
interface OidcOptions {
|
|
254
352
|
/**
|
|
@@ -283,13 +381,13 @@ interface OidcOptions {
|
|
|
283
381
|
* @default "openid profile email".
|
|
284
382
|
*/
|
|
285
383
|
scope?: string;
|
|
286
|
-
|
|
287
|
-
id_token?: string;
|
|
384
|
+
account?: (tokens: {
|
|
288
385
|
access_token: string;
|
|
386
|
+
user: OAuth2Profile;
|
|
387
|
+
id_token?: string;
|
|
289
388
|
expires_in?: number;
|
|
290
389
|
scope?: string;
|
|
291
|
-
|
|
292
|
-
}) => Async<UserAccountInfo>;
|
|
390
|
+
}) => Async<UserAccount>;
|
|
293
391
|
}
|
|
294
392
|
interface OAuth2Options {
|
|
295
393
|
/**
|
|
@@ -311,7 +409,14 @@ interface OAuth2Options {
|
|
|
311
409
|
/**
|
|
312
410
|
* Function to retrieve user profile information from the OAuth2 tokens.
|
|
313
411
|
*/
|
|
314
|
-
|
|
412
|
+
userinfo: (tokens: Tokens) => Async<OAuth2Profile>;
|
|
413
|
+
account?: (tokens: {
|
|
414
|
+
access_token: string;
|
|
415
|
+
user: OAuth2Profile;
|
|
416
|
+
id_token?: string;
|
|
417
|
+
expires_in?: number;
|
|
418
|
+
scope?: string;
|
|
419
|
+
}) => Async<UserAccount>;
|
|
315
420
|
/**
|
|
316
421
|
* URL of the OAuth2 authorization endpoint.
|
|
317
422
|
*/
|
|
@@ -331,27 +436,35 @@ declare class AuthDescriptor extends Descriptor<AuthDescriptorOptions> {
|
|
|
331
436
|
get redirect_uri(): string | undefined;
|
|
332
437
|
/**
|
|
333
438
|
* Refreshes the access token using the refresh token.
|
|
439
|
+
* Can be used on oauth2, oidc or credentials auth providers.
|
|
334
440
|
*/
|
|
335
|
-
refresh(
|
|
441
|
+
refresh(refreshToken: string, accessToken?: string): Promise<AccessTokenResponse>;
|
|
336
442
|
/**
|
|
337
443
|
* Extracts user information from the access token.
|
|
338
444
|
* This is used to create a user account from the access token.
|
|
339
445
|
*/
|
|
340
|
-
user(tokens: Tokens): Promise<
|
|
341
|
-
protected getUserFromIdToken(idToken: string):
|
|
446
|
+
user(tokens: Tokens): Promise<UserAccount>;
|
|
447
|
+
protected getUserFromIdToken(idToken: string): OAuth2Profile;
|
|
342
448
|
prepare(): Promise<void>;
|
|
343
449
|
}
|
|
344
450
|
type AccessToken = string | {
|
|
345
451
|
token: () => Async<string>;
|
|
346
452
|
};
|
|
347
|
-
//#
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/errors/SessionExpiredError.d.ts
|
|
455
|
+
declare class SessionExpiredError extends AlephaError {
|
|
456
|
+
readonly name = "SessionExpiredError";
|
|
457
|
+
readonly status = 401;
|
|
458
|
+
}
|
|
348
459
|
//#endregion
|
|
349
460
|
//#region src/hooks/useAuth.d.ts
|
|
350
461
|
declare const useAuth: <T extends object = any>() => {
|
|
351
462
|
user: {
|
|
352
463
|
name?: string | undefined;
|
|
353
464
|
email?: string | undefined;
|
|
465
|
+
username?: string | undefined;
|
|
354
466
|
picture?: string | undefined;
|
|
467
|
+
sessionId?: string | undefined;
|
|
355
468
|
organizations?: string[] | undefined;
|
|
356
469
|
roles?: string[] | undefined;
|
|
357
470
|
id: string;
|
|
@@ -365,47 +478,16 @@ declare const useAuth: <T extends object = any>() => {
|
|
|
365
478
|
}) => Promise<void>;
|
|
366
479
|
can: <Api extends object = any>(name: keyof HttpVirtualClient<Api>) => boolean;
|
|
367
480
|
};
|
|
368
|
-
//# sourceMappingURL=useAuth.d.ts.map
|
|
369
|
-
//#endregion
|
|
370
|
-
//#region src/services/ReactAuth.d.ts
|
|
371
|
-
declare class ReactAuth {
|
|
372
|
-
protected readonly log: _alepha_core5.Logger;
|
|
373
|
-
protected readonly alepha: Alepha;
|
|
374
|
-
protected readonly auth: _alepha_server_links0.HttpVirtualClient<ReactAuthProvider>;
|
|
375
|
-
protected readonly client: HttpClient;
|
|
376
|
-
protected readonly linkProvider: LinkProvider;
|
|
377
|
-
static path: {
|
|
378
|
-
login: string;
|
|
379
|
-
callback: string;
|
|
380
|
-
logout: string;
|
|
381
|
-
token: string;
|
|
382
|
-
userinfo: string;
|
|
383
|
-
};
|
|
384
|
-
protected readonly onFetchRequest: _alepha_core5.HookDescriptor<"client:onRequest">;
|
|
385
|
-
readonly onRender: _alepha_core5.HookDescriptor<"react:transition:begin">;
|
|
386
|
-
get user(): UserAccountToken | undefined;
|
|
387
|
-
login(provider: string, options: {
|
|
388
|
-
username?: string;
|
|
389
|
-
password?: string;
|
|
390
|
-
redirect?: string;
|
|
391
|
-
[extra: string]: any;
|
|
392
|
-
}): Promise<void>;
|
|
393
|
-
logout(): void;
|
|
394
|
-
}
|
|
395
|
-
//# sourceMappingURL=ReactAuth.d.ts.map
|
|
396
481
|
//#endregion
|
|
397
482
|
//#region src/index.d.ts
|
|
398
483
|
declare module "alepha" {
|
|
399
484
|
interface State {
|
|
400
|
-
user?:
|
|
485
|
+
user?: UserAccount;
|
|
401
486
|
}
|
|
402
487
|
}
|
|
403
488
|
declare module "alepha/react" {
|
|
404
|
-
interface
|
|
405
|
-
user?:
|
|
406
|
-
}
|
|
407
|
-
interface ReactHydrationState {
|
|
408
|
-
user?: UserAccountInfo;
|
|
489
|
+
interface ReactRouterState {
|
|
490
|
+
user?: UserAccount;
|
|
409
491
|
}
|
|
410
492
|
}
|
|
411
493
|
/**
|
|
@@ -414,9 +496,7 @@ declare module "alepha/react" {
|
|
|
414
496
|
* @see {@link ReactAuthProvider}
|
|
415
497
|
* @module alepha.react.auth
|
|
416
498
|
*/
|
|
417
|
-
declare const AlephaReactAuth:
|
|
418
|
-
//# sourceMappingURL=index.d.ts.map
|
|
419
|
-
|
|
499
|
+
declare const AlephaReactAuth: _alepha_core4.Service<_alepha_core4.Module>;
|
|
420
500
|
//#endregion
|
|
421
|
-
export { $auth, AccessToken, AlephaReactAuth, AuthDescriptor, AuthDescriptorOptions, AuthExternal, AuthInternal, CredentialsOptions, OAuth2Options,
|
|
501
|
+
export { $auth, AccessToken, AlephaReactAuth, AuthDescriptor, AuthDescriptorOptions, AuthExternal, AuthInternal, CredentialsOptions, OAuth2Options, OAuth2Profile, OidcOptions, ReactAuth, ReactAuthProvider, SessionExpiredError, useAuth };
|
|
422
502
|
//# sourceMappingURL=index.d.ts.map
|