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/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: _alepha_core2.Logger;
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: _alepha_core3.TObject<{
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: _alepha_core3.TNumber;
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: _alepha_core3.TNumber;
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: _alepha_core3.TNumber;
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: _alepha_core3.Logger;
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: _alepha_core3.HookDescriptor<"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: _alepha_core3.HookDescriptor<"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: _alepha_core1.Logger;
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: _alepha_core0.Service<_alepha_core0.Module>;
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 _alepha_core1 from "alepha";
2
- import * as _alepha_core5 from "alepha";
3
- import * as _alepha_core0 from "alepha";
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, UserAccountInfo, UserAccountToken } from "alepha/security";
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 _sinclair_typebox92 from "@sinclair/typebox";
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: _sinclair_typebox92.TObject<{
19
- provider: _sinclair_typebox92.TString;
20
- access_token: _sinclair_typebox92.TString;
21
- issued_at: _sinclair_typebox92.TNumber;
22
- expires_in: _sinclair_typebox92.TOptional<_sinclair_typebox92.TNumber>;
23
- refresh_token: _sinclair_typebox92.TOptional<_sinclair_typebox92.TString>;
24
- refresh_token_expires_in: _sinclair_typebox92.TOptional<_sinclair_typebox92.TNumber>;
25
- id_token: _sinclair_typebox92.TOptional<_sinclair_typebox92.TString>;
26
- scope: _sinclair_typebox92.TOptional<_sinclair_typebox92.TString>;
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
- //# sourceMappingURL=tokensSchema.d.ts.map
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: _alepha_core1.Logger;
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 authorizationCode: _alepha_server_cookies0.AbstractCookieDescriptor<_sinclair_typebox0.TObject<{
40
- provider: _sinclair_typebox0.TString;
41
- codeVerifier: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
42
- redirectUri: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
43
- state: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
44
- nonce: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
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: _alepha_server_cookies0.AbstractCookieDescriptor<_sinclair_typebox0.TObject<{
47
- provider: _sinclair_typebox0.TString;
48
- access_token: _sinclair_typebox0.TString;
49
- issued_at: _sinclair_typebox0.TNumber;
50
- expires_in: _sinclair_typebox0.TOptional<_sinclair_typebox0.TNumber>;
51
- refresh_token: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
52
- refresh_token_expires_in: _sinclair_typebox0.TOptional<_sinclair_typebox0.TNumber>;
53
- id_token: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
54
- scope: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
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: _alepha_core1.HookDescriptor<"react:server:render:begin">;
99
+ readonly onRender: _alepha_core4.HookDescriptor<"react:server:render:begin">;
57
100
  get identities(): Array<AuthDescriptor>;
58
- protected readonly configure: _alepha_core1.HookDescriptor<"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: _alepha_core1.HookDescriptor<"server: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
- readonly userinfo: _alepha_server0.ActionDescriptor<{
70
- response: _sinclair_typebox0.TObject<{
71
- id: _sinclair_typebox0.TString;
72
- name: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
73
- email: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
74
- picture: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
75
- organizations: _sinclair_typebox0.TOptional<_sinclair_typebox0.TArray<_sinclair_typebox0.TString>>;
76
- roles: _sinclair_typebox0.TOptional<_sinclair_typebox0.TArray<_sinclair_typebox0.TString>>;
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: _sinclair_typebox0.TObject<{
81
- provider: _sinclair_typebox0.TString;
171
+ query: _sinclair_typebox156.TObject<{
172
+ provider: _sinclair_typebox156.TString;
82
173
  }>;
83
- body: _sinclair_typebox0.TObject<{
84
- username: _sinclair_typebox0.TString;
85
- password: _sinclair_typebox0.TString;
174
+ body: _sinclair_typebox156.TObject<{
175
+ username: _sinclair_typebox156.TString;
176
+ password: _sinclair_typebox156.TString;
86
177
  }>;
87
- response: _sinclair_typebox0.TObject<{
88
- provider: _sinclair_typebox0.TString;
89
- access_token: _sinclair_typebox0.TString;
90
- issued_at: _sinclair_typebox0.TNumber;
91
- expires_in: _sinclair_typebox0.TOptional<_sinclair_typebox0.TNumber>;
92
- refresh_token: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
93
- refresh_token_expires_in: _sinclair_typebox0.TOptional<_sinclair_typebox0.TNumber>;
94
- id_token: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
95
- scope: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
96
- user: _sinclair_typebox0.TObject<{
97
- id: _sinclair_typebox0.TString;
98
- name: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
99
- email: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
100
- picture: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
101
- organizations: _sinclair_typebox0.TOptional<_sinclair_typebox0.TArray<_sinclair_typebox0.TString>>;
102
- roles: _sinclair_typebox0.TOptional<_sinclair_typebox0.TArray<_sinclair_typebox0.TString>>;
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
- links: _sinclair_typebox0.TObject<{
105
- prefix: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
106
- links: _sinclair_typebox0.TArray<_sinclair_typebox0.TObject<{
107
- name: _sinclair_typebox0.TString;
108
- path: _sinclair_typebox0.TString;
109
- method: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
110
- group: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
111
- requestBodyType: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
112
- service: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
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: _sinclair_typebox0.TObject<{
119
- provider: _sinclair_typebox0.TString;
120
- redirect_uri: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
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: _sinclair_typebox0.TObject<{
130
- post_logout_redirect_uri: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
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 OAuth2UserInfo {
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
- user: (entry: {
349
+ account: (credentials: {
249
350
  username: string;
250
351
  password: string;
251
- }) => Async<UserAccountInfo>;
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
- user?: (tokens: {
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
- user: OAuth2UserInfo;
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
- user: (tokens: Tokens) => Async<UserAccountInfo>;
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(tokens: Tokens): Promise<AccessTokenResponse>;
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<UserAccountInfo>;
341
- protected getUserFromIdToken(idToken: string): OAuth2UserInfo;
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
- //# sourceMappingURL=$auth.d.ts.map
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?: UserAccountInfo;
488
+ user?: UserAccount;
401
489
  }
402
490
  }
403
491
  declare module "alepha/react" {
404
- interface PageReactContext {
405
- user?: UserAccountInfo;
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: _alepha_core0.Service<_alepha_core0.Module>;
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, OAuth2UserInfo, OidcOptions, ReactAuth, ReactAuthProvider, useAuth };
504
+ export { $auth, AccessToken, AlephaReactAuth, AuthDescriptor, AuthDescriptorOptions, AuthExternal, AuthInternal, CredentialsOptions, OAuth2Options, OAuth2Profile, OidcOptions, ReactAuth, ReactAuthProvider, SessionExpiredError, useAuth };
422
505
  //# sourceMappingURL=index.d.ts.map