alepha 0.13.6 → 0.13.7
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/dist/api-audits/index.browser.js +116 -0
- package/dist/api-audits/index.browser.js.map +1 -0
- package/dist/api-audits/index.d.ts +1194 -0
- package/dist/api-audits/index.js +674 -0
- package/dist/api-audits/index.js.map +1 -0
- package/dist/api-notifications/index.d.ts +147 -147
- package/dist/api-parameters/index.browser.js +36 -5
- package/dist/api-parameters/index.browser.js.map +1 -1
- package/dist/api-parameters/index.d.ts +711 -33
- package/dist/api-parameters/index.js +831 -17
- package/dist/api-parameters/index.js.map +1 -1
- package/dist/api-users/index.d.ts +793 -780
- package/dist/api-users/index.js +699 -19
- package/dist/api-users/index.js.map +1 -1
- package/dist/api-verifications/index.js +2 -1
- package/dist/api-verifications/index.js.map +1 -1
- package/dist/bin/index.js +1 -0
- package/dist/bin/index.js.map +1 -1
- package/dist/cli/index.d.ts +85 -31
- package/dist/cli/index.js +205 -33
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +67 -6
- package/dist/command/index.js +30 -3
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +241 -61
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +170 -90
- package/dist/core/index.js +264 -67
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +248 -65
- package/dist/core/index.native.js.map +1 -1
- package/dist/email/index.js +15 -10554
- package/dist/email/index.js.map +1 -1
- package/dist/logger/index.d.ts +4 -4
- package/dist/logger/index.js +77 -72
- package/dist/logger/index.js.map +1 -1
- package/dist/orm/index.d.ts +5 -1
- package/dist/orm/index.js +24 -7
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/index.d.ts +4 -4
- package/dist/scheduler/index.d.ts +6 -6
- package/dist/server/index.d.ts +10 -1
- package/dist/server/index.js +20 -6
- package/dist/server/index.js.map +1 -1
- package/dist/server-auth/index.d.ts +163 -152
- package/dist/server-auth/index.js +40 -10
- package/dist/server-auth/index.js.map +1 -1
- package/dist/server-cookies/index.js +5 -1
- package/dist/server-cookies/index.js.map +1 -1
- package/dist/server-links/index.d.ts +33 -33
- package/dist/server-security/index.d.ts +9 -9
- package/dist/thread/index.js +2 -2
- package/dist/thread/index.js.map +1 -1
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +102 -45
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +3 -3
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.js +4 -4
- package/dist/websocket/index.js.map +1 -1
- package/package.json +14 -9
- package/src/api-audits/controllers/AuditController.ts +186 -0
- package/src/api-audits/entities/audits.ts +132 -0
- package/src/api-audits/index.browser.ts +18 -0
- package/src/api-audits/index.ts +58 -0
- package/src/api-audits/primitives/$audit.ts +159 -0
- package/src/api-audits/schemas/auditQuerySchema.ts +23 -0
- package/src/api-audits/schemas/auditResourceSchema.ts +9 -0
- package/src/api-audits/schemas/createAuditSchema.ts +27 -0
- package/src/api-audits/services/AuditService.ts +412 -0
- package/src/api-parameters/controllers/ConfigController.ts +324 -0
- package/src/api-parameters/entities/parameters.ts +93 -10
- package/src/api-parameters/index.ts +43 -4
- package/src/api-parameters/primitives/$config.ts +291 -19
- package/src/api-parameters/schedulers/ConfigActivationScheduler.ts +30 -0
- package/src/api-parameters/services/ConfigStore.ts +491 -0
- package/src/api-users/atoms/realmAuthSettingsAtom.ts +19 -0
- package/src/api-users/controllers/UserRealmController.ts +0 -2
- package/src/api-users/index.ts +2 -0
- package/src/api-users/primitives/$userRealm.ts +18 -3
- package/src/api-users/providers/UserRealmProvider.ts +6 -3
- package/src/api-users/services/RegistrationService.ts +2 -1
- package/src/api-users/services/SessionService.ts +4 -0
- package/src/api-users/services/UserService.ts +3 -0
- package/src/api-verifications/index.ts +7 -1
- package/src/bin/index.ts +1 -0
- package/src/cli/assets/biomeJson.ts +1 -1
- package/src/cli/assets/dummySpecTs.ts +7 -0
- package/src/cli/assets/editorconfig.ts +13 -0
- package/src/cli/assets/mainTs.ts +14 -0
- package/src/cli/commands/BiomeCommands.ts +2 -0
- package/src/cli/commands/CoreCommands.ts +28 -9
- package/src/cli/commands/VerifyCommands.ts +2 -1
- package/src/cli/commands/ViteCommands.ts +8 -9
- package/src/cli/services/AlephaCliUtils.ts +214 -23
- package/src/command/helpers/Asker.ts +0 -1
- package/src/command/primitives/$command.ts +67 -0
- package/src/command/providers/CliProvider.ts +39 -8
- package/src/core/Alepha.ts +40 -30
- package/src/core/helpers/jsonSchemaToTypeBox.ts +307 -0
- package/src/core/index.shared.ts +1 -0
- package/src/core/index.ts +30 -3
- package/src/core/providers/EventManager.ts +1 -1
- package/src/core/providers/StateManager.ts +23 -12
- package/src/core/providers/TypeProvider.ts +26 -34
- package/src/logger/index.ts +8 -6
- package/src/logger/primitives/$logger.ts +1 -1
- package/src/logger/providers/{SimpleFormatterProvider.ts → PrettyFormatterProvider.ts} +10 -1
- package/src/orm/index.ts +6 -0
- package/src/orm/services/PgRelationManager.ts +2 -2
- package/src/orm/services/PostgresModelBuilder.ts +11 -7
- package/src/orm/services/Repository.ts +16 -7
- package/src/orm/services/SqliteModelBuilder.ts +10 -0
- package/src/server/index.ts +6 -0
- package/src/server/primitives/$action.ts +10 -1
- package/src/server/providers/ServerBodyParserProvider.ts +11 -5
- package/src/server/providers/ServerRouterProvider.ts +13 -7
- package/src/server-auth/primitives/$auth.ts +7 -0
- package/src/server-auth/providers/ServerAuthProvider.ts +51 -8
- package/src/server-cookies/index.ts +2 -1
- package/src/thread/primitives/$thread.ts +2 -2
- package/src/vite/index.ts +0 -2
- package/src/vite/tasks/buildServer.ts +3 -4
- package/src/vite/tasks/generateCloudflare.ts +35 -19
- package/src/vite/tasks/generateDocker.ts +18 -4
- package/src/vite/tasks/generateSitemap.ts +5 -7
- package/src/vite/tasks/generateVercel.ts +76 -41
- package/src/vite/tasks/runAlepha.ts +16 -1
- package/src/websocket/providers/NodeWebSocketServerProvider.ts +3 -11
- package/src/websocket/services/WebSocketClient.ts +3 -3
- package/dist/cli/dist-BlfFtOk2.js +0 -2770
- package/dist/cli/dist-BlfFtOk2.js.map +0 -1
- package/src/api-parameters/controllers/ParameterController.ts +0 -45
- package/src/api-parameters/services/ParameterStore.ts +0 -23
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as alepha188 from "alepha";
|
|
2
2
|
import { Alepha, Async, KIND, Primitive, Static } from "alepha";
|
|
3
3
|
import * as alepha_server_cookies0 from "alepha/server/cookies";
|
|
4
4
|
import { Cookies, ServerCookiesProvider } from "alepha/server/cookies";
|
|
@@ -20,82 +20,82 @@ declare const alephaServerAuthRoutes: {
|
|
|
20
20
|
};
|
|
21
21
|
//#endregion
|
|
22
22
|
//#region ../../src/server-auth/schemas/authenticationProviderSchema.d.ts
|
|
23
|
-
declare const authenticationProviderSchema:
|
|
24
|
-
name:
|
|
25
|
-
type:
|
|
23
|
+
declare const authenticationProviderSchema: alepha188.TObject<{
|
|
24
|
+
name: alepha188.TString;
|
|
25
|
+
type: alepha188.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
|
|
26
26
|
}>;
|
|
27
27
|
type AuthenticationProvider = Static<typeof authenticationProviderSchema>;
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region ../../src/server-auth/schemas/tokenResponseSchema.d.ts
|
|
30
|
-
declare const tokenResponseSchema:
|
|
31
|
-
provider:
|
|
32
|
-
access_token:
|
|
33
|
-
issued_at:
|
|
34
|
-
expires_in:
|
|
35
|
-
refresh_token:
|
|
36
|
-
refresh_token_expires_in:
|
|
37
|
-
refresh_expires_in:
|
|
38
|
-
id_token:
|
|
39
|
-
scope:
|
|
40
|
-
user:
|
|
41
|
-
id:
|
|
42
|
-
name:
|
|
43
|
-
email:
|
|
44
|
-
username:
|
|
45
|
-
picture:
|
|
46
|
-
sessionId:
|
|
47
|
-
organizations:
|
|
48
|
-
roles:
|
|
30
|
+
declare const tokenResponseSchema: alepha188.TObject<{
|
|
31
|
+
provider: alepha188.TString;
|
|
32
|
+
access_token: alepha188.TString;
|
|
33
|
+
issued_at: alepha188.TNumber;
|
|
34
|
+
expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
35
|
+
refresh_token: alepha188.TOptional<alepha188.TString>;
|
|
36
|
+
refresh_token_expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
37
|
+
refresh_expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
38
|
+
id_token: alepha188.TOptional<alepha188.TString>;
|
|
39
|
+
scope: alepha188.TOptional<alepha188.TString>;
|
|
40
|
+
user: alepha188.TObject<{
|
|
41
|
+
id: alepha188.TString;
|
|
42
|
+
name: alepha188.TOptional<alepha188.TString>;
|
|
43
|
+
email: alepha188.TOptional<alepha188.TString>;
|
|
44
|
+
username: alepha188.TOptional<alepha188.TString>;
|
|
45
|
+
picture: alepha188.TOptional<alepha188.TString>;
|
|
46
|
+
sessionId: alepha188.TOptional<alepha188.TString>;
|
|
47
|
+
organizations: alepha188.TOptional<alepha188.TArray<alepha188.TString>>;
|
|
48
|
+
roles: alepha188.TOptional<alepha188.TArray<alepha188.TString>>;
|
|
49
49
|
}>;
|
|
50
|
-
api:
|
|
51
|
-
prefix:
|
|
52
|
-
links:
|
|
53
|
-
name:
|
|
54
|
-
group:
|
|
55
|
-
path:
|
|
56
|
-
method:
|
|
57
|
-
requestBodyType:
|
|
58
|
-
service:
|
|
50
|
+
api: alepha188.TObject<{
|
|
51
|
+
prefix: alepha188.TOptional<alepha188.TString>;
|
|
52
|
+
links: alepha188.TArray<alepha188.TObject<{
|
|
53
|
+
name: alepha188.TString;
|
|
54
|
+
group: alepha188.TOptional<alepha188.TString>;
|
|
55
|
+
path: alepha188.TString;
|
|
56
|
+
method: alepha188.TOptional<alepha188.TString>;
|
|
57
|
+
requestBodyType: alepha188.TOptional<alepha188.TString>;
|
|
58
|
+
service: alepha188.TOptional<alepha188.TString>;
|
|
59
59
|
}>>;
|
|
60
60
|
}>;
|
|
61
61
|
}>;
|
|
62
62
|
type TokenResponse = Static<typeof tokenResponseSchema>;
|
|
63
63
|
//#endregion
|
|
64
64
|
//#region ../../src/server-auth/schemas/tokensSchema.d.ts
|
|
65
|
-
declare const tokensSchema:
|
|
66
|
-
provider:
|
|
67
|
-
access_token:
|
|
68
|
-
issued_at:
|
|
69
|
-
expires_in:
|
|
70
|
-
refresh_token:
|
|
71
|
-
refresh_token_expires_in:
|
|
72
|
-
refresh_expires_in:
|
|
73
|
-
id_token:
|
|
74
|
-
scope:
|
|
65
|
+
declare const tokensSchema: alepha188.TObject<{
|
|
66
|
+
provider: alepha188.TString;
|
|
67
|
+
access_token: alepha188.TString;
|
|
68
|
+
issued_at: alepha188.TNumber;
|
|
69
|
+
expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
70
|
+
refresh_token: alepha188.TOptional<alepha188.TString>;
|
|
71
|
+
refresh_token_expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
72
|
+
refresh_expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
73
|
+
id_token: alepha188.TOptional<alepha188.TString>;
|
|
74
|
+
scope: alepha188.TOptional<alepha188.TString>;
|
|
75
75
|
}>;
|
|
76
76
|
type Tokens = Static<typeof tokensSchema>;
|
|
77
77
|
//#endregion
|
|
78
78
|
//#region ../../src/server-auth/schemas/userinfoResponseSchema.d.ts
|
|
79
|
-
declare const userinfoResponseSchema:
|
|
80
|
-
user:
|
|
81
|
-
id:
|
|
82
|
-
name:
|
|
83
|
-
email:
|
|
84
|
-
username:
|
|
85
|
-
picture:
|
|
86
|
-
sessionId:
|
|
87
|
-
organizations:
|
|
88
|
-
roles:
|
|
79
|
+
declare const userinfoResponseSchema: alepha188.TObject<{
|
|
80
|
+
user: alepha188.TOptional<alepha188.TObject<{
|
|
81
|
+
id: alepha188.TString;
|
|
82
|
+
name: alepha188.TOptional<alepha188.TString>;
|
|
83
|
+
email: alepha188.TOptional<alepha188.TString>;
|
|
84
|
+
username: alepha188.TOptional<alepha188.TString>;
|
|
85
|
+
picture: alepha188.TOptional<alepha188.TString>;
|
|
86
|
+
sessionId: alepha188.TOptional<alepha188.TString>;
|
|
87
|
+
organizations: alepha188.TOptional<alepha188.TArray<alepha188.TString>>;
|
|
88
|
+
roles: alepha188.TOptional<alepha188.TArray<alepha188.TString>>;
|
|
89
89
|
}>>;
|
|
90
|
-
api:
|
|
91
|
-
prefix:
|
|
92
|
-
links:
|
|
93
|
-
name:
|
|
94
|
-
group:
|
|
95
|
-
path:
|
|
96
|
-
method:
|
|
97
|
-
requestBodyType:
|
|
98
|
-
service:
|
|
90
|
+
api: alepha188.TObject<{
|
|
91
|
+
prefix: alepha188.TOptional<alepha188.TString>;
|
|
92
|
+
links: alepha188.TArray<alepha188.TObject<{
|
|
93
|
+
name: alepha188.TString;
|
|
94
|
+
group: alepha188.TOptional<alepha188.TString>;
|
|
95
|
+
path: alepha188.TString;
|
|
96
|
+
method: alepha188.TOptional<alepha188.TString>;
|
|
97
|
+
requestBodyType: alepha188.TOptional<alepha188.TString>;
|
|
98
|
+
service: alepha188.TOptional<alepha188.TString>;
|
|
99
99
|
}>>;
|
|
100
100
|
}>;
|
|
101
101
|
}>;
|
|
@@ -108,34 +108,35 @@ declare class ServerAuthProvider {
|
|
|
108
108
|
protected readonly serverCookiesProvider: ServerCookiesProvider;
|
|
109
109
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
110
110
|
protected readonly serverLinksProvider: ServerLinksProvider;
|
|
111
|
-
protected readonly authorizationCode: alepha_server_cookies0.AbstractCookiePrimitive<
|
|
112
|
-
provider:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
protected readonly authorizationCode: alepha_server_cookies0.AbstractCookiePrimitive<alepha188.TObject<{
|
|
112
|
+
provider: alepha188.TString;
|
|
113
|
+
realm: alepha188.TOptional<alepha188.TString>;
|
|
114
|
+
codeVerifier: alepha188.TOptional<alepha188.TString>;
|
|
115
|
+
redirectUri: alepha188.TOptional<alepha188.TString>;
|
|
116
|
+
state: alepha188.TOptional<alepha188.TString>;
|
|
117
|
+
nonce: alepha188.TOptional<alepha188.TString>;
|
|
117
118
|
}>>;
|
|
118
|
-
readonly tokens: alepha_server_cookies0.AbstractCookiePrimitive<
|
|
119
|
-
provider:
|
|
120
|
-
access_token:
|
|
121
|
-
issued_at:
|
|
122
|
-
expires_in:
|
|
123
|
-
refresh_token:
|
|
124
|
-
refresh_token_expires_in:
|
|
125
|
-
refresh_expires_in:
|
|
126
|
-
id_token:
|
|
127
|
-
scope:
|
|
119
|
+
readonly tokens: alepha_server_cookies0.AbstractCookiePrimitive<alepha188.TObject<{
|
|
120
|
+
provider: alepha188.TString;
|
|
121
|
+
access_token: alepha188.TString;
|
|
122
|
+
issued_at: alepha188.TNumber;
|
|
123
|
+
expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
124
|
+
refresh_token: alepha188.TOptional<alepha188.TString>;
|
|
125
|
+
refresh_token_expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
126
|
+
refresh_expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
127
|
+
id_token: alepha188.TOptional<alepha188.TString>;
|
|
128
|
+
scope: alepha188.TOptional<alepha188.TString>;
|
|
128
129
|
}>>;
|
|
129
130
|
get identities(): Array<AuthPrimitive>;
|
|
130
131
|
getAuthenticationProviders(filters?: {
|
|
131
132
|
realmName?: string;
|
|
132
133
|
}): AuthenticationProvider[];
|
|
133
|
-
protected readonly configure:
|
|
134
|
+
protected readonly configure: alepha188.HookPrimitive<"configure">;
|
|
134
135
|
protected getAccessTokens(tokens: Tokens): string | undefined;
|
|
135
136
|
/**
|
|
136
137
|
* Fill request headers with access token from cookies or fallback to provider's fallback function.
|
|
137
138
|
*/
|
|
138
|
-
protected readonly onRequest:
|
|
139
|
+
protected readonly onRequest: alepha188.HookPrimitive<"server:onRequest">;
|
|
139
140
|
/**
|
|
140
141
|
* Convert cookies to tokens.
|
|
141
142
|
* If the tokens are expired, try to refresh them using the refresh token.
|
|
@@ -146,26 +147,26 @@ declare class ServerAuthProvider {
|
|
|
146
147
|
* Get user information.
|
|
147
148
|
*/
|
|
148
149
|
readonly userinfo: alepha_server0.RoutePrimitive<{
|
|
149
|
-
response:
|
|
150
|
-
user:
|
|
151
|
-
id:
|
|
152
|
-
name:
|
|
153
|
-
email:
|
|
154
|
-
username:
|
|
155
|
-
picture:
|
|
156
|
-
sessionId:
|
|
157
|
-
organizations:
|
|
158
|
-
roles:
|
|
150
|
+
response: alepha188.TObject<{
|
|
151
|
+
user: alepha188.TOptional<alepha188.TObject<{
|
|
152
|
+
id: alepha188.TString;
|
|
153
|
+
name: alepha188.TOptional<alepha188.TString>;
|
|
154
|
+
email: alepha188.TOptional<alepha188.TString>;
|
|
155
|
+
username: alepha188.TOptional<alepha188.TString>;
|
|
156
|
+
picture: alepha188.TOptional<alepha188.TString>;
|
|
157
|
+
sessionId: alepha188.TOptional<alepha188.TString>;
|
|
158
|
+
organizations: alepha188.TOptional<alepha188.TArray<alepha188.TString>>;
|
|
159
|
+
roles: alepha188.TOptional<alepha188.TArray<alepha188.TString>>;
|
|
159
160
|
}>>;
|
|
160
|
-
api:
|
|
161
|
-
prefix:
|
|
162
|
-
links:
|
|
163
|
-
name:
|
|
164
|
-
group:
|
|
165
|
-
path:
|
|
166
|
-
method:
|
|
167
|
-
requestBodyType:
|
|
168
|
-
service:
|
|
161
|
+
api: alepha188.TObject<{
|
|
162
|
+
prefix: alepha188.TOptional<alepha188.TString>;
|
|
163
|
+
links: alepha188.TArray<alepha188.TObject<{
|
|
164
|
+
name: alepha188.TString;
|
|
165
|
+
group: alepha188.TOptional<alepha188.TString>;
|
|
166
|
+
path: alepha188.TString;
|
|
167
|
+
method: alepha188.TOptional<alepha188.TString>;
|
|
168
|
+
requestBodyType: alepha188.TOptional<alepha188.TString>;
|
|
169
|
+
service: alepha188.TOptional<alepha188.TString>;
|
|
169
170
|
}>>;
|
|
170
171
|
}>;
|
|
171
172
|
}>;
|
|
@@ -174,65 +175,66 @@ declare class ServerAuthProvider {
|
|
|
174
175
|
* Refresh a token for internal providers.
|
|
175
176
|
*/
|
|
176
177
|
readonly refresh: alepha_server0.RoutePrimitive<{
|
|
177
|
-
query:
|
|
178
|
-
provider:
|
|
178
|
+
query: alepha188.TObject<{
|
|
179
|
+
provider: alepha188.TString;
|
|
179
180
|
}>;
|
|
180
|
-
body:
|
|
181
|
-
refresh_token:
|
|
182
|
-
access_token:
|
|
181
|
+
body: alepha188.TObject<{
|
|
182
|
+
refresh_token: alepha188.TString;
|
|
183
|
+
access_token: alepha188.TOptional<alepha188.TString>;
|
|
183
184
|
}>;
|
|
184
|
-
response:
|
|
185
|
-
provider:
|
|
186
|
-
access_token:
|
|
187
|
-
issued_at:
|
|
188
|
-
expires_in:
|
|
189
|
-
refresh_token:
|
|
190
|
-
refresh_token_expires_in:
|
|
191
|
-
refresh_expires_in:
|
|
192
|
-
id_token:
|
|
193
|
-
scope:
|
|
185
|
+
response: alepha188.TObject<{
|
|
186
|
+
provider: alepha188.TString;
|
|
187
|
+
access_token: alepha188.TString;
|
|
188
|
+
issued_at: alepha188.TNumber;
|
|
189
|
+
expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
190
|
+
refresh_token: alepha188.TOptional<alepha188.TString>;
|
|
191
|
+
refresh_token_expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
192
|
+
refresh_expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
193
|
+
id_token: alepha188.TOptional<alepha188.TString>;
|
|
194
|
+
scope: alepha188.TOptional<alepha188.TString>;
|
|
194
195
|
}>;
|
|
195
196
|
}>;
|
|
196
197
|
/**
|
|
197
198
|
* Login for local password-based authentication.
|
|
198
199
|
*/
|
|
199
200
|
readonly token: alepha_server0.RoutePrimitive<{
|
|
200
|
-
query:
|
|
201
|
-
provider:
|
|
201
|
+
query: alepha188.TObject<{
|
|
202
|
+
provider: alepha188.TString;
|
|
203
|
+
realm: alepha188.TOptional<alepha188.TString>;
|
|
202
204
|
}>;
|
|
203
|
-
body:
|
|
204
|
-
username:
|
|
205
|
-
password:
|
|
205
|
+
body: alepha188.TObject<{
|
|
206
|
+
username: alepha188.TString;
|
|
207
|
+
password: alepha188.TString;
|
|
206
208
|
}>;
|
|
207
|
-
response:
|
|
208
|
-
provider:
|
|
209
|
-
access_token:
|
|
210
|
-
issued_at:
|
|
211
|
-
expires_in:
|
|
212
|
-
refresh_token:
|
|
213
|
-
refresh_token_expires_in:
|
|
214
|
-
refresh_expires_in:
|
|
215
|
-
id_token:
|
|
216
|
-
scope:
|
|
217
|
-
user:
|
|
218
|
-
id:
|
|
219
|
-
name:
|
|
220
|
-
email:
|
|
221
|
-
username:
|
|
222
|
-
picture:
|
|
223
|
-
sessionId:
|
|
224
|
-
organizations:
|
|
225
|
-
roles:
|
|
209
|
+
response: alepha188.TObject<{
|
|
210
|
+
provider: alepha188.TString;
|
|
211
|
+
access_token: alepha188.TString;
|
|
212
|
+
issued_at: alepha188.TNumber;
|
|
213
|
+
expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
214
|
+
refresh_token: alepha188.TOptional<alepha188.TString>;
|
|
215
|
+
refresh_token_expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
216
|
+
refresh_expires_in: alepha188.TOptional<alepha188.TNumber>;
|
|
217
|
+
id_token: alepha188.TOptional<alepha188.TString>;
|
|
218
|
+
scope: alepha188.TOptional<alepha188.TString>;
|
|
219
|
+
user: alepha188.TObject<{
|
|
220
|
+
id: alepha188.TString;
|
|
221
|
+
name: alepha188.TOptional<alepha188.TString>;
|
|
222
|
+
email: alepha188.TOptional<alepha188.TString>;
|
|
223
|
+
username: alepha188.TOptional<alepha188.TString>;
|
|
224
|
+
picture: alepha188.TOptional<alepha188.TString>;
|
|
225
|
+
sessionId: alepha188.TOptional<alepha188.TString>;
|
|
226
|
+
organizations: alepha188.TOptional<alepha188.TArray<alepha188.TString>>;
|
|
227
|
+
roles: alepha188.TOptional<alepha188.TArray<alepha188.TString>>;
|
|
226
228
|
}>;
|
|
227
|
-
api:
|
|
228
|
-
prefix:
|
|
229
|
-
links:
|
|
230
|
-
name:
|
|
231
|
-
group:
|
|
232
|
-
path:
|
|
233
|
-
method:
|
|
234
|
-
requestBodyType:
|
|
235
|
-
service:
|
|
229
|
+
api: alepha188.TObject<{
|
|
230
|
+
prefix: alepha188.TOptional<alepha188.TString>;
|
|
231
|
+
links: alepha188.TArray<alepha188.TObject<{
|
|
232
|
+
name: alepha188.TString;
|
|
233
|
+
group: alepha188.TOptional<alepha188.TString>;
|
|
234
|
+
path: alepha188.TString;
|
|
235
|
+
method: alepha188.TOptional<alepha188.TString>;
|
|
236
|
+
requestBodyType: alepha188.TOptional<alepha188.TString>;
|
|
237
|
+
service: alepha188.TOptional<alepha188.TString>;
|
|
236
238
|
}>>;
|
|
237
239
|
}>;
|
|
238
240
|
}>;
|
|
@@ -241,9 +243,10 @@ declare class ServerAuthProvider {
|
|
|
241
243
|
* Oauth2/OIDC login route.
|
|
242
244
|
*/
|
|
243
245
|
readonly login: alepha_server0.RoutePrimitive<{
|
|
244
|
-
query:
|
|
245
|
-
provider:
|
|
246
|
-
|
|
246
|
+
query: alepha188.TObject<{
|
|
247
|
+
provider: alepha188.TString;
|
|
248
|
+
realm: alepha188.TOptional<alepha188.TString>;
|
|
249
|
+
redirect_uri: alepha188.TOptional<alepha188.TString>;
|
|
247
250
|
}>;
|
|
248
251
|
}>;
|
|
249
252
|
/**
|
|
@@ -255,13 +258,20 @@ declare class ServerAuthProvider {
|
|
|
255
258
|
* Logout route for OAuth2/OIDC providers.
|
|
256
259
|
*/
|
|
257
260
|
readonly logout: alepha_server0.RoutePrimitive<{
|
|
258
|
-
query:
|
|
259
|
-
post_logout_redirect_uri:
|
|
261
|
+
query: alepha188.TObject<{
|
|
262
|
+
post_logout_redirect_uri: alepha188.TOptional<alepha188.TString>;
|
|
260
263
|
}>;
|
|
261
264
|
}>;
|
|
265
|
+
/**
|
|
266
|
+
* Find an auth provider by name and optionally by realm.
|
|
267
|
+
* When realm is specified, it filters providers by both name and realm.
|
|
268
|
+
* This enables multi-realm setups where multiple providers share the same name (e.g., "credentials").
|
|
269
|
+
*/
|
|
262
270
|
protected provider(opts: string | {
|
|
263
271
|
provider: string;
|
|
272
|
+
realm?: string;
|
|
264
273
|
}): AuthPrimitive;
|
|
274
|
+
protected getTokens(cookies?: Cookies): Tokens | undefined;
|
|
265
275
|
protected setTokens(tokens: Tokens, cookies?: Cookies): void;
|
|
266
276
|
}
|
|
267
277
|
interface OAuth2Profile {
|
|
@@ -493,6 +503,7 @@ declare class AuthPrimitive extends Primitive<AuthPrimitiveOptions> {
|
|
|
493
503
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
494
504
|
oauth?: Configuration;
|
|
495
505
|
get name(): string;
|
|
506
|
+
get realm(): RealmPrimitive | undefined;
|
|
496
507
|
get jwks_uri(): string;
|
|
497
508
|
get scope(): string | undefined;
|
|
498
509
|
get redirect_uri(): string | undefined;
|
|
@@ -577,7 +588,7 @@ declare module "alepha" {
|
|
|
577
588
|
* @see {@link ServerAuthProvider}
|
|
578
589
|
* @module alepha.server.auth
|
|
579
590
|
*/
|
|
580
|
-
declare const AlephaServerAuth:
|
|
591
|
+
declare const AlephaServerAuth: alepha188.Service<alepha188.Module>;
|
|
581
592
|
//#endregion
|
|
582
593
|
export { $auth, $authCredentials, $authGithub, $authGoogle, AccessToken, AlephaServerAuth, AuthExternal, AuthInternal, AuthPrimitive, AuthPrimitiveOptions, AuthenticationProvider, Credentials, CredentialsFn, CredentialsOptions, LinkAccountFn, LinkAccountOptions, OAuth2Options, OAuth2Profile, OidcOptions, ServerAuthProvider, TokenResponse, Tokens, UserinfoResponse, WithLinkFn, WithLoginFn, alephaServerAuthRoutes, authenticationProviderSchema, tokenResponseSchema, tokensSchema, userinfoResponseSchema };
|
|
583
594
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1283,6 +1283,9 @@ var AuthPrimitive = class extends Primitive {
|
|
|
1283
1283
|
get name() {
|
|
1284
1284
|
return this.options.name ?? this.config.propertyKey;
|
|
1285
1285
|
}
|
|
1286
|
+
get realm() {
|
|
1287
|
+
if ("realm" in this.options) return this.options.realm;
|
|
1288
|
+
}
|
|
1286
1289
|
get jwks_uri() {
|
|
1287
1290
|
const jwks = this.oauth?.serverMetadata().jwks_uri;
|
|
1288
1291
|
if (!jwks) throw new AlephaError("No JWKS URI available for the auth provider");
|
|
@@ -1424,6 +1427,7 @@ var ServerAuthProvider = class {
|
|
|
1424
1427
|
httpOnly: true,
|
|
1425
1428
|
schema: t.object({
|
|
1426
1429
|
provider: t.text(),
|
|
1430
|
+
realm: t.optional(t.text()),
|
|
1427
1431
|
codeVerifier: t.optional(t.text({ size: "long" })),
|
|
1428
1432
|
redirectUri: t.optional(t.text({ size: "long" })),
|
|
1429
1433
|
state: t.optional(t.text()),
|
|
@@ -1499,7 +1503,7 @@ var ServerAuthProvider = class {
|
|
|
1499
1503
|
* If the tokens are expired, try to refresh them using the refresh token.
|
|
1500
1504
|
*/
|
|
1501
1505
|
async cookiesToTokens(cookies) {
|
|
1502
|
-
const tokens = this.
|
|
1506
|
+
const tokens = this.getTokens(cookies);
|
|
1503
1507
|
if (!tokens) {
|
|
1504
1508
|
this.log.trace("No tokens found in cookies");
|
|
1505
1509
|
return;
|
|
@@ -1547,7 +1551,7 @@ var ServerAuthProvider = class {
|
|
|
1547
1551
|
path: alephaServerAuthRoutes.userinfo,
|
|
1548
1552
|
schema: { response: userinfoResponseSchema },
|
|
1549
1553
|
handler: async ({ user, headers: headers$1, cookies }) => {
|
|
1550
|
-
const tokens = this.
|
|
1554
|
+
const tokens = this.getTokens(cookies);
|
|
1551
1555
|
if (tokens) {
|
|
1552
1556
|
const provider = this.provider(tokens);
|
|
1553
1557
|
if (!("realm" in provider.options)) {
|
|
@@ -1604,7 +1608,10 @@ var ServerAuthProvider = class {
|
|
|
1604
1608
|
path: alephaServerAuthRoutes.token,
|
|
1605
1609
|
method: "POST",
|
|
1606
1610
|
schema: {
|
|
1607
|
-
query: t.object({
|
|
1611
|
+
query: t.object({
|
|
1612
|
+
provider: t.text(),
|
|
1613
|
+
realm: t.optional(t.text({ description: "Realm name for multi-realm setups" }))
|
|
1614
|
+
}),
|
|
1608
1615
|
body: t.object({
|
|
1609
1616
|
username: t.text(),
|
|
1610
1617
|
password: t.text()
|
|
@@ -1612,11 +1619,15 @@ var ServerAuthProvider = class {
|
|
|
1612
1619
|
response: tokenResponseSchema
|
|
1613
1620
|
},
|
|
1614
1621
|
handler: async ({ query, body, cookies }) => {
|
|
1615
|
-
const provider = this.provider(
|
|
1622
|
+
const provider = this.provider({
|
|
1623
|
+
provider: query.provider,
|
|
1624
|
+
realm: query.realm
|
|
1625
|
+
});
|
|
1616
1626
|
const realm = "realm" in provider.options && provider.options.realm;
|
|
1617
1627
|
if (!realm) throw new SecurityError(`Auth provider '${query.provider}' does not support password grant`);
|
|
1618
1628
|
const credentials = "credentials" in provider.options && provider.options.credentials;
|
|
1619
1629
|
if (!credentials) throw new SecurityError(`Auth provider '${query.provider}' does not support password grant`);
|
|
1630
|
+
console.log("->", body);
|
|
1620
1631
|
let user;
|
|
1621
1632
|
try {
|
|
1622
1633
|
user = await credentials.account(body);
|
|
@@ -1646,10 +1657,14 @@ var ServerAuthProvider = class {
|
|
|
1646
1657
|
path: alephaServerAuthRoutes.login,
|
|
1647
1658
|
schema: { query: t.object({
|
|
1648
1659
|
provider: t.text(),
|
|
1660
|
+
realm: t.optional(t.text({ description: "Realm name for multi-realm setups" })),
|
|
1649
1661
|
redirect_uri: t.optional(t.text({ size: "rich" }))
|
|
1650
1662
|
}) },
|
|
1651
1663
|
handler: async ({ query, url, reply }) => {
|
|
1652
|
-
const provider = this.provider(
|
|
1664
|
+
const provider = this.provider({
|
|
1665
|
+
provider: query.provider,
|
|
1666
|
+
realm: query.realm
|
|
1667
|
+
});
|
|
1653
1668
|
const oauth = provider.oauth;
|
|
1654
1669
|
if (!oauth) throw new SecurityError(`Auth provider '${query.provider}' does not support OAuth2`);
|
|
1655
1670
|
const scope = provider.scope;
|
|
@@ -1668,7 +1683,8 @@ var ServerAuthProvider = class {
|
|
|
1668
1683
|
state,
|
|
1669
1684
|
nonce: parameters$1.nonce,
|
|
1670
1685
|
redirectUri: query.redirect_uri ?? "/",
|
|
1671
|
-
provider: query.provider
|
|
1686
|
+
provider: query.provider,
|
|
1687
|
+
realm: query.realm
|
|
1672
1688
|
});
|
|
1673
1689
|
reply.redirect(buildAuthorizationUrl(oauth, parameters$1).toString());
|
|
1674
1690
|
return;
|
|
@@ -1684,7 +1700,8 @@ var ServerAuthProvider = class {
|
|
|
1684
1700
|
this.authorizationCode.set({
|
|
1685
1701
|
codeVerifier,
|
|
1686
1702
|
redirectUri: query.redirect_uri ?? "/",
|
|
1687
|
-
provider: query.provider
|
|
1703
|
+
provider: query.provider,
|
|
1704
|
+
realm: query.realm
|
|
1688
1705
|
});
|
|
1689
1706
|
reply.redirect(buildAuthorizationUrl(oauth, parameters).toString());
|
|
1690
1707
|
}
|
|
@@ -1740,7 +1757,7 @@ var ServerAuthProvider = class {
|
|
|
1740
1757
|
schema: { query: t.object({ post_logout_redirect_uri: t.optional(t.text()) }) },
|
|
1741
1758
|
handler: async ({ query, reply, cookies }) => {
|
|
1742
1759
|
const redirect = query.post_logout_redirect_uri ?? "/";
|
|
1743
|
-
const tokens = this.
|
|
1760
|
+
const tokens = this.getTokens(cookies);
|
|
1744
1761
|
if (!tokens) {
|
|
1745
1762
|
reply.redirect(redirect);
|
|
1746
1763
|
return;
|
|
@@ -1776,12 +1793,25 @@ var ServerAuthProvider = class {
|
|
|
1776
1793
|
reply.redirect(buildEndSessionUrl(oauth, params).toString());
|
|
1777
1794
|
}
|
|
1778
1795
|
});
|
|
1796
|
+
/**
|
|
1797
|
+
* Find an auth provider by name and optionally by realm.
|
|
1798
|
+
* When realm is specified, it filters providers by both name and realm.
|
|
1799
|
+
* This enables multi-realm setups where multiple providers share the same name (e.g., "credentials").
|
|
1800
|
+
*/
|
|
1779
1801
|
provider(opts) {
|
|
1780
1802
|
const name = typeof opts === "string" ? opts : opts.provider;
|
|
1781
|
-
const
|
|
1782
|
-
|
|
1803
|
+
const realmName = typeof opts === "string" ? void 0 : opts.realm;
|
|
1804
|
+
const identity = this.identities.find((identity$1) => {
|
|
1805
|
+
if (identity$1.name !== name) return false;
|
|
1806
|
+
if (realmName && identity$1.realm?.name !== realmName) return false;
|
|
1807
|
+
return true;
|
|
1808
|
+
});
|
|
1809
|
+
if (!identity) throw new SecurityError(`Auth provider '${name}'${realmName ? ` for realm '${realmName}'` : ""} not found`);
|
|
1783
1810
|
return identity;
|
|
1784
1811
|
}
|
|
1812
|
+
getTokens(cookies) {
|
|
1813
|
+
return this.tokens.get({ cookies });
|
|
1814
|
+
}
|
|
1785
1815
|
setTokens(tokens, cookies) {
|
|
1786
1816
|
const exp = tokens.refresh_token_expires_in || tokens.refresh_expires_in || tokens.expires_in;
|
|
1787
1817
|
const ttl = exp ? this.dateTimeProvider.duration(exp, "seconds") : void 0;
|