alepha 0.9.3 → 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 +3 -6
- package/bucket.d.ts +7 -14
- package/cache/redis.d.ts +7 -7
- package/cache.d.ts +2 -6
- package/command.d.ts +11 -11
- package/core.d.ts +99 -254
- package/datetime.d.ts +3 -7
- package/file.d.ts +0 -3
- package/lock/redis.d.ts +2 -5
- package/lock.d.ts +8 -15
- package/logger.cjs +8 -0
- package/logger.d.ts +222 -0
- package/logger.js +1 -0
- package/package.json +50 -42
- package/postgres.d.ts +192 -271
- package/queue/redis.d.ts +0 -2
- package/queue.d.ts +11 -19
- package/react/auth.d.ts +217 -134
- package/react/form.d.ts +113 -72
- package/react/head.d.ts +7 -14
- package/react/i18n.d.ts +23 -28
- package/react.d.ts +274 -256
- package/redis.d.ts +12 -12
- package/retry.d.ts +0 -4
- package/router.d.ts +0 -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 +144 -42
- package/server/metrics.d.ts +1 -5
- package/server/multipart.d.ts +0 -2
- package/server/proxy.d.ts +3 -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 +72 -96
- package/topic/redis.d.ts +3 -6
- package/topic.d.ts +5 -13
- package/vite.d.ts +5 -7
package/queue/redis.d.ts
CHANGED
|
@@ -24,8 +24,6 @@ declare class RedisQueueProvider implements QueueProvider {
|
|
|
24
24
|
* @module alepha.queue.redis
|
|
25
25
|
*/
|
|
26
26
|
declare const AlephaQueueRedis: _alepha_core0.Service<_alepha_core0.Module>;
|
|
27
|
-
//# sourceMappingURL=index.d.ts.map
|
|
28
|
-
|
|
29
27
|
//#endregion
|
|
30
28
|
export { AlephaQueueRedis, RedisQueueProvider };
|
|
31
29
|
//# sourceMappingURL=index.d.ts.map
|
package/queue.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import * as _alepha_core2 from "alepha";
|
|
2
|
-
import * as _alepha_core3 from "alepha";
|
|
3
1
|
import * as _alepha_core1 from "alepha";
|
|
4
|
-
import * as _alepha_core0 from "alepha";
|
|
5
2
|
import { Alepha, Descriptor, KIND, Service, Static, TSchema } from "alepha";
|
|
3
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
6
4
|
import { DateTimeProvider } from "alepha/datetime";
|
|
7
5
|
|
|
8
6
|
//#region src/providers/QueueProvider.d.ts
|
|
@@ -28,38 +26,36 @@ declare abstract class QueueProvider {
|
|
|
28
26
|
*/
|
|
29
27
|
abstract pop(queue: string): Promise<string | undefined>;
|
|
30
28
|
}
|
|
31
|
-
//# sourceMappingURL=QueueProvider.d.ts.map
|
|
32
29
|
//#endregion
|
|
33
30
|
//#region src/providers/MemoryQueueProvider.d.ts
|
|
34
31
|
declare class MemoryQueueProvider implements QueueProvider {
|
|
35
|
-
protected readonly log:
|
|
32
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
36
33
|
protected queueList: Record<string, string[]>;
|
|
37
34
|
push(queue: string, ...messages: string[]): Promise<void>;
|
|
38
35
|
pop(queue: string): Promise<string | undefined>;
|
|
39
36
|
}
|
|
40
|
-
//# sourceMappingURL=MemoryQueueProvider.d.ts.map
|
|
41
37
|
//#endregion
|
|
42
38
|
//#region src/providers/WorkerProvider.d.ts
|
|
43
|
-
declare const envSchema:
|
|
39
|
+
declare const envSchema: _alepha_core1.TObject<{
|
|
44
40
|
/**
|
|
45
41
|
* The interval in milliseconds to wait before checking for new messages.
|
|
46
42
|
*/
|
|
47
|
-
QUEUE_WORKER_INTERVAL:
|
|
43
|
+
QUEUE_WORKER_INTERVAL: _alepha_core1.TNumber;
|
|
48
44
|
/**
|
|
49
45
|
* The maximum interval in milliseconds to wait before checking for new messages.
|
|
50
46
|
*/
|
|
51
|
-
QUEUE_WORKER_MAX_INTERVAL:
|
|
47
|
+
QUEUE_WORKER_MAX_INTERVAL: _alepha_core1.TNumber;
|
|
52
48
|
/**
|
|
53
49
|
* The number of workers to run concurrently. Defaults to 1.
|
|
54
50
|
* Useful only if you are doing a lot of I/O.
|
|
55
51
|
*/
|
|
56
|
-
QUEUE_WORKER_CONCURRENCY:
|
|
52
|
+
QUEUE_WORKER_CONCURRENCY: _alepha_core1.TNumber;
|
|
57
53
|
}>;
|
|
58
54
|
declare module "alepha" {
|
|
59
55
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
60
56
|
}
|
|
61
57
|
declare class WorkerProvider {
|
|
62
|
-
protected readonly log:
|
|
58
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
63
59
|
protected readonly env: {
|
|
64
60
|
QUEUE_WORKER_INTERVAL: number;
|
|
65
61
|
QUEUE_WORKER_MAX_INTERVAL: number;
|
|
@@ -73,13 +69,13 @@ declare class WorkerProvider {
|
|
|
73
69
|
protected abortController: AbortController;
|
|
74
70
|
protected workerIntervals: Record<number, number>;
|
|
75
71
|
protected consumers: Array<Consumer>;
|
|
76
|
-
protected readonly start:
|
|
72
|
+
protected readonly start: _alepha_core1.HookDescriptor<"start">;
|
|
77
73
|
/**
|
|
78
74
|
* Start the workers.
|
|
79
75
|
* This method will create an endless loop that will check for new messages!
|
|
80
76
|
*/
|
|
81
77
|
protected startWorkers(): void;
|
|
82
|
-
protected readonly stop:
|
|
78
|
+
protected readonly stop: _alepha_core1.HookDescriptor<"stop">;
|
|
83
79
|
/**
|
|
84
80
|
* Wait for the next message, where `n` is the worker number.
|
|
85
81
|
*
|
|
@@ -133,7 +129,7 @@ interface QueueDescriptorOptions<T extends TSchema> {
|
|
|
133
129
|
handler?: (message: QueueMessage<T>) => Promise<void>;
|
|
134
130
|
}
|
|
135
131
|
declare class QueueDescriptor<T extends TSchema> extends Descriptor<QueueDescriptorOptions<T>> {
|
|
136
|
-
protected readonly log:
|
|
132
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
137
133
|
protected readonly workerProvider: WorkerProvider;
|
|
138
134
|
readonly provider: QueueProvider | MemoryQueueProvider;
|
|
139
135
|
push(...payloads: Array<Static<T>>): Promise<void>;
|
|
@@ -146,7 +142,6 @@ interface QueueMessageSchema {
|
|
|
146
142
|
interface QueueMessage<T extends TSchema> {
|
|
147
143
|
payload: Static<T>;
|
|
148
144
|
}
|
|
149
|
-
//# sourceMappingURL=$queue.d.ts.map
|
|
150
145
|
//#endregion
|
|
151
146
|
//#region src/descriptors/$consumer.d.ts
|
|
152
147
|
/**
|
|
@@ -163,7 +158,6 @@ interface ConsumerDescriptorOptions<T extends TSchema> {
|
|
|
163
158
|
}) => Promise<void>;
|
|
164
159
|
}
|
|
165
160
|
declare class ConsumerDescriptor<T extends TSchema> extends Descriptor<ConsumerDescriptorOptions<T>> {}
|
|
166
|
-
//# sourceMappingURL=$consumer.d.ts.map
|
|
167
161
|
//#endregion
|
|
168
162
|
//#region src/index.d.ts
|
|
169
163
|
/**
|
|
@@ -177,9 +171,7 @@ declare class ConsumerDescriptor<T extends TSchema> extends Descriptor<ConsumerD
|
|
|
177
171
|
* @see {@link $consumer}
|
|
178
172
|
* @module alepha.queue
|
|
179
173
|
*/
|
|
180
|
-
declare const AlephaQueue:
|
|
181
|
-
//# sourceMappingURL=index.d.ts.map
|
|
182
|
-
|
|
174
|
+
declare const AlephaQueue: _alepha_core1.Service<_alepha_core1.Module>;
|
|
183
175
|
//#endregion
|
|
184
176
|
export { $consumer, $queue, AlephaQueue, ConsumerDescriptor, ConsumerDescriptorOptions, MemoryQueueProvider, QueueDescriptor, QueueDescriptorOptions, QueueMessage, QueueMessageSchema, QueueProvider };
|
|
185
177
|
//# sourceMappingURL=index.d.ts.map
|
package/react/auth.d.ts
CHANGED
|
@@ -1,123 +1,222 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
4
|
-
import { Alepha, Async, Descriptor, KIND, Static } from "alepha";
|
|
5
|
-
import * as _alepha_server_cookies0 from "alepha/server/cookies";
|
|
1
|
+
import * as _alepha_core4 from "alepha";
|
|
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";
|
|
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 * as _alepha_server_links0 from "alepha/server/links";
|
|
13
11
|
import { HttpVirtualClient, LinkProvider, ServerLinksProvider } from "alepha/server/links";
|
|
14
|
-
import * as
|
|
15
|
-
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
12
|
+
import * as _sinclair_typebox156 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_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
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 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;
|
|
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;
|
|
69
|
+
}
|
|
30
70
|
//#endregion
|
|
31
71
|
//#region src/providers/ReactAuthProvider.d.ts
|
|
32
72
|
declare class ReactAuthProvider {
|
|
33
|
-
protected readonly log:
|
|
73
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
34
74
|
protected readonly alepha: Alepha;
|
|
35
75
|
protected readonly serverCookiesProvider: ServerCookiesProvider;
|
|
36
|
-
protected readonly securityProvider: SecurityProvider;
|
|
37
76
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
38
77
|
protected readonly serverLinksProvider: ServerLinksProvider;
|
|
39
|
-
protected readonly
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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>;
|
|
45
85
|
}>>;
|
|
46
|
-
readonly tokens:
|
|
47
|
-
provider:
|
|
48
|
-
access_token:
|
|
49
|
-
issued_at:
|
|
50
|
-
expires_in:
|
|
51
|
-
refresh_token:
|
|
52
|
-
refresh_token_expires_in:
|
|
53
|
-
|
|
54
|
-
|
|
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>;
|
|
55
98
|
}>>;
|
|
56
|
-
readonly onRender:
|
|
99
|
+
readonly onRender: _alepha_core4.HookDescriptor<"react:server:render:begin">;
|
|
57
100
|
get identities(): Array<AuthDescriptor>;
|
|
58
|
-
protected readonly configure:
|
|
101
|
+
protected readonly configure: _alepha_core4.HookDescriptor<"configure">;
|
|
59
102
|
protected getAccessTokens(tokens: Tokens): string | undefined;
|
|
60
103
|
/**
|
|
61
104
|
* Fill request headers with access token from cookies or fallback to provider's fallback function.
|
|
62
105
|
*/
|
|
63
|
-
protected readonly onRequest:
|
|
106
|
+
protected readonly onRequest: _alepha_core4.HookDescriptor<"server:onRequest">;
|
|
64
107
|
/**
|
|
65
108
|
* Convert cookies to tokens.
|
|
66
109
|
* If the tokens are expired, try to refresh them using the refresh token.
|
|
67
110
|
*/
|
|
68
111
|
protected cookiesToTokens(cookies: Cookies): Promise<Tokens | undefined>;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
}>;
|
|
140
|
+
}>;
|
|
141
|
+
}>;
|
|
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>;
|
|
77
165
|
}>;
|
|
78
166
|
}>;
|
|
167
|
+
/**
|
|
168
|
+
* Login for local password-based authentication.
|
|
169
|
+
*/
|
|
79
170
|
readonly token: _alepha_server0.RouteDescriptor<{
|
|
80
|
-
query:
|
|
81
|
-
provider:
|
|
171
|
+
query: _sinclair_typebox156.TObject<{
|
|
172
|
+
provider: _sinclair_typebox156.TString;
|
|
82
173
|
}>;
|
|
83
|
-
body:
|
|
84
|
-
username:
|
|
85
|
-
password:
|
|
174
|
+
body: _sinclair_typebox156.TObject<{
|
|
175
|
+
username: _sinclair_typebox156.TString;
|
|
176
|
+
password: _sinclair_typebox156.TString;
|
|
86
177
|
}>;
|
|
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
|
-
|
|
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>>;
|
|
103
199
|
}>;
|
|
104
|
-
|
|
105
|
-
prefix:
|
|
106
|
-
links:
|
|
107
|
-
name:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
requestBodyType:
|
|
112
|
-
service:
|
|
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>;
|
|
113
209
|
}>>;
|
|
114
210
|
}>;
|
|
115
211
|
}>;
|
|
116
212
|
}>;
|
|
213
|
+
/**
|
|
214
|
+
* Oauth2/OIDC login route.
|
|
215
|
+
*/
|
|
117
216
|
readonly login: _alepha_server0.RouteDescriptor<{
|
|
118
|
-
query:
|
|
119
|
-
provider:
|
|
120
|
-
redirect_uri:
|
|
217
|
+
query: _sinclair_typebox156.TObject<{
|
|
218
|
+
provider: _sinclair_typebox156.TString;
|
|
219
|
+
redirect_uri: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
121
220
|
}>;
|
|
122
221
|
}>;
|
|
123
222
|
/**
|
|
@@ -125,9 +224,12 @@ declare class ReactAuthProvider {
|
|
|
125
224
|
* It handles the authorization code flow and retrieves the access token.
|
|
126
225
|
*/
|
|
127
226
|
readonly callback: _alepha_server0.RouteDescriptor<_alepha_server0.RequestConfigSchema>;
|
|
227
|
+
/**
|
|
228
|
+
* Logout route for OAuth2/OIDC providers.
|
|
229
|
+
*/
|
|
128
230
|
readonly logout: _alepha_server0.RouteDescriptor<{
|
|
129
|
-
query:
|
|
130
|
-
post_logout_redirect_uri:
|
|
231
|
+
query: _sinclair_typebox156.TObject<{
|
|
232
|
+
post_logout_redirect_uri: _sinclair_typebox156.TOptional<_sinclair_typebox156.TString>;
|
|
131
233
|
}>;
|
|
132
234
|
}>;
|
|
133
235
|
protected provider(opts: string | {
|
|
@@ -135,8 +237,9 @@ declare class ReactAuthProvider {
|
|
|
135
237
|
}): AuthDescriptor;
|
|
136
238
|
protected setTokens(tokens: Tokens, cookies?: Cookies): void;
|
|
137
239
|
}
|
|
138
|
-
interface
|
|
240
|
+
interface OAuth2Profile {
|
|
139
241
|
sub: string;
|
|
242
|
+
email?: string;
|
|
140
243
|
name?: string;
|
|
141
244
|
given_name?: string;
|
|
142
245
|
family_name?: string;
|
|
@@ -146,7 +249,6 @@ interface OAuth2UserInfo {
|
|
|
146
249
|
profile?: string;
|
|
147
250
|
picture?: string;
|
|
148
251
|
website?: string;
|
|
149
|
-
email?: string;
|
|
150
252
|
email_verified?: boolean;
|
|
151
253
|
gender?: string;
|
|
152
254
|
birthdate?: string;
|
|
@@ -165,7 +267,6 @@ interface OAuth2UserInfo {
|
|
|
165
267
|
updated_at?: number;
|
|
166
268
|
[key: string]: unknown;
|
|
167
269
|
}
|
|
168
|
-
//# sourceMappingURL=ReactAuthProvider.d.ts.map
|
|
169
270
|
//#endregion
|
|
170
271
|
//#region src/descriptors/$auth.d.ts
|
|
171
272
|
declare const $auth: {
|
|
@@ -245,10 +346,10 @@ type AuthInternal = {
|
|
|
245
346
|
oidc: OidcOptions;
|
|
246
347
|
});
|
|
247
348
|
type CredentialsOptions = {
|
|
248
|
-
|
|
349
|
+
account: (credentials: {
|
|
249
350
|
username: string;
|
|
250
351
|
password: string;
|
|
251
|
-
}) => Async<
|
|
352
|
+
}) => Async<UserAccount>;
|
|
252
353
|
};
|
|
253
354
|
interface OidcOptions {
|
|
254
355
|
/**
|
|
@@ -283,13 +384,13 @@ interface OidcOptions {
|
|
|
283
384
|
* @default "openid profile email".
|
|
284
385
|
*/
|
|
285
386
|
scope?: string;
|
|
286
|
-
|
|
287
|
-
id_token?: string;
|
|
387
|
+
account?: (tokens: {
|
|
288
388
|
access_token: string;
|
|
389
|
+
user: OAuth2Profile;
|
|
390
|
+
id_token?: string;
|
|
289
391
|
expires_in?: number;
|
|
290
392
|
scope?: string;
|
|
291
|
-
|
|
292
|
-
}) => Async<UserAccountInfo>;
|
|
393
|
+
}) => Async<UserAccount>;
|
|
293
394
|
}
|
|
294
395
|
interface OAuth2Options {
|
|
295
396
|
/**
|
|
@@ -311,7 +412,14 @@ interface OAuth2Options {
|
|
|
311
412
|
/**
|
|
312
413
|
* Function to retrieve user profile information from the OAuth2 tokens.
|
|
313
414
|
*/
|
|
314
|
-
|
|
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>;
|
|
315
423
|
/**
|
|
316
424
|
* URL of the OAuth2 authorization endpoint.
|
|
317
425
|
*/
|
|
@@ -331,27 +439,35 @@ declare class AuthDescriptor extends Descriptor<AuthDescriptorOptions> {
|
|
|
331
439
|
get redirect_uri(): string | undefined;
|
|
332
440
|
/**
|
|
333
441
|
* Refreshes the access token using the refresh token.
|
|
442
|
+
* Can be used on oauth2, oidc or credentials auth providers.
|
|
334
443
|
*/
|
|
335
|
-
refresh(
|
|
444
|
+
refresh(refreshToken: string, accessToken?: string): Promise<AccessTokenResponse>;
|
|
336
445
|
/**
|
|
337
446
|
* Extracts user information from the access token.
|
|
338
447
|
* This is used to create a user account from the access token.
|
|
339
448
|
*/
|
|
340
|
-
user(tokens: Tokens): Promise<
|
|
341
|
-
protected getUserFromIdToken(idToken: string):
|
|
449
|
+
user(tokens: Tokens): Promise<UserAccount>;
|
|
450
|
+
protected getUserFromIdToken(idToken: string): OAuth2Profile;
|
|
342
451
|
prepare(): Promise<void>;
|
|
343
452
|
}
|
|
344
453
|
type AccessToken = string | {
|
|
345
454
|
token: () => Async<string>;
|
|
346
455
|
};
|
|
347
|
-
//#
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/errors/SessionExpiredError.d.ts
|
|
458
|
+
declare class SessionExpiredError extends AlephaError {
|
|
459
|
+
readonly name = "SessionExpiredError";
|
|
460
|
+
readonly status = 401;
|
|
461
|
+
}
|
|
348
462
|
//#endregion
|
|
349
463
|
//#region src/hooks/useAuth.d.ts
|
|
350
464
|
declare const useAuth: <T extends object = any>() => {
|
|
351
465
|
user: {
|
|
352
466
|
name?: string | undefined;
|
|
353
467
|
email?: string | undefined;
|
|
468
|
+
username?: string | undefined;
|
|
354
469
|
picture?: string | undefined;
|
|
470
|
+
sessionId?: string | undefined;
|
|
355
471
|
organizations?: string[] | undefined;
|
|
356
472
|
roles?: string[] | undefined;
|
|
357
473
|
id: string;
|
|
@@ -365,47 +481,16 @@ declare const useAuth: <T extends object = any>() => {
|
|
|
365
481
|
}) => Promise<void>;
|
|
366
482
|
can: <Api extends object = any>(name: keyof HttpVirtualClient<Api>) => boolean;
|
|
367
483
|
};
|
|
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
484
|
//#endregion
|
|
397
485
|
//#region src/index.d.ts
|
|
398
486
|
declare module "alepha" {
|
|
399
487
|
interface State {
|
|
400
|
-
user?:
|
|
488
|
+
user?: UserAccount;
|
|
401
489
|
}
|
|
402
490
|
}
|
|
403
491
|
declare module "alepha/react" {
|
|
404
|
-
interface
|
|
405
|
-
user?:
|
|
406
|
-
}
|
|
407
|
-
interface ReactHydrationState {
|
|
408
|
-
user?: UserAccountInfo;
|
|
492
|
+
interface ReactRouterState {
|
|
493
|
+
user?: UserAccount;
|
|
409
494
|
}
|
|
410
495
|
}
|
|
411
496
|
/**
|
|
@@ -414,9 +499,7 @@ declare module "alepha/react" {
|
|
|
414
499
|
* @see {@link ReactAuthProvider}
|
|
415
500
|
* @module alepha.react.auth
|
|
416
501
|
*/
|
|
417
|
-
declare const AlephaReactAuth:
|
|
418
|
-
//# sourceMappingURL=index.d.ts.map
|
|
419
|
-
|
|
502
|
+
declare const AlephaReactAuth: _alepha_core4.Service<_alepha_core4.Module>;
|
|
420
503
|
//#endregion
|
|
421
|
-
export { $auth, AccessToken, AlephaReactAuth, AuthDescriptor, AuthDescriptorOptions, AuthExternal, AuthInternal, CredentialsOptions, OAuth2Options,
|
|
504
|
+
export { $auth, AccessToken, AlephaReactAuth, AuthDescriptor, AuthDescriptorOptions, AuthExternal, AuthInternal, CredentialsOptions, OAuth2Options, OAuth2Profile, OidcOptions, ReactAuth, ReactAuthProvider, SessionExpiredError, useAuth };
|
|
422
505
|
//# sourceMappingURL=index.d.ts.map
|