alepha 0.9.2 → 0.9.4
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/README.md +46 -0
- package/batch.d.ts +5 -8
- package/bucket.d.ts +9 -16
- package/cache/redis.d.ts +10 -10
- package/cache.d.ts +3 -7
- package/command.d.ts +19 -17
- package/core.d.ts +188 -340
- package/datetime.d.ts +6 -10
- package/file.d.ts +0 -3
- package/lock/redis.d.ts +3 -6
- package/lock.d.ts +9 -16
- package/{testing.cjs → logger.cjs} +1 -1
- package/logger.d.ts +222 -0
- package/logger.js +1 -0
- package/package.json +50 -49
- package/postgres.d.ts +273 -315
- package/queue/redis.d.ts +1 -3
- package/queue.d.ts +11 -19
- package/react/auth.d.ts +453 -146
- package/react/form.d.ts +119 -69
- package/react/head.d.ts +49 -18
- package/react/i18n.d.ts +61 -27
- package/react.d.ts +304 -212
- package/redis.d.ts +15 -15
- package/retry.d.ts +0 -4
- package/router.d.ts +0 -1
- package/scheduler.d.ts +6 -10
- package/security.d.ts +140 -138
- package/server/cache.d.ts +11 -11
- package/server/compress.d.ts +1 -4
- package/server/cookies.d.ts +45 -19
- package/server/cors.d.ts +4 -8
- package/server/health.d.ts +1 -4
- package/server/helmet.d.ts +28 -28
- package/server/links.d.ts +147 -45
- package/server/metrics.d.ts +5 -9
- package/server/multipart.d.ts +1 -3
- package/server/proxy.d.ts +5 -9
- package/server/security.d.ts +12 -15
- package/server/static.d.ts +6 -10
- package/server/swagger.d.ts +4 -8
- package/server.d.ts +75 -91
- package/topic/redis.d.ts +5 -8
- package/topic.d.ts +4 -12
- package/vite.d.ts +59 -30
- package/testing.d.ts +0 -1
- package/testing.js +0 -1
package/react/auth.d.ts
CHANGED
|
@@ -1,187 +1,496 @@
|
|
|
1
|
-
import * as _alepha_core0$1 from "alepha";
|
|
2
1
|
import * as _alepha_core4 from "alepha";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import * as _alepha_server_cookies0 from "alepha/server/cookies";
|
|
2
|
+
import { Alepha, AlephaError, Async, Descriptor, KIND, Static } from "alepha";
|
|
3
|
+
import * as _alepha_server_cookies1 from "alepha/server/cookies";
|
|
6
4
|
import { Cookies, ServerCookiesProvider } from "alepha/server/cookies";
|
|
5
|
+
import { DateTimeProvider } from "alepha/datetime";
|
|
6
|
+
import { AccessTokenResponse, RealmDescriptor, SecurityProvider, UserAccount, UserAccountToken } from "alepha/security";
|
|
7
|
+
import { Configuration } from "openid-client";
|
|
8
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
7
9
|
import * as _alepha_server0 from "alepha/server";
|
|
8
10
|
import { HttpClient } from "alepha/server";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import { UserAccountToken } from "alepha/security";
|
|
12
|
-
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
11
|
+
import { HttpVirtualClient, LinkProvider, ServerLinksProvider } from "alepha/server/links";
|
|
12
|
+
import * as _sinclair_typebox156 from "@sinclair/typebox";
|
|
13
13
|
|
|
14
|
-
//#region src/
|
|
15
|
-
declare const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
//#region src/schemas/tokensSchema.d.ts
|
|
15
|
+
declare const tokensSchema: _sinclair_typebox156.TObject<{
|
|
16
|
+
provider: _sinclair_typebox156.TString;
|
|
17
|
+
access_token: _sinclair_typebox156.TString;
|
|
18
|
+
issued_at: _sinclair_typebox156.TNumber;
|
|
19
|
+
expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
20
|
+
refresh_token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
21
|
+
refresh_token_expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
22
|
+
refresh_expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
23
|
+
id_token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
24
|
+
scope: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
25
|
+
token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
26
|
+
realm: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
27
|
+
}>;
|
|
28
|
+
type Tokens = Static<typeof tokensSchema>;
|
|
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 linkProvider: LinkProvider;
|
|
38
|
+
protected readonly httpClient: HttpClient;
|
|
39
|
+
static path: {
|
|
40
|
+
login: string;
|
|
41
|
+
callback: string;
|
|
42
|
+
logout: string;
|
|
43
|
+
token: string;
|
|
44
|
+
refresh: string;
|
|
45
|
+
userinfo: string;
|
|
29
46
|
};
|
|
47
|
+
protected readonly onBeginTransition: _alepha_core4.HookDescriptor<"react:transition:begin">;
|
|
48
|
+
csrfCookie: _alepha_server_cookies1.AbstractCookieDescriptor<_sinclair_typebox156.TString>;
|
|
49
|
+
protected readonly onFetchRequest: _alepha_core4.HookDescriptor<"client:onRequest">;
|
|
50
|
+
get user(): UserAccountToken | undefined;
|
|
51
|
+
ping(): Promise<{
|
|
52
|
+
name?: string | undefined;
|
|
53
|
+
email?: string | undefined;
|
|
54
|
+
username?: string | undefined;
|
|
55
|
+
picture?: string | undefined;
|
|
56
|
+
sessionId?: string | undefined;
|
|
57
|
+
organizations?: string[] | undefined;
|
|
58
|
+
roles?: string[] | undefined;
|
|
59
|
+
id: string;
|
|
60
|
+
} | undefined>;
|
|
61
|
+
login(provider: string, options: {
|
|
62
|
+
hostname?: string;
|
|
63
|
+
username?: string;
|
|
64
|
+
password?: string;
|
|
65
|
+
redirect?: string;
|
|
66
|
+
[extra: string]: any;
|
|
67
|
+
}): Promise<Tokens>;
|
|
68
|
+
logout(): void;
|
|
30
69
|
}
|
|
31
|
-
declare class AuthDescriptor extends Descriptor<AuthDescriptorOptions> {
|
|
32
|
-
get name(): string;
|
|
33
|
-
jwks(): string;
|
|
34
|
-
}
|
|
35
|
-
type AccessToken = string;
|
|
36
|
-
//# sourceMappingURL=$auth.d.ts.map
|
|
37
70
|
//#endregion
|
|
38
71
|
//#region src/providers/ReactAuthProvider.d.ts
|
|
39
72
|
declare class ReactAuthProvider {
|
|
40
|
-
protected readonly log:
|
|
73
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
41
74
|
protected readonly alepha: Alepha;
|
|
42
75
|
protected readonly serverCookiesProvider: ServerCookiesProvider;
|
|
43
|
-
protected
|
|
44
|
-
protected readonly
|
|
45
|
-
|
|
46
|
-
|
|
76
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
77
|
+
protected readonly serverLinksProvider: ServerLinksProvider;
|
|
78
|
+
protected readonly reactAuth: ReactAuth;
|
|
79
|
+
protected readonly authorizationCode: _alepha_server_cookies1.AbstractCookieDescriptor<_sinclair_typebox156.TObject<{
|
|
80
|
+
provider: _sinclair_typebox156.TString;
|
|
81
|
+
codeVerifier: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
82
|
+
redirectUri: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
83
|
+
state: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
84
|
+
nonce: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
47
85
|
}>>;
|
|
48
|
-
readonly tokens:
|
|
49
|
-
provider:
|
|
50
|
-
access_token:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
86
|
+
readonly tokens: _alepha_server_cookies1.AbstractCookieDescriptor<_sinclair_typebox156.TObject<{
|
|
87
|
+
provider: _sinclair_typebox156.TString;
|
|
88
|
+
access_token: _sinclair_typebox156.TString;
|
|
89
|
+
issued_at: _sinclair_typebox156.TNumber;
|
|
90
|
+
expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
91
|
+
refresh_token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
92
|
+
refresh_token_expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
93
|
+
refresh_expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
94
|
+
id_token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
95
|
+
scope: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
96
|
+
token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
97
|
+
realm: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
56
98
|
}>>;
|
|
57
|
-
readonly
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
picture: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
62
|
-
}>>;
|
|
63
|
-
readonly onRender: _alepha_core0$1.HookDescriptor<"react:server:render:begin">;
|
|
64
|
-
protected readonly configure: _alepha_core0$1.HookDescriptor<"configure">;
|
|
65
|
-
protected getAccessTokenFromCookies(tokens: SessionTokens): Promise<string | undefined>;
|
|
99
|
+
readonly onRender: _alepha_core4.HookDescriptor<"react:server:render:begin">;
|
|
100
|
+
get identities(): Array<AuthDescriptor>;
|
|
101
|
+
protected readonly configure: _alepha_core4.HookDescriptor<"configure">;
|
|
102
|
+
protected getAccessTokens(tokens: Tokens): string | undefined;
|
|
66
103
|
/**
|
|
67
|
-
*
|
|
104
|
+
* Fill request headers with access token from cookies or fallback to provider's fallback function.
|
|
68
105
|
*/
|
|
69
|
-
protected readonly onRequest:
|
|
106
|
+
protected readonly onRequest: _alepha_core4.HookDescriptor<"server:onRequest">;
|
|
70
107
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @protected
|
|
108
|
+
* Convert cookies to tokens.
|
|
109
|
+
* If the tokens are expired, try to refresh them using the refresh token.
|
|
74
110
|
*/
|
|
75
|
-
protected
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
111
|
+
protected cookiesToTokens(cookies: Cookies): Promise<Tokens | undefined>;
|
|
112
|
+
protected checkCsrf(cookies: Cookies, csrfHeader: string): Promise<void>;
|
|
113
|
+
protected refreshTokens(tokens: Tokens): Promise<Tokens | undefined>;
|
|
114
|
+
/**
|
|
115
|
+
* Get user information.
|
|
116
|
+
*/
|
|
117
|
+
readonly userinfo: _alepha_server0.RouteDescriptor<{
|
|
118
|
+
response: _sinclair_typebox156.TObject<{
|
|
119
|
+
user: _sinclair_typebox156.TOptional<_sinclair_typebox156.TObject<{
|
|
120
|
+
id: _sinclair_typebox156.TString;
|
|
121
|
+
name: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
122
|
+
email: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
123
|
+
username: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
124
|
+
picture: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
125
|
+
sessionId: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
126
|
+
organizations: _sinclair_typebox156.TOptional<_sinclair_typebox156.TArray<_sinclair_typebox156.TString>>;
|
|
127
|
+
roles: _sinclair_typebox156.TOptional<_sinclair_typebox156.TArray<_sinclair_typebox156.TString>>;
|
|
128
|
+
}>>;
|
|
129
|
+
api: _sinclair_typebox156.TObject<{
|
|
130
|
+
prefix: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
131
|
+
links: _sinclair_typebox156.TArray<_sinclair_typebox156.TObject<{
|
|
132
|
+
name: _sinclair_typebox156.TString;
|
|
133
|
+
group: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
134
|
+
path: _sinclair_typebox156.TString;
|
|
135
|
+
method: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
136
|
+
requestBodyType: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
137
|
+
service: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
138
|
+
}>>;
|
|
139
|
+
}>;
|
|
80
140
|
}>;
|
|
81
141
|
}>;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Refresh a token for internal providers.
|
|
144
|
+
*/
|
|
145
|
+
readonly refresh: _alepha_server0.RouteDescriptor<{
|
|
146
|
+
query: _sinclair_typebox156.TObject<{
|
|
147
|
+
provider: _sinclair_typebox156.TString;
|
|
148
|
+
}>;
|
|
149
|
+
body: _sinclair_typebox156.TObject<{
|
|
150
|
+
refresh_token: _sinclair_typebox156.TString;
|
|
151
|
+
access_token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
152
|
+
}>;
|
|
153
|
+
response: _sinclair_typebox156.TObject<{
|
|
154
|
+
provider: _sinclair_typebox156.TString;
|
|
155
|
+
access_token: _sinclair_typebox156.TString;
|
|
156
|
+
issued_at: _sinclair_typebox156.TNumber;
|
|
157
|
+
expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
158
|
+
refresh_token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
159
|
+
refresh_token_expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
160
|
+
refresh_expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
161
|
+
id_token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
162
|
+
scope: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
163
|
+
token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
164
|
+
realm: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
85
165
|
}>;
|
|
86
166
|
}>;
|
|
87
167
|
/**
|
|
88
|
-
*
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
168
|
+
* Login for local password-based authentication.
|
|
169
|
+
*/
|
|
170
|
+
readonly token: _alepha_server0.RouteDescriptor<{
|
|
171
|
+
query: _sinclair_typebox156.TObject<{
|
|
172
|
+
provider: _sinclair_typebox156.TString;
|
|
173
|
+
}>;
|
|
174
|
+
body: _sinclair_typebox156.TObject<{
|
|
175
|
+
username: _sinclair_typebox156.TString;
|
|
176
|
+
password: _sinclair_typebox156.TString;
|
|
177
|
+
}>;
|
|
178
|
+
response: _sinclair_typebox156.TObject<{
|
|
179
|
+
provider: _sinclair_typebox156.TString;
|
|
180
|
+
access_token: _sinclair_typebox156.TString;
|
|
181
|
+
issued_at: _sinclair_typebox156.TNumber;
|
|
182
|
+
expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
183
|
+
refresh_token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
184
|
+
refresh_token_expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
185
|
+
refresh_expires_in: _sinclair_typebox156.TOptional<_sinclair_typebox156.TNumber>;
|
|
186
|
+
id_token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
187
|
+
scope: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
188
|
+
token: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
189
|
+
realm: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
190
|
+
user: _sinclair_typebox156.TObject<{
|
|
191
|
+
id: _sinclair_typebox156.TString;
|
|
192
|
+
name: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
193
|
+
email: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
194
|
+
username: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
195
|
+
picture: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
196
|
+
sessionId: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
197
|
+
organizations: _sinclair_typebox156.TOptional<_sinclair_typebox156.TArray<_sinclair_typebox156.TString>>;
|
|
198
|
+
roles: _sinclair_typebox156.TOptional<_sinclair_typebox156.TArray<_sinclair_typebox156.TString>>;
|
|
199
|
+
}>;
|
|
200
|
+
api: _sinclair_typebox156.TObject<{
|
|
201
|
+
prefix: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
202
|
+
links: _sinclair_typebox156.TArray<_sinclair_typebox156.TObject<{
|
|
203
|
+
name: _sinclair_typebox156.TString;
|
|
204
|
+
group: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
205
|
+
path: _sinclair_typebox156.TString;
|
|
206
|
+
method: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
207
|
+
requestBodyType: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
208
|
+
service: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
209
|
+
}>>;
|
|
210
|
+
}>;
|
|
102
211
|
}>;
|
|
103
212
|
}>;
|
|
104
213
|
/**
|
|
105
|
-
*
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
redirectUri: string;
|
|
113
|
-
fallback?: () => Async<AccessToken>;
|
|
114
|
-
useIdToken?: boolean;
|
|
115
|
-
logoutUri?: string;
|
|
214
|
+
* Oauth2/OIDC login route.
|
|
215
|
+
*/
|
|
216
|
+
readonly login: _alepha_server0.RouteDescriptor<{
|
|
217
|
+
query: _sinclair_typebox156.TObject<{
|
|
218
|
+
provider: _sinclair_typebox156.TString;
|
|
219
|
+
redirect_uri: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
220
|
+
}>;
|
|
116
221
|
}>;
|
|
117
222
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* @protected
|
|
223
|
+
* Callback for OAuth2/OIDC providers.
|
|
224
|
+
* It handles the authorization code flow and retrieves the access token.
|
|
121
225
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
provider
|
|
226
|
+
readonly callback: _alepha_server0.RouteDescriptor<_alepha_server0.RequestConfigSchema>;
|
|
227
|
+
/**
|
|
228
|
+
* Logout route for OAuth2/OIDC providers.
|
|
229
|
+
*/
|
|
230
|
+
readonly logout: _alepha_server0.RouteDescriptor<{
|
|
231
|
+
query: _sinclair_typebox156.TObject<{
|
|
232
|
+
post_logout_redirect_uri: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
233
|
+
}>;
|
|
234
|
+
}>;
|
|
235
|
+
protected provider(opts: string | {
|
|
236
|
+
provider: string;
|
|
237
|
+
}): AuthDescriptor;
|
|
238
|
+
protected setTokens(tokens: Tokens, cookies?: Cookies): void;
|
|
132
239
|
}
|
|
133
|
-
interface
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
240
|
+
interface OAuth2Profile {
|
|
241
|
+
sub: string;
|
|
242
|
+
email?: string;
|
|
243
|
+
name?: string;
|
|
244
|
+
given_name?: string;
|
|
245
|
+
family_name?: string;
|
|
246
|
+
middle_name?: string;
|
|
247
|
+
nickname?: string;
|
|
248
|
+
preferred_username?: string;
|
|
249
|
+
profile?: string;
|
|
250
|
+
picture?: string;
|
|
251
|
+
website?: string;
|
|
252
|
+
email_verified?: boolean;
|
|
253
|
+
gender?: string;
|
|
254
|
+
birthdate?: string;
|
|
255
|
+
zoneinfo?: string;
|
|
256
|
+
locale?: string;
|
|
257
|
+
phone_number?: string;
|
|
258
|
+
phone_number_verified?: boolean;
|
|
259
|
+
address?: {
|
|
260
|
+
formatted?: string;
|
|
261
|
+
street_address?: string;
|
|
262
|
+
locality?: string;
|
|
263
|
+
region?: string;
|
|
264
|
+
postal_code?: string;
|
|
265
|
+
country?: string;
|
|
138
266
|
};
|
|
267
|
+
updated_at?: number;
|
|
268
|
+
[key: string]: unknown;
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region src/descriptors/$auth.d.ts
|
|
272
|
+
declare const $auth: {
|
|
273
|
+
(options: AuthDescriptorOptions): AuthDescriptor;
|
|
274
|
+
[KIND]: typeof AuthDescriptor;
|
|
275
|
+
};
|
|
276
|
+
type AuthDescriptorOptions = {
|
|
277
|
+
/**
|
|
278
|
+
* Name of the identity provider.
|
|
279
|
+
* If not provided, it will be derived from the property key.
|
|
280
|
+
*/
|
|
281
|
+
name?: string;
|
|
282
|
+
/**
|
|
283
|
+
* If true, auth provider will be skipped.
|
|
284
|
+
*/
|
|
285
|
+
disabled?: boolean;
|
|
286
|
+
} & (AuthExternal | AuthInternal);
|
|
287
|
+
/**
|
|
288
|
+
* When you let an external service handle authentication. (e.g. Keycloak, Auth0, etc.)
|
|
289
|
+
*/
|
|
290
|
+
type AuthExternal = {
|
|
291
|
+
/**
|
|
292
|
+
* Only OIDC is supported for external authentication.
|
|
293
|
+
*/
|
|
294
|
+
oidc: OidcOptions;
|
|
295
|
+
/**
|
|
296
|
+
* For anonymous access, this will expect a service account access token.
|
|
297
|
+
*
|
|
298
|
+
* ```ts
|
|
299
|
+
* class App {
|
|
300
|
+
* anonymous = $serviceAccount(...);
|
|
301
|
+
* auth = $auth({
|
|
302
|
+
* // ... config ...
|
|
303
|
+
* fallback: this.anonymous,
|
|
304
|
+
* })
|
|
305
|
+
* }
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
139
308
|
fallback?: () => Async<AccessToken>;
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* When using your own authentication system, e.g. using a database to store user accounts.
|
|
312
|
+
* This is usually used with a custom login form.
|
|
313
|
+
*
|
|
314
|
+
* This relies on the `realm`, which is used to create/verify the access token.
|
|
315
|
+
*/
|
|
316
|
+
type AuthInternal = {
|
|
317
|
+
realm: RealmDescriptor;
|
|
318
|
+
} & ({
|
|
319
|
+
/**
|
|
320
|
+
* The common username/password authentication.
|
|
321
|
+
*
|
|
322
|
+
* - It uses the OAuth2 Client Credentials flow to obtain an access token.
|
|
323
|
+
*
|
|
324
|
+
* This is usually used with a custom login form on your website or mobile app.
|
|
325
|
+
*/
|
|
326
|
+
credentials: CredentialsOptions;
|
|
327
|
+
} | {
|
|
328
|
+
/**
|
|
329
|
+
* OAuth2 authentication. Delegates authentication to an OAuth2 provider. (e.g. Google, GitHub, etc.)
|
|
330
|
+
*
|
|
331
|
+
* - It uses the OAuth2 Authorization Code flow to obtain an access token and user information.
|
|
332
|
+
*
|
|
333
|
+
* This is usually used with a login button that redirects to the OAuth2 provider.
|
|
334
|
+
*/
|
|
335
|
+
oauth: OAuth2Options;
|
|
336
|
+
} | {
|
|
337
|
+
/**
|
|
338
|
+
* Like OAuth2, but uses OIDC (OpenID Connect) for authentication and user information retrieval.
|
|
339
|
+
* OIDC is an identity layer on top of OAuth2, providing user authentication and profile information.
|
|
340
|
+
*
|
|
341
|
+
* - It uses the OAuth2 Authorization Code flow to obtain an access token and user information.
|
|
342
|
+
* - PCKE (Proof Key for Code Exchange) is recommended for security.
|
|
343
|
+
*
|
|
344
|
+
* This is usually used with a login button that redirects to the OIDC provider.
|
|
345
|
+
*/
|
|
346
|
+
oidc: OidcOptions;
|
|
347
|
+
});
|
|
348
|
+
type CredentialsOptions = {
|
|
349
|
+
account: (credentials: {
|
|
350
|
+
username: string;
|
|
351
|
+
password: string;
|
|
352
|
+
}) => Async<UserAccount>;
|
|
353
|
+
};
|
|
354
|
+
interface OidcOptions {
|
|
355
|
+
/**
|
|
356
|
+
* URL of the OIDC issuer.
|
|
357
|
+
*/
|
|
358
|
+
issuer: string;
|
|
359
|
+
/**
|
|
360
|
+
* Client ID for the OIDC client.
|
|
361
|
+
*/
|
|
362
|
+
clientId: string;
|
|
363
|
+
/**
|
|
364
|
+
* Client secret for the OIDC client.
|
|
365
|
+
* Optional if PKCE (Proof Key for Code Exchange) is used.
|
|
366
|
+
*/
|
|
367
|
+
clientSecret?: string;
|
|
368
|
+
/**
|
|
369
|
+
* Redirect URI for the OIDC client.
|
|
370
|
+
* This is where the user will be redirected after authentication.
|
|
371
|
+
*/
|
|
372
|
+
redirectUri?: string;
|
|
373
|
+
/**
|
|
374
|
+
* For external auth providers only.
|
|
375
|
+
* Take the ID token instead of the access token for validation.
|
|
376
|
+
*/
|
|
140
377
|
useIdToken?: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* URI to redirect the user after logout.
|
|
380
|
+
*/
|
|
141
381
|
logoutUri?: string;
|
|
382
|
+
/**
|
|
383
|
+
* Optional scope for the OIDC client.
|
|
384
|
+
* @default "openid profile email".
|
|
385
|
+
*/
|
|
386
|
+
scope?: string;
|
|
387
|
+
account?: (tokens: {
|
|
388
|
+
access_token: string;
|
|
389
|
+
user: OAuth2Profile;
|
|
390
|
+
id_token?: string;
|
|
391
|
+
expires_in?: number;
|
|
392
|
+
scope?: string;
|
|
393
|
+
}) => Async<UserAccount>;
|
|
142
394
|
}
|
|
143
|
-
interface
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
395
|
+
interface OAuth2Options {
|
|
396
|
+
/**
|
|
397
|
+
* URL of the OAuth2 authorization endpoint.
|
|
398
|
+
*/
|
|
399
|
+
clientId: string;
|
|
400
|
+
/**
|
|
401
|
+
* Client secret for the OAuth2 client.
|
|
402
|
+
*/
|
|
403
|
+
clientSecret: string;
|
|
404
|
+
/**
|
|
405
|
+
* URL of the OAuth2 authorization endpoint.
|
|
406
|
+
*/
|
|
407
|
+
authorization: string;
|
|
408
|
+
/**
|
|
409
|
+
* URL of the OAuth2 token endpoint.
|
|
410
|
+
*/
|
|
411
|
+
token: string;
|
|
412
|
+
/**
|
|
413
|
+
* Function to retrieve user profile information from the OAuth2 tokens.
|
|
414
|
+
*/
|
|
415
|
+
userinfo: (tokens: Tokens) => Async<OAuth2Profile>;
|
|
416
|
+
account?: (tokens: {
|
|
417
|
+
access_token: string;
|
|
418
|
+
user: OAuth2Profile;
|
|
419
|
+
id_token?: string;
|
|
420
|
+
expires_in?: number;
|
|
421
|
+
scope?: string;
|
|
422
|
+
}) => Async<UserAccount>;
|
|
423
|
+
/**
|
|
424
|
+
* URL of the OAuth2 authorization endpoint.
|
|
425
|
+
*/
|
|
426
|
+
redirectUri?: string;
|
|
427
|
+
/**
|
|
428
|
+
* URL of the OAuth2 authorization endpoint.
|
|
429
|
+
*/
|
|
430
|
+
scope?: string;
|
|
147
431
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
432
|
+
declare class AuthDescriptor extends Descriptor<AuthDescriptorOptions> {
|
|
433
|
+
protected readonly securityProvider: SecurityProvider;
|
|
434
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
435
|
+
oauth?: Configuration;
|
|
436
|
+
get name(): string;
|
|
437
|
+
get jwks_uri(): string;
|
|
438
|
+
get scope(): string | undefined;
|
|
439
|
+
get redirect_uri(): string | undefined;
|
|
440
|
+
/**
|
|
441
|
+
* Refreshes the access token using the refresh token.
|
|
442
|
+
* Can be used on oauth2, oidc or credentials auth providers.
|
|
443
|
+
*/
|
|
444
|
+
refresh(refreshToken: string, accessToken?: string): Promise<AccessTokenResponse>;
|
|
445
|
+
/**
|
|
446
|
+
* Extracts user information from the access token.
|
|
447
|
+
* This is used to create a user account from the access token.
|
|
448
|
+
*/
|
|
449
|
+
user(tokens: Tokens): Promise<UserAccount>;
|
|
450
|
+
protected getUserFromIdToken(idToken: string): OAuth2Profile;
|
|
451
|
+
prepare(): Promise<void>;
|
|
157
452
|
}
|
|
158
|
-
|
|
453
|
+
type AccessToken = string | {
|
|
454
|
+
token: () => Async<string>;
|
|
455
|
+
};
|
|
159
456
|
//#endregion
|
|
160
|
-
//#region src/
|
|
161
|
-
declare class
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
protected readonly client: HttpClient;
|
|
165
|
-
static path: {
|
|
166
|
-
login: string;
|
|
167
|
-
callback: string;
|
|
168
|
-
logout: string;
|
|
169
|
-
};
|
|
170
|
-
readonly onRender: _alepha_core4.HookDescriptor<"react:transition:begin">;
|
|
171
|
-
get user(): UserAccountToken | undefined;
|
|
172
|
-
protected getUserFromCookies(): UserAccountToken | undefined;
|
|
173
|
-
login(): void;
|
|
174
|
-
logout(): void;
|
|
457
|
+
//#region src/errors/SessionExpiredError.d.ts
|
|
458
|
+
declare class SessionExpiredError extends AlephaError {
|
|
459
|
+
readonly name = "SessionExpiredError";
|
|
460
|
+
readonly status = 401;
|
|
175
461
|
}
|
|
176
|
-
//#
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region src/hooks/useAuth.d.ts
|
|
464
|
+
declare const useAuth: <T extends object = any>() => {
|
|
465
|
+
user: {
|
|
466
|
+
name?: string | undefined;
|
|
467
|
+
email?: string | undefined;
|
|
468
|
+
username?: string | undefined;
|
|
469
|
+
picture?: string | undefined;
|
|
470
|
+
sessionId?: string | undefined;
|
|
471
|
+
organizations?: string[] | undefined;
|
|
472
|
+
roles?: string[] | undefined;
|
|
473
|
+
id: string;
|
|
474
|
+
} | undefined;
|
|
475
|
+
logout: () => void;
|
|
476
|
+
login: (provider: keyof T, options?: {
|
|
477
|
+
username?: string;
|
|
478
|
+
password?: string;
|
|
479
|
+
redirect?: string;
|
|
480
|
+
[extra: string]: any;
|
|
481
|
+
}) => Promise<void>;
|
|
482
|
+
can: <Api extends object = any>(name: keyof HttpVirtualClient<Api>) => boolean;
|
|
483
|
+
};
|
|
177
484
|
//#endregion
|
|
178
485
|
//#region src/index.d.ts
|
|
179
|
-
declare module "alepha
|
|
180
|
-
interface
|
|
181
|
-
user?:
|
|
486
|
+
declare module "alepha" {
|
|
487
|
+
interface State {
|
|
488
|
+
user?: UserAccount;
|
|
182
489
|
}
|
|
183
|
-
|
|
184
|
-
|
|
490
|
+
}
|
|
491
|
+
declare module "alepha/react" {
|
|
492
|
+
interface ReactRouterState {
|
|
493
|
+
user?: UserAccount;
|
|
185
494
|
}
|
|
186
495
|
}
|
|
187
496
|
/**
|
|
@@ -190,9 +499,7 @@ declare module "alepha/react" {
|
|
|
190
499
|
* @see {@link ReactAuthProvider}
|
|
191
500
|
* @module alepha.react.auth
|
|
192
501
|
*/
|
|
193
|
-
declare const AlephaReactAuth:
|
|
194
|
-
//# sourceMappingURL=index.d.ts.map
|
|
195
|
-
|
|
502
|
+
declare const AlephaReactAuth: _alepha_core4.Service<_alepha_core4.Module>;
|
|
196
503
|
//#endregion
|
|
197
|
-
export { $auth, AccessToken, AlephaReactAuth, AuthDescriptor, AuthDescriptorOptions,
|
|
504
|
+
export { $auth, AccessToken, AlephaReactAuth, AuthDescriptor, AuthDescriptorOptions, AuthExternal, AuthInternal, CredentialsOptions, OAuth2Options, OAuth2Profile, OidcOptions, ReactAuth, ReactAuthProvider, SessionExpiredError, useAuth };
|
|
198
505
|
//# sourceMappingURL=index.d.ts.map
|