alepha 0.9.1 → 0.9.3
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/batch.d.ts +4 -4
- package/bucket.d.ts +3 -3
- package/cache/redis.d.ts +4 -4
- package/cache.d.ts +3 -3
- package/command.d.ts +27 -13
- package/core.d.ts +104 -100
- package/datetime.d.ts +5 -5
- package/lock/redis.d.ts +1 -1
- package/lock.d.ts +8 -8
- package/package.json +54 -47
- package/postgres.d.ts +135 -98
- package/queue/redis.d.ts +1 -1
- package/queue.d.ts +12 -12
- package/react/auth.d.ts +342 -118
- package/{testing.cjs → react/form.cjs} +1 -1
- package/react/form.d.ts +126 -0
- package/react/form.js +1 -0
- package/react/head.d.ts +46 -8
- package/react/i18n.cjs +8 -0
- package/react/i18n.d.ts +112 -0
- package/react/i18n.js +1 -0
- package/react.d.ts +261 -164
- package/redis.d.ts +7 -7
- package/scheduler.d.ts +9 -9
- package/security.d.ts +131 -111
- package/server/cache.d.ts +10 -8
- package/server/compress.d.ts +1 -1
- package/server/cookies.d.ts +44 -15
- package/server/cors.d.ts +4 -4
- package/server/health.d.ts +1 -1
- package/server/helmet.d.ts +1 -1
- package/server/links.d.ts +11 -10
- package/server/metrics.d.ts +5 -5
- package/server/multipart.d.ts +1 -1
- package/server/proxy.d.ts +4 -4
- package/server/security.d.ts +8 -10
- package/server/static.d.ts +3 -3
- package/server/swagger.d.ts +3 -3
- package/server.d.ts +47 -39
- package/topic/redis.d.ts +4 -4
- package/topic.d.ts +5 -5
- package/vite.d.ts +55 -24
- package/testing.d.ts +0 -1
- package/testing.js +0 -1
package/security.d.ts
CHANGED
|
@@ -1,43 +1,26 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alepha_core2 from "alepha";
|
|
2
|
+
import * as _alepha_core3 from "alepha";
|
|
2
3
|
import * as _alepha_core1 from "alepha";
|
|
3
4
|
import * as _alepha_core0 from "alepha";
|
|
4
5
|
import { Alepha, Descriptor, KIND, Static } from "alepha";
|
|
5
|
-
import { DateTimeProvider } from "alepha/datetime";
|
|
6
|
+
import { DateTimeProvider, Duration, DurationLike } from "alepha/datetime";
|
|
6
7
|
import { CryptoKey, FlattenedJWSInput, JSONWebKeySet, JWSHeaderParameters, JWTHeaderParameters, JWTPayload, JWTVerifyResult, KeyObject } from "jose";
|
|
7
8
|
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
8
|
-
import * as
|
|
9
|
+
import * as _sinclair_typebox13 from "@sinclair/typebox";
|
|
10
|
+
import * as _sinclair_typebox23 from "@sinclair/typebox";
|
|
11
|
+
import { JWTVerifyOptions } from "jose/jwt/verify";
|
|
9
12
|
|
|
10
|
-
//#region src/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
roles?: string[];
|
|
23
|
-
/**
|
|
24
|
-
* User full name, if available.
|
|
25
|
-
*/
|
|
26
|
-
name?: string;
|
|
27
|
-
/**
|
|
28
|
-
* User email, if available.
|
|
29
|
-
*/
|
|
30
|
-
email?: string;
|
|
31
|
-
/**
|
|
32
|
-
* User profile picture URL, if available.
|
|
33
|
-
*/
|
|
34
|
-
picture?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Organization ID, if available.
|
|
37
|
-
*/
|
|
38
|
-
organization?: string;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=UserAccountInfo.d.ts.map
|
|
13
|
+
//#region src/schemas/userAccountInfoSchema.d.ts
|
|
14
|
+
declare const userAccountInfoSchema: _sinclair_typebox0.TObject<{
|
|
15
|
+
id: _sinclair_typebox0.TString;
|
|
16
|
+
name: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
17
|
+
email: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
18
|
+
picture: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
19
|
+
organizations: _sinclair_typebox0.TOptional<_sinclair_typebox0.TArray<_sinclair_typebox0.TString>>;
|
|
20
|
+
roles: _sinclair_typebox0.TOptional<_sinclair_typebox0.TArray<_sinclair_typebox0.TString>>;
|
|
21
|
+
}>;
|
|
22
|
+
type UserAccountInfo = Static<typeof userAccountInfoSchema>;
|
|
23
|
+
//# sourceMappingURL=userAccountInfoSchema.d.ts.map
|
|
41
24
|
//#endregion
|
|
42
25
|
//#region src/interfaces/UserAccountToken.d.ts
|
|
43
26
|
interface UserAccountToken extends UserAccountInfo {
|
|
@@ -55,25 +38,25 @@ interface UserAccountToken extends UserAccountInfo {
|
|
|
55
38
|
//# sourceMappingURL=UserAccountToken.d.ts.map
|
|
56
39
|
//#endregion
|
|
57
40
|
//#region src/schemas/permissionSchema.d.ts
|
|
58
|
-
declare const permissionSchema:
|
|
59
|
-
name:
|
|
60
|
-
group:
|
|
61
|
-
description:
|
|
62
|
-
method:
|
|
63
|
-
path:
|
|
41
|
+
declare const permissionSchema: _sinclair_typebox13.TObject<{
|
|
42
|
+
name: _sinclair_typebox13.TString;
|
|
43
|
+
group: _sinclair_typebox13.TOptional<_sinclair_typebox13.TString>;
|
|
44
|
+
description: _sinclair_typebox13.TOptional<_sinclair_typebox13.TString>;
|
|
45
|
+
method: _sinclair_typebox13.TOptional<_sinclair_typebox13.TString>;
|
|
46
|
+
path: _sinclair_typebox13.TOptional<_sinclair_typebox13.TString>;
|
|
64
47
|
}>;
|
|
65
48
|
type Permission = Static<typeof permissionSchema>;
|
|
66
49
|
//# sourceMappingURL=permissionSchema.d.ts.map
|
|
67
50
|
//#endregion
|
|
68
51
|
//#region src/schemas/roleSchema.d.ts
|
|
69
|
-
declare const roleSchema:
|
|
70
|
-
name:
|
|
71
|
-
description:
|
|
72
|
-
default:
|
|
73
|
-
permissions:
|
|
74
|
-
name:
|
|
75
|
-
ownership:
|
|
76
|
-
exclude:
|
|
52
|
+
declare const roleSchema: _sinclair_typebox23.TObject<{
|
|
53
|
+
name: _sinclair_typebox23.TString;
|
|
54
|
+
description: _sinclair_typebox23.TOptional<_sinclair_typebox23.TString>;
|
|
55
|
+
default: _sinclair_typebox23.TOptional<_sinclair_typebox23.TBoolean>;
|
|
56
|
+
permissions: _sinclair_typebox23.TArray<_sinclair_typebox23.TObject<{
|
|
57
|
+
name: _sinclair_typebox23.TString;
|
|
58
|
+
ownership: _sinclair_typebox23.TOptional<_sinclair_typebox23.TBoolean>;
|
|
59
|
+
exclude: _sinclair_typebox23.TOptional<_sinclair_typebox23.TArray<_sinclair_typebox23.TString>>;
|
|
77
60
|
}>>;
|
|
78
61
|
}>;
|
|
79
62
|
type Role = Static<typeof roleSchema>;
|
|
@@ -84,9 +67,10 @@ type Role = Static<typeof roleSchema>;
|
|
|
84
67
|
* Provides utilities for working with JSON Web Tokens (JWT).
|
|
85
68
|
*/
|
|
86
69
|
declare class JwtProvider {
|
|
87
|
-
protected readonly log:
|
|
70
|
+
protected readonly log: _alepha_core2.Logger;
|
|
88
71
|
protected readonly keystore: KeyLoaderHolder[];
|
|
89
72
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
73
|
+
protected readonly encoder: TextEncoder;
|
|
90
74
|
/**
|
|
91
75
|
* Adds a key loader to the embedded keystore.
|
|
92
76
|
*
|
|
@@ -101,30 +85,17 @@ declare class JwtProvider {
|
|
|
101
85
|
*
|
|
102
86
|
* @return A Promise that resolves with the payload object from the token.
|
|
103
87
|
*/
|
|
104
|
-
parse(token: string): Promise<JwtParseResult>;
|
|
88
|
+
parse(token: string, keyName?: string, options?: JWTVerifyOptions): Promise<JwtParseResult>;
|
|
105
89
|
/**
|
|
106
90
|
* Creates a JWT token with the provided payload and secret key.
|
|
107
91
|
*
|
|
108
92
|
* @param payload - The payload to be encoded in the token.
|
|
109
93
|
* It should include the `realm_access` property which contains an array of roles.
|
|
110
94
|
* @param keyName - The name of the key to use when signing the token.
|
|
111
|
-
* @param signOptions - The options to use when signing the token.
|
|
112
95
|
*
|
|
113
96
|
* @returns The signed JWT token.
|
|
114
97
|
*/
|
|
115
98
|
create(payload: ExtendedJWTPayload, keyName?: string, signOptions?: JwtSignOptions): Promise<string>;
|
|
116
|
-
/**
|
|
117
|
-
* Retrieves the options to use when signing a JWT token.
|
|
118
|
-
*
|
|
119
|
-
* @returns The JWT sign options.
|
|
120
|
-
*/
|
|
121
|
-
signOptions(): JwtSignOptions;
|
|
122
|
-
/**
|
|
123
|
-
* Retrieves the first secret key from the keystore.
|
|
124
|
-
*
|
|
125
|
-
* @protected
|
|
126
|
-
*/
|
|
127
|
-
protected getFirstSecretKey(): string | undefined;
|
|
128
99
|
/**
|
|
129
100
|
* Determines if the provided key is a secret key.
|
|
130
101
|
*
|
|
@@ -132,16 +103,6 @@ declare class JwtProvider {
|
|
|
132
103
|
* @protected
|
|
133
104
|
*/
|
|
134
105
|
protected isSecretKey(key: string): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Try to find a realm name or something similar in the token.
|
|
137
|
-
*
|
|
138
|
-
* This is useful when the token is not encrypted and API has multiple realms.
|
|
139
|
-
* Instead of trying to verify the token with all keys, we can try to find the key !
|
|
140
|
-
*
|
|
141
|
-
* @param token
|
|
142
|
-
* @protected
|
|
143
|
-
*/
|
|
144
|
-
protected tryToGetKeyLoaderFromToken(token: string): KeyLoaderHolder | undefined;
|
|
145
106
|
}
|
|
146
107
|
type KeyLoader = (protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput) => Promise<CryptoKey | KeyObject>;
|
|
147
108
|
interface KeyLoaderHolder {
|
|
@@ -150,13 +111,13 @@ interface KeyLoaderHolder {
|
|
|
150
111
|
secretKey?: string;
|
|
151
112
|
}
|
|
152
113
|
interface JwtSignOptions {
|
|
153
|
-
|
|
154
|
-
protectedHeader?: JWTHeaderParameters;
|
|
155
|
-
expiresIn?: number;
|
|
114
|
+
header?: Partial<JWTHeaderParameters>;
|
|
156
115
|
}
|
|
157
116
|
interface ExtendedJWTPayload extends JWTPayload {
|
|
158
117
|
name?: string;
|
|
159
118
|
roles?: string[];
|
|
119
|
+
email?: string;
|
|
120
|
+
organizations?: string[];
|
|
160
121
|
realm_access?: {
|
|
161
122
|
roles: string[];
|
|
162
123
|
};
|
|
@@ -168,8 +129,8 @@ interface JwtParseResult {
|
|
|
168
129
|
//# sourceMappingURL=JwtProvider.d.ts.map
|
|
169
130
|
//#endregion
|
|
170
131
|
//#region src/providers/SecurityProvider.d.ts
|
|
171
|
-
declare const envSchema:
|
|
172
|
-
SECURITY_SECRET_KEY:
|
|
132
|
+
declare const envSchema: _alepha_core3.TObject<{
|
|
133
|
+
SECURITY_SECRET_KEY: _alepha_core3.TString;
|
|
173
134
|
}>;
|
|
174
135
|
declare module "alepha" {
|
|
175
136
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -178,7 +139,7 @@ declare class SecurityProvider {
|
|
|
178
139
|
protected readonly UNKNOWN_USER_NAME = "Unknown User";
|
|
179
140
|
protected readonly PERMISSION_REGEXP: RegExp;
|
|
180
141
|
protected readonly PERMISSION_REGEXP_WILDCARD: RegExp;
|
|
181
|
-
protected readonly log:
|
|
142
|
+
protected readonly log: _alepha_core3.Logger;
|
|
182
143
|
protected readonly jwt: JwtProvider;
|
|
183
144
|
protected readonly env: {
|
|
184
145
|
SECURITY_SECRET_KEY: string;
|
|
@@ -192,8 +153,8 @@ declare class SecurityProvider {
|
|
|
192
153
|
* The realms configured for the security provider.
|
|
193
154
|
*/
|
|
194
155
|
protected readonly realms: Realm[];
|
|
195
|
-
protected configure:
|
|
196
|
-
protected ready:
|
|
156
|
+
protected configure: _alepha_core3.HookDescriptor<"start">;
|
|
157
|
+
protected ready: _alepha_core3.HookDescriptor<"ready">;
|
|
197
158
|
/**
|
|
198
159
|
* Adds a role to one or more realms.
|
|
199
160
|
*
|
|
@@ -225,7 +186,7 @@ declare class SecurityProvider {
|
|
|
225
186
|
*
|
|
226
187
|
* @returns The user info created from the payload.
|
|
227
188
|
*/
|
|
228
|
-
|
|
189
|
+
createUserFromPayload(payload: JWTPayload, realmName?: string): UserAccountInfo;
|
|
229
190
|
/**
|
|
230
191
|
* Checks if the user has the specified permission.
|
|
231
192
|
*
|
|
@@ -241,7 +202,11 @@ declare class SecurityProvider {
|
|
|
241
202
|
* @param headerOrToken
|
|
242
203
|
* @param permissionLike
|
|
243
204
|
*/
|
|
244
|
-
createUserFromToken(headerOrToken?: string,
|
|
205
|
+
createUserFromToken(headerOrToken?: string, options?: {
|
|
206
|
+
permission?: Permission | string;
|
|
207
|
+
realm?: string;
|
|
208
|
+
verify?: JWTVerifyOptions;
|
|
209
|
+
}): Promise<UserAccountToken>;
|
|
245
210
|
/**
|
|
246
211
|
* Checks if a user has a specific role.
|
|
247
212
|
*
|
|
@@ -300,7 +265,7 @@ declare class SecurityProvider {
|
|
|
300
265
|
* @returns The name extracted from the payload, or an empty string if the payload is falsy or no name is found.
|
|
301
266
|
*/
|
|
302
267
|
getNameFromPayload(payload: Record<string, any>): string;
|
|
303
|
-
|
|
268
|
+
getOrganizationsFromPayload(payload: Record<string, any>): string[] | undefined;
|
|
304
269
|
}
|
|
305
270
|
/**
|
|
306
271
|
* A realm definition.
|
|
@@ -313,7 +278,7 @@ interface Realm {
|
|
|
313
278
|
*
|
|
314
279
|
* Can be also a JWKS URL.
|
|
315
280
|
*/
|
|
316
|
-
secret?: string | JSONWebKeySet;
|
|
281
|
+
secret?: string | JSONWebKeySet | (() => string);
|
|
317
282
|
/**
|
|
318
283
|
* Attach a user provider to the realm.
|
|
319
284
|
*
|
|
@@ -321,6 +286,10 @@ interface Realm {
|
|
|
321
286
|
*/
|
|
322
287
|
userAccountProvider?: SecurityUserAccountProvider;
|
|
323
288
|
onLoadUser?: (user: UserAccountInfo) => Promise<void> | void;
|
|
289
|
+
/**
|
|
290
|
+
* Function to create a user profile from the raw JWT user data.
|
|
291
|
+
*/
|
|
292
|
+
profile?: (raw: Record<string, any>) => UserAccountInfo;
|
|
324
293
|
}
|
|
325
294
|
interface SecurityUserAccountProvider {
|
|
326
295
|
jwks: string | undefined;
|
|
@@ -376,41 +345,79 @@ declare class PermissionDescriptor extends Descriptor<PermissionDescriptorOption
|
|
|
376
345
|
* Create a new realm.
|
|
377
346
|
*/
|
|
378
347
|
declare const $realm: {
|
|
379
|
-
(options
|
|
348
|
+
(options: RealmDescriptorOptions): RealmDescriptor;
|
|
380
349
|
[KIND]: typeof RealmDescriptor;
|
|
381
350
|
};
|
|
382
|
-
|
|
351
|
+
type RealmDescriptorOptions = {
|
|
383
352
|
/**
|
|
384
353
|
* Define the realm name.
|
|
385
|
-
*
|
|
386
|
-
* @default key name
|
|
354
|
+
* If not provided, it will use the property key.
|
|
387
355
|
*/
|
|
388
356
|
name?: string;
|
|
389
357
|
/**
|
|
390
|
-
*
|
|
358
|
+
* Short description about the realm.
|
|
391
359
|
*/
|
|
392
360
|
description?: string;
|
|
393
361
|
/**
|
|
394
362
|
* All roles available in the realm. Role is a string (role name) or a Role object (embedded role).
|
|
395
363
|
*/
|
|
396
364
|
roles?: Array<string | Role>;
|
|
365
|
+
settings?: RealmSettings;
|
|
366
|
+
/**
|
|
367
|
+
* Parse the JWT payload to create a user account info.
|
|
368
|
+
*/
|
|
369
|
+
profile?: (jwtPayload: Record<string, any>) => UserAccountInfo;
|
|
370
|
+
} & (RealmInternal | RealmExternal);
|
|
371
|
+
interface RealmSettings {
|
|
372
|
+
accessToken?: {
|
|
373
|
+
/**
|
|
374
|
+
* Lifetime of the access token.
|
|
375
|
+
* @default 15 minutes
|
|
376
|
+
*/
|
|
377
|
+
expiration?: DurationLike;
|
|
378
|
+
};
|
|
379
|
+
refreshToken?: {
|
|
380
|
+
/**
|
|
381
|
+
* Lifetime of the refresh token.
|
|
382
|
+
* @default 30 days
|
|
383
|
+
*/
|
|
384
|
+
expiration?: DurationLike;
|
|
385
|
+
/**
|
|
386
|
+
* If true, no refresh token will be created.
|
|
387
|
+
*/
|
|
388
|
+
disabled?: boolean;
|
|
389
|
+
create?: (user: UserAccountInfo, refreshToken?: string) => Promise<{
|
|
390
|
+
refresh_token: string;
|
|
391
|
+
expires_in: number;
|
|
392
|
+
}>;
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
type RealmInternal = {
|
|
397
396
|
/**
|
|
398
|
-
*
|
|
399
|
-
* Can be a string based secret or a JWKS URL.
|
|
400
|
-
*
|
|
401
|
-
* Note: You can skip this if you are using a user account provider with JWKS.
|
|
397
|
+
* Internal secret to sign JWT tokens and verify them.
|
|
402
398
|
*/
|
|
403
|
-
secret
|
|
399
|
+
secret: string;
|
|
400
|
+
};
|
|
401
|
+
interface RealmExternal {
|
|
402
|
+
/**
|
|
403
|
+
* URL to the JWKS (JSON Web Key Set) to verify JWT tokens from external providers.
|
|
404
|
+
*/
|
|
405
|
+
jwks: (() => string) | JSONWebKeySet;
|
|
404
406
|
/**
|
|
405
407
|
* Attach a user account provider to the realm to manage roles.
|
|
406
|
-
*
|
|
408
|
+
*
|
|
409
|
+
* For example, you can use a KeycloakUserProvider to automatically create/update realm roles inside Keycloak.
|
|
407
410
|
*/
|
|
408
411
|
userAccountProvider?: SecurityUserAccountProvider | (() => SecurityUserAccountProvider);
|
|
409
412
|
}
|
|
410
413
|
declare class RealmDescriptor extends Descriptor<RealmDescriptorOptions> {
|
|
411
414
|
protected readonly securityProvider: SecurityProvider;
|
|
415
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
412
416
|
protected readonly jwt: JwtProvider;
|
|
417
|
+
protected readonly log: _alepha_core1.Logger;
|
|
413
418
|
get name(): string;
|
|
419
|
+
get accessTokenExpiration(): Duration;
|
|
420
|
+
get refreshTokenExpiration(): Duration;
|
|
414
421
|
protected onInit(): void;
|
|
415
422
|
/**
|
|
416
423
|
* Get all roles in the realm.
|
|
@@ -424,10 +431,25 @@ declare class RealmDescriptor extends Descriptor<RealmDescriptorOptions> {
|
|
|
424
431
|
* Get a role by name, throws an error if not found.
|
|
425
432
|
*/
|
|
426
433
|
getRoleByName(name: string): Role;
|
|
434
|
+
parseToken(token: string): Promise<JWTPayload>;
|
|
427
435
|
/**
|
|
428
436
|
* Create a token for the subject.
|
|
429
437
|
*/
|
|
430
|
-
createToken(
|
|
438
|
+
createToken(user: UserAccountInfo, refreshToken?: string): Promise<AccessTokenResponse>;
|
|
439
|
+
}
|
|
440
|
+
interface CreateTokenOptions {
|
|
441
|
+
sub: string;
|
|
442
|
+
roles?: string[];
|
|
443
|
+
email?: string;
|
|
444
|
+
}
|
|
445
|
+
interface AccessTokenResponse {
|
|
446
|
+
access_token: string;
|
|
447
|
+
token_type: string;
|
|
448
|
+
expires_in?: number;
|
|
449
|
+
issued_at: number;
|
|
450
|
+
refresh_token?: string;
|
|
451
|
+
refresh_token_expires_in?: number;
|
|
452
|
+
scope?: string;
|
|
431
453
|
}
|
|
432
454
|
//# sourceMappingURL=$realm.d.ts.map
|
|
433
455
|
//#endregion
|
|
@@ -500,13 +522,9 @@ type ServiceAccountDescriptorOptions = {
|
|
|
500
522
|
} & ({
|
|
501
523
|
oauth2: Oauth2ServiceAccountDescriptorOptions;
|
|
502
524
|
} | {
|
|
503
|
-
|
|
525
|
+
realm: RealmDescriptor;
|
|
526
|
+
user: UserAccountInfo;
|
|
504
527
|
});
|
|
505
|
-
interface JwtServiceAccountDescriptorOptions {
|
|
506
|
-
secret: string;
|
|
507
|
-
roles?: string[];
|
|
508
|
-
signOptions?: JwtSignOptions;
|
|
509
|
-
}
|
|
510
528
|
interface Oauth2ServiceAccountDescriptorOptions {
|
|
511
529
|
/**
|
|
512
530
|
* Get Token URL.
|
|
@@ -524,11 +542,6 @@ interface Oauth2ServiceAccountDescriptorOptions {
|
|
|
524
542
|
interface ServiceAccountDescriptor {
|
|
525
543
|
token: () => Promise<string>;
|
|
526
544
|
}
|
|
527
|
-
interface AccessTokenResponse {
|
|
528
|
-
access_token: string;
|
|
529
|
-
expires_in: number;
|
|
530
|
-
at: number;
|
|
531
|
-
}
|
|
532
545
|
interface ServiceAccountStore {
|
|
533
546
|
response?: AccessTokenResponse;
|
|
534
547
|
}
|
|
@@ -542,10 +555,17 @@ declare class InvalidPermissionError extends Error {
|
|
|
542
555
|
//#endregion
|
|
543
556
|
//#region src/errors/SecurityError.d.ts
|
|
544
557
|
declare class SecurityError extends Error {
|
|
558
|
+
name: string;
|
|
545
559
|
readonly status = 403;
|
|
546
|
-
readonly code = "ERR_SECURITY";
|
|
547
560
|
}
|
|
548
561
|
//# sourceMappingURL=SecurityError.d.ts.map
|
|
562
|
+
//#endregion
|
|
563
|
+
//#region src/providers/CryptoProvider.d.ts
|
|
564
|
+
declare class CryptoProvider {
|
|
565
|
+
hashPassword(password: string): Promise<string>;
|
|
566
|
+
verifyPassword(password: string, stored: string): Promise<boolean>;
|
|
567
|
+
}
|
|
568
|
+
//# sourceMappingURL=CryptoProvider.d.ts.map
|
|
549
569
|
|
|
550
570
|
//#endregion
|
|
551
571
|
//#region src/index.d.ts
|
|
@@ -569,9 +589,9 @@ declare module "alepha" {
|
|
|
569
589
|
* @see {@link $permission}
|
|
570
590
|
* @module alepha.security
|
|
571
591
|
*/
|
|
572
|
-
declare const AlephaSecurity: _alepha_core0.
|
|
592
|
+
declare const AlephaSecurity: _alepha_core0.Service<_alepha_core0.Module>;
|
|
573
593
|
//# sourceMappingURL=index.d.ts.map
|
|
574
594
|
|
|
575
595
|
//#endregion
|
|
576
|
-
export { $permission, $realm, $role, $serviceAccount, AccessTokenResponse, AlephaSecurity, ExtendedJWTPayload, InvalidPermissionError, JwtParseResult, JwtProvider,
|
|
596
|
+
export { $permission, $realm, $role, $serviceAccount, AccessTokenResponse, AlephaSecurity, CreateTokenOptions, CryptoProvider, ExtendedJWTPayload, InvalidPermissionError, JwtParseResult, JwtProvider, JwtSignOptions, KeyLoader, KeyLoaderHolder, Oauth2ServiceAccountDescriptorOptions, Permission, PermissionDescriptor, PermissionDescriptorOptions, Realm, RealmConfig, RealmDescriptor, RealmDescriptorOptions, RealmExternal, RealmInternal, RealmSettings, Role, RoleDescriptor, RoleDescriptorOptions, SecurityCheckResult, SecurityError, SecurityProvider, SecurityUserAccountProvider, ServiceAccountDescriptor, ServiceAccountDescriptorOptions, ServiceAccountStore, UserAccountInfo, UserAccountToken, permissionSchema, roleSchema, userAccountInfoSchema };
|
|
577
597
|
//# sourceMappingURL=index.d.ts.map
|
package/server/cache.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _alepha_cache0 from "alepha/cache";
|
|
2
2
|
import { CacheDescriptorOptions } from "alepha/cache";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alepha_core1 from "alepha";
|
|
4
4
|
import * as _alepha_core0 from "alepha";
|
|
5
5
|
import { Alepha } from "alepha";
|
|
6
6
|
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
@@ -16,26 +16,28 @@ declare module "alepha/server" {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
declare class ServerCacheProvider {
|
|
19
|
-
protected readonly log:
|
|
19
|
+
protected readonly log: _alepha_core1.Logger;
|
|
20
20
|
protected readonly alepha: Alepha;
|
|
21
21
|
protected readonly time: DateTimeProvider;
|
|
22
22
|
protected readonly cache: _alepha_cache0.CacheDescriptorFn<RouteCacheEntry, any[]>;
|
|
23
23
|
generateETag(content: string): string;
|
|
24
24
|
invalidate(route: ServerRoute): Promise<void>;
|
|
25
|
-
protected readonly
|
|
26
|
-
protected readonly
|
|
25
|
+
protected readonly onActionRequest: _alepha_core1.HookDescriptor<"action:onRequest">;
|
|
26
|
+
protected readonly onActionResponse: _alepha_core1.HookDescriptor<"action:onResponse">;
|
|
27
|
+
protected readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
28
|
+
protected readonly onResponse: _alepha_core1.HookDescriptor<"server:onResponse">;
|
|
27
29
|
protected getCacheOptions(cache: ServerRouteCache): {
|
|
28
|
-
provider?: (
|
|
30
|
+
provider?: (_alepha_core1.InstantiableClass<_alepha_cache0.CacheProvider> | "memory") | undefined;
|
|
29
31
|
name?: string | undefined;
|
|
30
32
|
ttl?: DurationLike | undefined;
|
|
31
33
|
disabled?: boolean | undefined;
|
|
32
34
|
};
|
|
33
|
-
protected createCacheKey(route: ServerRoute,
|
|
35
|
+
protected createCacheKey(route: ServerRoute, config?: ServerRequest): string;
|
|
34
36
|
}
|
|
35
37
|
type ServerRouteCache = boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
|
|
36
38
|
interface RouteCacheEntry {
|
|
37
39
|
contentType?: string;
|
|
38
|
-
body:
|
|
40
|
+
body: any;
|
|
39
41
|
status?: number;
|
|
40
42
|
lastModified: string;
|
|
41
43
|
hash: string;
|
|
@@ -70,7 +72,7 @@ interface RouteCacheEntry {
|
|
|
70
72
|
* @see {@link ServerCacheProvider}
|
|
71
73
|
* @module alepha.server.cache
|
|
72
74
|
*/
|
|
73
|
-
declare const AlephaServerCache: _alepha_core0.
|
|
75
|
+
declare const AlephaServerCache: _alepha_core0.Service<_alepha_core0.Module>;
|
|
74
76
|
//# sourceMappingURL=index.d.ts.map
|
|
75
77
|
|
|
76
78
|
//#endregion
|
package/server/compress.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ interface ServerCompressProviderOptions {
|
|
|
27
27
|
*
|
|
28
28
|
* Compresses responses using gzip, brotli, or zstd based on the `Accept-Encoding` header.
|
|
29
29
|
*/
|
|
30
|
-
declare const AlephaServerCompress: _alepha_core0.
|
|
30
|
+
declare const AlephaServerCompress: _alepha_core0.Service<_alepha_core0.Module>;
|
|
31
31
|
//# sourceMappingURL=index.d.ts.map
|
|
32
32
|
|
|
33
33
|
//#endregion
|
package/server/cookies.d.ts
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alepha_core1 from "alepha";
|
|
2
2
|
import * as _alepha_core0 from "alepha";
|
|
3
3
|
import { Alepha, Descriptor, KIND, Static, TSchema } from "alepha";
|
|
4
4
|
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
5
5
|
|
|
6
|
+
//#region src/services/CookieParser.d.ts
|
|
7
|
+
declare class CookieParser {
|
|
8
|
+
parseRequestCookies(header: string): Record<string, string>;
|
|
9
|
+
serializeResponseCookies(cookies: Record<string, Cookie | null>, isHttps: boolean): string[];
|
|
10
|
+
cookieToString(name: string, cookie: Cookie, isHttps?: boolean): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=CookieParser.d.ts.map
|
|
13
|
+
//#endregion
|
|
6
14
|
//#region src/providers/ServerCookiesProvider.d.ts
|
|
7
|
-
declare const envSchema:
|
|
15
|
+
declare const envSchema: _alepha_core1.TObject<{
|
|
8
16
|
/**
|
|
9
17
|
* A 32-byte secret key used for cookie encryption and signing. MUST be set for `encrypt` or `sign` to work.
|
|
10
18
|
*/
|
|
11
|
-
COOKIE_SECRET:
|
|
19
|
+
COOKIE_SECRET: _alepha_core1.TOptional<_alepha_core1.TString>;
|
|
12
20
|
}>;
|
|
13
21
|
declare module "alepha" {
|
|
14
22
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
15
23
|
}
|
|
16
24
|
declare class ServerCookiesProvider {
|
|
17
25
|
protected readonly alepha: Alepha;
|
|
18
|
-
protected readonly log:
|
|
26
|
+
protected readonly log: _alepha_core1.Logger;
|
|
19
27
|
protected readonly env: {
|
|
20
28
|
COOKIE_SECRET?: string | undefined;
|
|
21
29
|
};
|
|
30
|
+
protected readonly cookieParser: CookieParser;
|
|
22
31
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
23
32
|
protected readonly ALGORITHM = "aes-256-gcm";
|
|
24
33
|
protected readonly IV_LENGTH = 16;
|
|
25
34
|
protected readonly AUTH_TAG_LENGTH = 16;
|
|
26
35
|
protected readonly SIGNATURE_LENGTH = 32;
|
|
27
|
-
readonly onRequest:
|
|
28
|
-
readonly onSend:
|
|
36
|
+
readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
37
|
+
readonly onSend: _alepha_core1.HookDescriptor<"server:onSend">;
|
|
29
38
|
protected getCookiesFromContext(cookies?: Cookies): Cookies;
|
|
30
39
|
getCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, contextCookies?: Cookies): Static<T> | undefined;
|
|
31
40
|
setCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, data: Static<T>, contextCookies?: Cookies): void;
|
|
@@ -34,8 +43,6 @@ declare class ServerCookiesProvider {
|
|
|
34
43
|
protected decrypt(encryptedText: string): string;
|
|
35
44
|
secretKey(): string;
|
|
36
45
|
protected sign(data: string): string;
|
|
37
|
-
protected parseRequestCookies(header: string): Record<string, string>;
|
|
38
|
-
protected serializeResponseCookies(cookies: Record<string, Cookie | null>, isHttps: boolean): string[];
|
|
39
46
|
}
|
|
40
47
|
//#endregion
|
|
41
48
|
//#region src/descriptors/$cookie.d.ts
|
|
@@ -45,7 +52,7 @@ declare class ServerCookiesProvider {
|
|
|
45
52
|
* within the server request/response cycle.
|
|
46
53
|
*/
|
|
47
54
|
declare const $cookie: {
|
|
48
|
-
<T extends TSchema>(options: CookieDescriptorOptions<T>):
|
|
55
|
+
<T extends TSchema>(options: CookieDescriptorOptions<T>): AbstractCookieDescriptor<T>;
|
|
49
56
|
[KIND]: typeof CookieDescriptor;
|
|
50
57
|
};
|
|
51
58
|
interface CookieDescriptorOptions<T extends TSchema> {
|
|
@@ -72,18 +79,40 @@ interface CookieDescriptorOptions<T extends TSchema> {
|
|
|
72
79
|
/** If true, the cookie will be signed to prevent tampering. Requires `COOKIE_SECRET` env var. */
|
|
73
80
|
sign?: boolean;
|
|
74
81
|
}
|
|
75
|
-
|
|
82
|
+
interface AbstractCookieDescriptor<T extends TSchema> {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly options: CookieDescriptorOptions<T>;
|
|
85
|
+
set(value: Static<T>, options?: {
|
|
86
|
+
cookies?: Cookies;
|
|
87
|
+
ttl?: DurationLike;
|
|
88
|
+
}): void;
|
|
89
|
+
get(options?: {
|
|
90
|
+
cookies?: Cookies;
|
|
91
|
+
}): Static<T> | undefined;
|
|
92
|
+
del(options?: {
|
|
93
|
+
cookies?: Cookies;
|
|
94
|
+
}): void;
|
|
95
|
+
}
|
|
96
|
+
declare class CookieDescriptor<T extends TSchema> extends Descriptor<CookieDescriptorOptions<T>> implements AbstractCookieDescriptor<T> {
|
|
76
97
|
protected readonly serverCookiesProvider: ServerCookiesProvider;
|
|
98
|
+
get schema(): T;
|
|
77
99
|
get name(): string;
|
|
78
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Sets the cookie with the given value in the current request's response.
|
|
102
|
+
*/
|
|
79
103
|
set(value: Static<T>, options?: {
|
|
80
104
|
cookies?: Cookies;
|
|
105
|
+
ttl?: DurationLike;
|
|
81
106
|
}): void;
|
|
82
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Gets the cookie value from the current request. Returns undefined if not found or invalid.
|
|
109
|
+
*/
|
|
83
110
|
get(options?: {
|
|
84
111
|
cookies?: Cookies;
|
|
85
112
|
}): Static<T> | undefined;
|
|
86
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Deletes the cookie in the current request's response.
|
|
115
|
+
*/
|
|
87
116
|
del(options?: {
|
|
88
117
|
cookies?: Cookies;
|
|
89
118
|
}): void;
|
|
@@ -119,9 +148,9 @@ declare module "alepha/server" {
|
|
|
119
148
|
* @see {@link $cookie}
|
|
120
149
|
* @module alepha.server.cookies
|
|
121
150
|
*/
|
|
122
|
-
declare const AlephaServerCookies: _alepha_core0.
|
|
151
|
+
declare const AlephaServerCookies: _alepha_core0.Service<_alepha_core0.Module>;
|
|
123
152
|
//# sourceMappingURL=index.d.ts.map
|
|
124
153
|
|
|
125
154
|
//#endregion
|
|
126
|
-
export { $cookie, AlephaServerCookies, Cookie, CookieDescriptor, CookieDescriptorOptions, Cookies, ServerCookiesProvider };
|
|
155
|
+
export { $cookie, AbstractCookieDescriptor, AlephaServerCookies, Cookie, CookieDescriptor, CookieDescriptorOptions, Cookies, ServerCookiesProvider };
|
|
127
156
|
//# sourceMappingURL=index.d.ts.map
|
package/server/cors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alepha_core1 from "alepha";
|
|
2
2
|
import * as _alepha_core0 from "alepha";
|
|
3
3
|
import { ServerRouterProvider } from "alepha/server";
|
|
4
4
|
|
|
@@ -6,8 +6,8 @@ import { ServerRouterProvider } from "alepha/server";
|
|
|
6
6
|
declare class ServerCorsProvider {
|
|
7
7
|
protected readonly serverRouterProvider: ServerRouterProvider;
|
|
8
8
|
options: ServerCorsProviderOptions;
|
|
9
|
-
protected readonly configure:
|
|
10
|
-
protected readonly onRequest:
|
|
9
|
+
protected readonly configure: _alepha_core1.HookDescriptor<"configure">;
|
|
10
|
+
protected readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
11
11
|
isOriginAllowed(origin: string | undefined, allowed: ServerCorsProviderOptions["origin"]): boolean;
|
|
12
12
|
}
|
|
13
13
|
interface ServerCorsProviderOptions {
|
|
@@ -23,7 +23,7 @@ interface ServerCorsProviderOptions {
|
|
|
23
23
|
/**
|
|
24
24
|
* Plugin for configuring CORS on the Alepha server.
|
|
25
25
|
*/
|
|
26
|
-
declare const AlephaServerCors: _alepha_core0.
|
|
26
|
+
declare const AlephaServerCors: _alepha_core0.Service<_alepha_core0.Module>;
|
|
27
27
|
//# sourceMappingURL=index.d.ts.map
|
|
28
28
|
|
|
29
29
|
//#endregion
|
package/server/health.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ declare class ServerHealthProvider {
|
|
|
31
31
|
* @see {@link ServerHealthProvider}
|
|
32
32
|
* @module alepha.server.health
|
|
33
33
|
*/
|
|
34
|
-
declare const AlephaServerHealth: _alepha_core0.
|
|
34
|
+
declare const AlephaServerHealth: _alepha_core0.Service<_alepha_core0.Module>;
|
|
35
35
|
//# sourceMappingURL=index.d.ts.map
|
|
36
36
|
|
|
37
37
|
//#endregion
|
package/server/helmet.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ declare class ServerHelmetProvider {
|
|
|
61
61
|
* @see {@link ServerHelmetProvider}
|
|
62
62
|
* @module alepha.server.helmet
|
|
63
63
|
*/
|
|
64
|
-
declare const AlephaServerHelmet: _alepha_core0.
|
|
64
|
+
declare const AlephaServerHelmet: _alepha_core0.Service<_alepha_core0.Module>;
|
|
65
65
|
//# sourceMappingURL=index.d.ts.map
|
|
66
66
|
|
|
67
67
|
//#endregion
|