alepha 0.7.4 → 0.7.6
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/LICENSE +21 -21
- package/README.md +44 -21
- package/cache/redis.cjs +4 -8
- package/cache/redis.d.ts +30 -91
- package/cache/redis.js +1 -1
- package/cache.cjs +4 -8
- package/cache.d.ts +190 -259
- package/cache.js +1 -1
- package/core.cjs +4 -8
- package/core.d.ts +950 -925
- package/core.js +1 -1
- package/datetime.cjs +4 -8
- package/datetime.d.ts +151 -140
- package/datetime.js +1 -1
- package/lock/redis.cjs +7 -49
- package/lock/redis.d.ts +17 -14
- package/lock/redis.js +1 -47
- package/lock.cjs +4 -8
- package/lock.d.ts +117 -170
- package/lock.js +1 -1
- package/package.json +70 -40
- package/postgres.cjs +4 -8
- package/postgres.d.ts +1314 -4400
- package/postgres.js +1 -1
- package/queue/redis.cjs +8 -0
- package/queue/redis.d.ts +31 -0
- package/queue/redis.js +1 -0
- package/queue.cjs +4 -8
- package/queue.d.ts +162 -205
- package/queue.js +1 -1
- package/react/auth.cjs +4 -8
- package/react/auth.d.ts +167 -280
- package/react/auth.js +1 -1
- package/react.cjs +4 -8
- package/react.d.ts +530 -570
- package/react.js +1 -1
- package/redis.cjs +4 -8
- package/redis.d.ts +59 -132
- package/redis.js +1 -1
- package/retry.cjs +4 -8
- package/retry.d.ts +34 -31
- package/retry.js +1 -1
- package/scheduler.cjs +4 -8
- package/scheduler.d.ts +128 -155
- package/scheduler.js +1 -1
- package/security.cjs +4 -8
- package/security.d.ts +472 -595
- package/security.js +1 -1
- package/server/cache.cjs +4 -8
- package/server/cache.d.ts +73 -39
- package/server/cache.js +1 -1
- package/server/cookies.cjs +4 -8
- package/server/cookies.d.ts +46 -41
- package/server/cookies.js +1 -1
- package/server/static.cjs +4 -8
- package/server/static.d.ts +98 -95
- package/server/static.js +1 -1
- package/server/swagger.cjs +4 -8
- package/server/swagger.d.ts +106 -92
- package/server/swagger.js +1 -1
- package/server.cjs +4 -8
- package/server.d.ts +754 -1025
- package/server.js +1 -1
- package/testing.cjs +8 -0
- package/testing.d.ts +1 -0
- package/testing.js +1 -0
- package/topic/redis.cjs +8 -0
- package/topic/redis.d.ts +45 -0
- package/topic/redis.js +1 -0
- package/topic.cjs +4 -8
- package/topic.d.ts +171 -163
- package/topic.js +1 -1
- package/vite.cjs +4 -8
- package/vite.d.ts +91 -84
- package/vite.js +1 -1
- package/assets/logo.png +0 -0
- package/src/cache/redis.ts +0 -1
- package/src/cache.ts +0 -1
- package/src/core.ts +0 -1
- package/src/datetime.ts +0 -1
- package/src/lock/redis.ts +0 -1
- package/src/lock.ts +0 -1
- package/src/postgres.ts +0 -1
- package/src/queue/redis.ts +0 -1
- package/src/queue.ts +0 -1
- package/src/react/auth.ts +0 -1
- package/src/react.ts +0 -1
- package/src/redis.ts +0 -1
- package/src/retry.ts +0 -1
- package/src/scheduler.ts +0 -1
- package/src/security.ts +0 -1
- package/src/server/cache.ts +0 -1
- package/src/server/cookies.ts +0 -1
- package/src/server/static.ts +0 -1
- package/src/server/swagger.ts +0 -1
- package/src/server.ts +0 -1
- package/src/topic/redis.ts +0 -1
- package/src/topic.ts +0 -1
- package/src/vite.ts +0 -1
package/security.d.ts
CHANGED
|
@@ -1,618 +1,491 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { DateTimeProvider } from
|
|
1
|
+
import * as _alepha_core7 from "@alepha/core";
|
|
2
|
+
import * as _alepha_core2 from "@alepha/core";
|
|
3
|
+
import { Alepha, KIND, OPTIONS, Static } from "@alepha/core";
|
|
4
|
+
import { DateTimeProvider } from "@alepha/datetime";
|
|
5
|
+
import { CryptoKey, FlattenedJWSInput, JSONWebKeySet, JWSHeaderParameters, JWTHeaderParameters, JWTPayload, JWTVerifyResult, KeyObject } from "jose";
|
|
6
|
+
import * as _sinclair_typebox8 from "@sinclair/typebox";
|
|
7
|
+
import * as _sinclair_typebox20 from "@sinclair/typebox";
|
|
8
|
+
import * as _sinclair_typebox1 from "@sinclair/typebox";
|
|
5
9
|
|
|
10
|
+
//#region src/interfaces/UserAccountInfo.d.ts
|
|
6
11
|
/**
|
|
7
12
|
* Represents a User Account extracted from JWT.
|
|
8
13
|
*/
|
|
9
14
|
interface UserAccountInfo {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
declare const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
type TReadonly<T extends TSchema> = T & {
|
|
46
|
-
[ReadonlyKind]: 'Readonly';
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
|
|
50
|
-
type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
|
|
51
|
-
interface StringOptions extends SchemaOptions {
|
|
52
|
-
/** The maximum string length */
|
|
53
|
-
maxLength?: number;
|
|
54
|
-
/** The minimum string length */
|
|
55
|
-
minLength?: number;
|
|
56
|
-
/** A regular expression pattern this string should match */
|
|
57
|
-
pattern?: string;
|
|
58
|
-
/** A format this string should match */
|
|
59
|
-
format?: StringFormatOption;
|
|
60
|
-
/** The content encoding for this string */
|
|
61
|
-
contentEncoding?: StringContentEncodingOption;
|
|
62
|
-
/** The content media type for this string */
|
|
63
|
-
contentMediaType?: string;
|
|
64
|
-
}
|
|
65
|
-
interface TString extends TSchema, StringOptions {
|
|
66
|
-
[Kind]: 'String';
|
|
67
|
-
static: string;
|
|
68
|
-
type: 'string';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface TBoolean extends TSchema {
|
|
72
|
-
[Kind]: 'Boolean';
|
|
73
|
-
static: boolean;
|
|
74
|
-
type: 'boolean';
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
type TOptional<T extends TSchema> = T & {
|
|
78
|
-
[OptionalKind]: 'Optional';
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/** Creates a static type from a TypeBox type */
|
|
82
|
-
type Static<Type extends TSchema, Params extends unknown[] = [], Result = (Type & {
|
|
83
|
-
params: Params;
|
|
84
|
-
})['static']> = Result;
|
|
85
|
-
|
|
86
|
-
type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
|
|
87
|
-
[K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? K : never) : never;
|
|
88
|
-
}[keyof T];
|
|
89
|
-
type ReadonlyPropertyKeys<T extends TProperties> = {
|
|
90
|
-
[K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? never : K) : never;
|
|
91
|
-
}[keyof T];
|
|
92
|
-
type OptionalPropertyKeys<T extends TProperties> = {
|
|
93
|
-
[K in keyof T]: T[K] extends TOptional<TSchema> ? (T[K] extends TReadonly<T[K]> ? never : K) : never;
|
|
94
|
-
}[keyof T];
|
|
95
|
-
type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
|
|
96
|
-
type ObjectStaticProperties<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
|
|
97
|
-
type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProperties<T, {
|
|
98
|
-
[K in keyof T]: Static<T[K], P>;
|
|
15
|
+
/**
|
|
16
|
+
* ID of user account. Based on JWT.sub.
|
|
17
|
+
*/
|
|
18
|
+
id: string;
|
|
19
|
+
/**
|
|
20
|
+
* Represents the roles assigned to a user.
|
|
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
|
+
//#endregion
|
|
41
|
+
//#region src/schemas/permissionSchema.d.ts
|
|
42
|
+
declare const permissionSchema: _sinclair_typebox8.TObject<{
|
|
43
|
+
name: _sinclair_typebox8.TString;
|
|
44
|
+
group: _sinclair_typebox8.TOptional<_sinclair_typebox8.TString>;
|
|
45
|
+
description: _sinclair_typebox8.TOptional<_sinclair_typebox8.TString>;
|
|
46
|
+
method: _sinclair_typebox8.TOptional<_sinclair_typebox8.TString>;
|
|
47
|
+
path: _sinclair_typebox8.TOptional<_sinclair_typebox8.TString>;
|
|
48
|
+
contentType: _sinclair_typebox8.TOptional<_sinclair_typebox8.TString>;
|
|
99
49
|
}>;
|
|
100
|
-
type
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
interface ObjectOptions extends SchemaOptions {
|
|
104
|
-
/** Additional property constraints for this object */
|
|
105
|
-
additionalProperties?: TAdditionalProperties;
|
|
106
|
-
/** The minimum number of properties allowed on this object */
|
|
107
|
-
minProperties?: number;
|
|
108
|
-
/** The maximum number of properties allowed on this object */
|
|
109
|
-
maxProperties?: number;
|
|
110
|
-
}
|
|
111
|
-
interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
|
|
112
|
-
[Kind]: 'Object';
|
|
113
|
-
static: ObjectStatic<T, this['params']>;
|
|
114
|
-
additionalProperties?: TAdditionalProperties;
|
|
115
|
-
type: 'object';
|
|
116
|
-
properties: T;
|
|
117
|
-
required?: string[];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
type Evaluate<T> = T extends infer O ? {
|
|
121
|
-
[K in keyof O]: O[K];
|
|
122
|
-
} : never;
|
|
123
|
-
type Ensure<T> = T extends infer U ? U : never;
|
|
124
|
-
|
|
125
|
-
interface ArrayOptions extends SchemaOptions {
|
|
126
|
-
/** The minimum number of items in this array */
|
|
127
|
-
minItems?: number;
|
|
128
|
-
/** The maximum number of items in this array */
|
|
129
|
-
maxItems?: number;
|
|
130
|
-
/** Should this schema contain unique items */
|
|
131
|
-
uniqueItems?: boolean;
|
|
132
|
-
/** A schema for which some elements should match */
|
|
133
|
-
contains?: TSchema;
|
|
134
|
-
/** A minimum number of contains schema matches */
|
|
135
|
-
minContains?: number;
|
|
136
|
-
/** A maximum number of contains schema matches */
|
|
137
|
-
maxContains?: number;
|
|
138
|
-
}
|
|
139
|
-
type ArrayStatic<T extends TSchema, P extends unknown[]> = Ensure<Static<T, P>[]>;
|
|
140
|
-
interface TArray<T extends TSchema = TSchema> extends TSchema, ArrayOptions {
|
|
141
|
-
[Kind]: 'Array';
|
|
142
|
-
static: ArrayStatic<T, this['params']>;
|
|
143
|
-
type: 'array';
|
|
144
|
-
items: T;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
interface SchemaOptions {
|
|
148
|
-
$schema?: string;
|
|
149
|
-
/** Id for this schema */
|
|
150
|
-
$id?: string;
|
|
151
|
-
/** Title of this schema */
|
|
152
|
-
title?: string;
|
|
153
|
-
/** Description of this schema */
|
|
154
|
-
description?: string;
|
|
155
|
-
/** Default value for this schema */
|
|
156
|
-
default?: any;
|
|
157
|
-
/** Example values matching this schema */
|
|
158
|
-
examples?: any;
|
|
159
|
-
/** Optional annotation for readOnly */
|
|
160
|
-
readOnly?: boolean;
|
|
161
|
-
/** Optional annotation for writeOnly */
|
|
162
|
-
writeOnly?: boolean;
|
|
163
|
-
[prop: string]: any;
|
|
164
|
-
}
|
|
165
|
-
interface TKind {
|
|
166
|
-
[Kind]: string;
|
|
167
|
-
}
|
|
168
|
-
interface TSchema extends TKind, SchemaOptions {
|
|
169
|
-
[ReadonlyKind]?: string;
|
|
170
|
-
[OptionalKind]?: string;
|
|
171
|
-
[Hint]?: string;
|
|
172
|
-
params: unknown[];
|
|
173
|
-
static: unknown;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
declare const permissionSchema: TObject<{
|
|
177
|
-
name: TString;
|
|
178
|
-
group: TOptional<TString>;
|
|
179
|
-
description: TOptional<TString>;
|
|
180
|
-
method: TOptional<TString>;
|
|
181
|
-
path: TOptional<TString>;
|
|
182
|
-
contentType: TOptional<TString>;
|
|
183
|
-
}>;
|
|
184
|
-
type Permission = Static$1<typeof permissionSchema>;
|
|
185
|
-
|
|
50
|
+
type Permission = Static<typeof permissionSchema>;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/descriptors/$permission.d.ts
|
|
186
53
|
declare const KEY$2 = "PERMISSION";
|
|
187
54
|
interface PermissionDescriptorOptions {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Name of the permission. Use Property name is not provided.
|
|
57
|
+
*/
|
|
58
|
+
name?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Group of the permission. Use Class name is not provided.
|
|
61
|
+
*/
|
|
62
|
+
group?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Describe the permission.
|
|
65
|
+
*/
|
|
66
|
+
description?: string;
|
|
67
|
+
/**
|
|
68
|
+
* HTTP method of the permission. When available.
|
|
69
|
+
*/
|
|
70
|
+
method?: string;
|
|
71
|
+
/**
|
|
72
|
+
* URL of the permission. When available.
|
|
73
|
+
*/
|
|
74
|
+
url?: string;
|
|
208
75
|
}
|
|
209
76
|
interface PermissionDescriptor {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
77
|
+
[KIND]: typeof KEY$2;
|
|
78
|
+
[OPTIONS]: PermissionDescriptorOptions;
|
|
79
|
+
/**
|
|
80
|
+
* Get the permission object.
|
|
81
|
+
*/
|
|
82
|
+
(): Permission;
|
|
83
|
+
/**
|
|
84
|
+
* Check if the user has the permission.
|
|
85
|
+
*/
|
|
86
|
+
can(user: UserAccountInfo): boolean;
|
|
220
87
|
}
|
|
221
88
|
declare const $permission: {
|
|
222
|
-
|
|
223
|
-
|
|
89
|
+
(options?: PermissionDescriptorOptions): PermissionDescriptor;
|
|
90
|
+
[KIND]: string;
|
|
224
91
|
};
|
|
225
|
-
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/interfaces/UserAccountToken.d.ts
|
|
226
94
|
interface UserAccountToken extends UserAccountInfo {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Access token for the user.
|
|
97
|
+
*/
|
|
98
|
+
token?: string;
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
realm?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Is user dedicated to his own resources for this scope ?
|
|
105
|
+
* Mostly, Admin is false and Customer is true.
|
|
106
|
+
*/
|
|
107
|
+
ownership?: string | boolean;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/schemas/roleSchema.d.ts
|
|
111
|
+
declare const roleSchema: _sinclair_typebox20.TObject<{
|
|
112
|
+
name: _sinclair_typebox20.TString;
|
|
113
|
+
description: _sinclair_typebox20.TOptional<_sinclair_typebox20.TString>;
|
|
114
|
+
default: _sinclair_typebox20.TOptional<_sinclair_typebox20.TBoolean>;
|
|
115
|
+
permissions: _sinclair_typebox20.TArray<_sinclair_typebox20.TObject<{
|
|
116
|
+
name: _sinclair_typebox20.TString;
|
|
117
|
+
ownership: _sinclair_typebox20.TOptional<_sinclair_typebox20.TBoolean>;
|
|
118
|
+
exclude: _sinclair_typebox20.TOptional<_sinclair_typebox20.TArray<_sinclair_typebox20.TString>>;
|
|
119
|
+
}>>;
|
|
251
120
|
}>;
|
|
252
|
-
type Role = Static
|
|
253
|
-
|
|
121
|
+
type Role = Static<typeof roleSchema>;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/providers/JwtProvider.d.ts
|
|
254
124
|
/**
|
|
255
125
|
* Provides utilities for working with JSON Web Tokens (JWT).
|
|
256
126
|
*/
|
|
257
127
|
declare class JwtProvider {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
128
|
+
protected readonly log: _alepha_core7.Logger;
|
|
129
|
+
protected readonly keystore: KeyLoaderHolder[];
|
|
130
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
131
|
+
/**
|
|
132
|
+
* Adds a key loader to the embedded keystore.
|
|
133
|
+
*
|
|
134
|
+
* @param name
|
|
135
|
+
* @param secretKeyOrJwks
|
|
136
|
+
*/
|
|
137
|
+
setKeyLoader(name: string, secretKeyOrJwks: string | JSONWebKeySet): void;
|
|
138
|
+
/**
|
|
139
|
+
* Retrieves the payload from a JSON Web Token (JWT).
|
|
140
|
+
*
|
|
141
|
+
* @param token - The JWT to extract the payload from.
|
|
142
|
+
*
|
|
143
|
+
* @return A Promise that resolves with the payload object from the token.
|
|
144
|
+
*/
|
|
145
|
+
parse(token: string): Promise<JwtParseResult>;
|
|
146
|
+
/**
|
|
147
|
+
* Creates a JWT token with the provided payload and secret key.
|
|
148
|
+
*
|
|
149
|
+
* @param payload - The payload to be encoded in the token.
|
|
150
|
+
* It should include the `realm_access` property which contains an array of roles.
|
|
151
|
+
* @param keyName - The name of the key to use when signing the token.
|
|
152
|
+
* @param signOptions - The options to use when signing the token.
|
|
153
|
+
*
|
|
154
|
+
* @returns The signed JWT token.
|
|
155
|
+
*/
|
|
156
|
+
create(payload: ExtendedJWTPayload, keyName?: string, signOptions?: JwtSignOptions): Promise<string>;
|
|
157
|
+
/**
|
|
158
|
+
* Retrieves the options to use when signing a JWT token.
|
|
159
|
+
*
|
|
160
|
+
* @returns The JWT sign options.
|
|
161
|
+
*/
|
|
162
|
+
signOptions(): JwtSignOptions;
|
|
163
|
+
/**
|
|
164
|
+
* Retrieves the first secret key from the keystore.
|
|
165
|
+
*
|
|
166
|
+
* @protected
|
|
167
|
+
*/
|
|
168
|
+
protected getFirstSecretKey(): string | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* Determines if the provided key is a secret key.
|
|
171
|
+
*
|
|
172
|
+
* @param key
|
|
173
|
+
* @protected
|
|
174
|
+
*/
|
|
175
|
+
protected isSecretKey(key: string): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Try to find a realm name or something similar in the token.
|
|
178
|
+
*
|
|
179
|
+
* This is useful when the token is not encrypted and API has multiple realms.
|
|
180
|
+
* Instead of trying to verify the token with all keys, we can try to find the key !
|
|
181
|
+
*
|
|
182
|
+
* @param token
|
|
183
|
+
* @protected
|
|
184
|
+
*/
|
|
185
|
+
protected tryToGetKeyLoaderFromToken(token: string): KeyLoaderHolder | undefined;
|
|
316
186
|
}
|
|
317
187
|
type KeyLoader = (protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput) => Promise<CryptoKey | KeyObject>;
|
|
318
188
|
interface KeyLoaderHolder {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
189
|
+
name: string;
|
|
190
|
+
keyLoader: KeyLoader;
|
|
191
|
+
secretKey?: string;
|
|
322
192
|
}
|
|
323
193
|
interface JwtSignOptions {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
194
|
+
issuedAt?: boolean;
|
|
195
|
+
protectedHeader?: JWTHeaderParameters;
|
|
196
|
+
expiresIn?: number;
|
|
327
197
|
}
|
|
328
198
|
interface ExtendedJWTPayload extends JWTPayload {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
199
|
+
name?: string;
|
|
200
|
+
roles?: string[];
|
|
201
|
+
realm_access?: {
|
|
202
|
+
roles: string[];
|
|
203
|
+
};
|
|
334
204
|
}
|
|
335
205
|
interface JwtParseResult {
|
|
336
|
-
|
|
337
|
-
|
|
206
|
+
keyName: string;
|
|
207
|
+
result: JWTVerifyResult<ExtendedJWTPayload>;
|
|
338
208
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/providers/SecurityProvider.d.ts
|
|
211
|
+
declare const envSchema: _alepha_core2.TObject<{
|
|
212
|
+
SECURITY_SECRET_KEY: _sinclair_typebox1.TString;
|
|
342
213
|
}>;
|
|
343
214
|
declare module "alepha" {
|
|
344
|
-
|
|
345
|
-
}
|
|
215
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
346
216
|
}
|
|
347
217
|
declare class SecurityProvider {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
218
|
+
protected readonly UNKNOWN_USER_NAME = "Unknown User";
|
|
219
|
+
protected readonly PERMISSION_REGEXP: RegExp;
|
|
220
|
+
protected readonly PERMISSION_REGEXP_WILDCARD: RegExp;
|
|
221
|
+
protected readonly log: _alepha_core2.Logger;
|
|
222
|
+
protected readonly jwt: JwtProvider;
|
|
223
|
+
protected readonly env: {
|
|
224
|
+
SECURITY_SECRET_KEY: string;
|
|
225
|
+
};
|
|
226
|
+
protected readonly alepha: Alepha;
|
|
227
|
+
/**
|
|
228
|
+
* The permissions configured for the security provider.
|
|
229
|
+
*/
|
|
230
|
+
protected readonly permissions: Permission[];
|
|
231
|
+
/**
|
|
232
|
+
* The realms configured for the security provider.
|
|
233
|
+
*/
|
|
234
|
+
protected readonly realms: Realm[];
|
|
235
|
+
/**
|
|
236
|
+
* Create realms.
|
|
237
|
+
*/
|
|
238
|
+
protected createRealms(): Realm[];
|
|
239
|
+
protected configure: _alepha_core2.HookDescriptor<"configure">;
|
|
240
|
+
/**
|
|
241
|
+
* Processes all $permission descriptors.
|
|
242
|
+
*/
|
|
243
|
+
protected processPermissionDescriptors(): void;
|
|
244
|
+
/**
|
|
245
|
+
* Processes all $realm descriptors.
|
|
246
|
+
*/
|
|
247
|
+
protected processRealmDescriptors(): void;
|
|
248
|
+
/**
|
|
249
|
+
* Processes all $role descriptors.
|
|
250
|
+
*/
|
|
251
|
+
protected processRoleDescriptors(): void;
|
|
252
|
+
protected ready: _alepha_core2.HookDescriptor<"ready">;
|
|
253
|
+
/**
|
|
254
|
+
* Updates the roles for a realm then synchronizes the user account provider if available.
|
|
255
|
+
*
|
|
256
|
+
* Only available when the app is started.
|
|
257
|
+
*
|
|
258
|
+
* @param realm - The realm to update the roles for.
|
|
259
|
+
* @param roles - The roles to update.
|
|
260
|
+
*/
|
|
261
|
+
updateRealm(realm: string, roles: Role[]): Promise<void>;
|
|
262
|
+
/**
|
|
263
|
+
* Adds a role to one or more realms.
|
|
264
|
+
*
|
|
265
|
+
* @param role
|
|
266
|
+
* @param realms
|
|
267
|
+
*/
|
|
268
|
+
createRole(role: Role, ...realms: string[]): Role;
|
|
269
|
+
/**
|
|
270
|
+
* Adds a permission to the security provider.
|
|
271
|
+
*
|
|
272
|
+
* @param raw - The permission to add.
|
|
273
|
+
*/
|
|
274
|
+
createPermission(raw: Permission | string): Permission;
|
|
275
|
+
/**
|
|
276
|
+
* Creates a user account from the provided payload.
|
|
277
|
+
*
|
|
278
|
+
* @param payload - The payload to create the user account from.
|
|
279
|
+
* @param [realmName] - The realm containing the roles. Default is all.
|
|
280
|
+
*
|
|
281
|
+
* @returns The user info created from the payload.
|
|
282
|
+
*/
|
|
283
|
+
createInfoFromPayload(payload: JWTPayload, realmName?: string): UserAccountInfo;
|
|
284
|
+
/**
|
|
285
|
+
* Checks if the user has the specified permission.
|
|
286
|
+
*
|
|
287
|
+
* Bonus: we check also if the user has "ownership" flag.
|
|
288
|
+
*
|
|
289
|
+
* @param permissionLike - The permission to check for.
|
|
290
|
+
* @param roleEntries - The roles to check for the permission.
|
|
291
|
+
*/
|
|
292
|
+
checkPermission(permissionLike: string | Permission, ...roleEntries: string[]): SecurityCheckResult;
|
|
293
|
+
/**
|
|
294
|
+
* Creates a user account from the provided payload.
|
|
295
|
+
*
|
|
296
|
+
* @param headerOrToken
|
|
297
|
+
* @param permissionLike
|
|
298
|
+
*/
|
|
299
|
+
createUserFromToken(headerOrToken?: string, permissionLike?: Permission | string): Promise<UserAccountToken>;
|
|
300
|
+
/**
|
|
301
|
+
* Checks if a user has a specific role.
|
|
302
|
+
*
|
|
303
|
+
* @param roleName - The role to check for.
|
|
304
|
+
* @param permission - The permission to check for.
|
|
305
|
+
* @returns True if the user has the role, false otherwise.
|
|
306
|
+
*/
|
|
307
|
+
can(roleName: string, permission: string | Permission): boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Checks if a user has ownership of a specific permission.
|
|
310
|
+
*/
|
|
311
|
+
ownership(roleName: string, permission: string | Permission): string | boolean | undefined;
|
|
312
|
+
/**
|
|
313
|
+
* Converts a permission object to a string.
|
|
314
|
+
*
|
|
315
|
+
* @param permission
|
|
316
|
+
*/
|
|
317
|
+
permissionToString(permission: Permission | string): string;
|
|
318
|
+
getRealms(): Realm[];
|
|
319
|
+
/**
|
|
320
|
+
* Retrieves the user account from the provided user ID.
|
|
321
|
+
*
|
|
322
|
+
* @param realm
|
|
323
|
+
*/
|
|
324
|
+
getRoles(realm?: string): Role[];
|
|
325
|
+
/**
|
|
326
|
+
* Returns all permissions.
|
|
327
|
+
*
|
|
328
|
+
* @param user - Filter permissions by user.
|
|
329
|
+
*
|
|
330
|
+
* @return An array containing all permissions.
|
|
331
|
+
*/
|
|
332
|
+
getPermissions(user?: {
|
|
333
|
+
roles?: Array<Role | string>;
|
|
334
|
+
realm?: string;
|
|
335
|
+
}): Permission[];
|
|
336
|
+
/**
|
|
337
|
+
* Retrieves the user ID from the provided payload object.
|
|
338
|
+
*
|
|
339
|
+
* @param payload - The payload object from which to extract the user ID.
|
|
340
|
+
* @return The user ID as a string.
|
|
341
|
+
*/
|
|
342
|
+
getIdFromPayload(payload: Record<string, any>): string;
|
|
343
|
+
/**
|
|
344
|
+
* Retrieves the roles from the provided payload object.
|
|
345
|
+
* @param payload - The payload object from which to extract the roles.
|
|
346
|
+
* @return An array of role strings.
|
|
347
|
+
*/
|
|
348
|
+
getRolesFromPayload(payload: Record<string, any>): string[];
|
|
349
|
+
getPictureFromPayload(payload: Record<string, any>): string | undefined;
|
|
350
|
+
getEmailFromPayload(payload: Record<string, any>): string | undefined;
|
|
351
|
+
/**
|
|
352
|
+
* Returns the name from the given payload.
|
|
353
|
+
*
|
|
354
|
+
* @param payload - The payload object.
|
|
355
|
+
* @returns The name extracted from the payload, or an empty string if the payload is falsy or no name is found.
|
|
356
|
+
*/
|
|
357
|
+
getNameFromPayload(payload: Record<string, any>): string;
|
|
358
|
+
getOrganizationFromPayload(payload: Record<string, any>): string | undefined;
|
|
489
359
|
}
|
|
490
360
|
/**
|
|
491
361
|
* A realm definition.
|
|
492
362
|
*/
|
|
493
363
|
interface Realm {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
364
|
+
/**
|
|
365
|
+
*
|
|
366
|
+
*/
|
|
367
|
+
name: string;
|
|
368
|
+
/**
|
|
369
|
+
*
|
|
370
|
+
*/
|
|
371
|
+
roles: Role[];
|
|
372
|
+
/**
|
|
373
|
+
* The secret key for the realm.
|
|
374
|
+
*
|
|
375
|
+
* Can be also a JWKS URL.
|
|
376
|
+
*/
|
|
377
|
+
secret?: string | JSONWebKeySet;
|
|
378
|
+
/**
|
|
379
|
+
* Attach a user provider to the realm.
|
|
380
|
+
*
|
|
381
|
+
* This is useful when you want to use a custom user provider for a specific realm.
|
|
382
|
+
*/
|
|
383
|
+
userAccountProvider?: SecurityUserAccountProvider;
|
|
384
|
+
onLoadUser?: (user: UserAccountInfo) => Promise<void> | void;
|
|
515
385
|
}
|
|
516
386
|
interface SecurityUserAccountProvider {
|
|
517
|
-
|
|
518
|
-
|
|
387
|
+
jwks: string | undefined;
|
|
388
|
+
synchronize(config: RealmConfig): Promise<void>;
|
|
519
389
|
}
|
|
520
390
|
interface SecurityCheckResult {
|
|
521
|
-
|
|
522
|
-
|
|
391
|
+
isAuthorized: boolean;
|
|
392
|
+
ownership: string | boolean | undefined;
|
|
523
393
|
}
|
|
524
394
|
interface RealmConfig {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
395
|
+
roles?: Array<Role>;
|
|
396
|
+
smtp?: {
|
|
397
|
+
host?: string;
|
|
398
|
+
};
|
|
529
399
|
}
|
|
530
|
-
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region src/descriptors/$realm.d.ts
|
|
531
402
|
declare const KEY$1 = "REALM";
|
|
532
403
|
interface RealmDescriptorOptions {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
404
|
+
/**
|
|
405
|
+
* Define the realm name.
|
|
406
|
+
*
|
|
407
|
+
* @default key name
|
|
408
|
+
*/
|
|
409
|
+
name?: string;
|
|
410
|
+
/**
|
|
411
|
+
* Describe the realm.
|
|
412
|
+
*/
|
|
413
|
+
description?: string;
|
|
414
|
+
/**
|
|
415
|
+
* All roles available in the realm. Role is a string (role name) or a Role object (embedded role).
|
|
416
|
+
*/
|
|
417
|
+
roles?: Array<string | Role>;
|
|
418
|
+
/**
|
|
419
|
+
* In order to verify user of the realm, a secret is required.
|
|
420
|
+
* Can be a string based secret or a JWKS URL.
|
|
421
|
+
*
|
|
422
|
+
* Note: You can skip this if you are using a user account provider with JWKS.
|
|
423
|
+
*/
|
|
424
|
+
secret?: string | JSONWebKeySet | (() => string);
|
|
425
|
+
/**
|
|
426
|
+
* Attach a user account provider to the realm to manage roles.
|
|
427
|
+
* For example, you can use a KeycloakUserProvider to automatically create realm roles inside Keycloak.
|
|
428
|
+
*/
|
|
429
|
+
userAccountProvider?: SecurityUserAccountProvider | (() => SecurityUserAccountProvider);
|
|
559
430
|
}
|
|
560
431
|
interface RealmDescriptor {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
432
|
+
[KIND]: typeof KEY$1;
|
|
433
|
+
[OPTIONS]: RealmDescriptorOptions;
|
|
434
|
+
/**
|
|
435
|
+
* Get all roles in the realm.
|
|
436
|
+
*/
|
|
437
|
+
getRoles(): Role[];
|
|
438
|
+
/**
|
|
439
|
+
* Set all roles in the realm.
|
|
440
|
+
*/
|
|
441
|
+
setRoles(roles: Role[]): Promise<void>;
|
|
442
|
+
/**
|
|
443
|
+
* Get a role by name, throws an error if not found.
|
|
444
|
+
*/
|
|
445
|
+
getRoleByName(name: string): Role;
|
|
446
|
+
/**
|
|
447
|
+
* Create a token for the subject.
|
|
448
|
+
*/
|
|
449
|
+
createToken(subject: string, roles?: string[]): Promise<string>;
|
|
579
450
|
}
|
|
580
451
|
declare const $realm: {
|
|
581
|
-
|
|
582
|
-
|
|
452
|
+
(options?: RealmDescriptorOptions): RealmDescriptor;
|
|
453
|
+
[KIND]: string;
|
|
583
454
|
};
|
|
584
|
-
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/descriptors/$role.d.ts
|
|
585
457
|
declare const KEY = "ROLE";
|
|
586
458
|
interface RoleDescriptorOptions {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
459
|
+
/**
|
|
460
|
+
* Name of the role.
|
|
461
|
+
*/
|
|
462
|
+
name?: string;
|
|
463
|
+
/**
|
|
464
|
+
* Describe the role.
|
|
465
|
+
*/
|
|
466
|
+
description?: string;
|
|
467
|
+
/**
|
|
468
|
+
*
|
|
469
|
+
*/
|
|
470
|
+
permissions?: Array<string | {
|
|
471
|
+
name: string;
|
|
472
|
+
ownership?: boolean;
|
|
473
|
+
}>;
|
|
602
474
|
}
|
|
603
475
|
interface RoleDescriptor {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
476
|
+
[KIND]: typeof KEY;
|
|
477
|
+
[OPTIONS]: RoleDescriptorOptions;
|
|
478
|
+
/**
|
|
479
|
+
* Get the role object.
|
|
480
|
+
*/
|
|
481
|
+
(): Role;
|
|
610
482
|
}
|
|
611
483
|
declare const $role: {
|
|
612
|
-
|
|
613
|
-
|
|
484
|
+
(options?: RoleDescriptorOptions): RoleDescriptor;
|
|
485
|
+
[KIND]: string;
|
|
614
486
|
};
|
|
615
|
-
|
|
487
|
+
//#endregion
|
|
488
|
+
//#region src/descriptors/$serviceAccount.d.ts
|
|
616
489
|
/**
|
|
617
490
|
* Allow to get an access token for a service account.
|
|
618
491
|
*
|
|
@@ -643,63 +516,67 @@ declare const $role: {
|
|
|
643
516
|
*/
|
|
644
517
|
declare const $serviceAccount: (options: ServiceAccountDescriptorOptions) => ServiceAccountDescriptor;
|
|
645
518
|
type ServiceAccountDescriptorOptions = {
|
|
646
|
-
|
|
519
|
+
gracePeriod?: number;
|
|
647
520
|
} & ({
|
|
648
|
-
|
|
521
|
+
oauth2: Oauth2ServiceAccountDescriptorOptions;
|
|
649
522
|
} | {
|
|
650
|
-
|
|
523
|
+
jwt: JwtServiceAccountDescriptorOptions;
|
|
651
524
|
});
|
|
652
525
|
interface JwtServiceAccountDescriptorOptions {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
526
|
+
secret: string;
|
|
527
|
+
roles?: string[];
|
|
528
|
+
signOptions?: JwtSignOptions;
|
|
656
529
|
}
|
|
657
530
|
interface Oauth2ServiceAccountDescriptorOptions {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
531
|
+
/**
|
|
532
|
+
* Get Token URL.
|
|
533
|
+
*/
|
|
534
|
+
url: string;
|
|
535
|
+
/**
|
|
536
|
+
* Client ID.
|
|
537
|
+
*/
|
|
538
|
+
clientId: string;
|
|
539
|
+
/**
|
|
540
|
+
* Client Secret.
|
|
541
|
+
*/
|
|
542
|
+
clientSecret: string;
|
|
670
543
|
}
|
|
671
544
|
interface ServiceAccountDescriptor {
|
|
672
|
-
|
|
545
|
+
token: () => Promise<string>;
|
|
673
546
|
}
|
|
674
547
|
interface AccessTokenResponse {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
548
|
+
access_token: string;
|
|
549
|
+
expires_in: number;
|
|
550
|
+
at: number;
|
|
678
551
|
}
|
|
679
552
|
interface ServiceAccountStore {
|
|
680
|
-
|
|
553
|
+
response?: AccessTokenResponse;
|
|
681
554
|
}
|
|
682
|
-
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/errors/InvalidPermissionError.d.ts
|
|
683
557
|
declare class InvalidPermissionError extends Error {
|
|
684
|
-
|
|
558
|
+
constructor(name: string);
|
|
685
559
|
}
|
|
686
|
-
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region src/errors/SecurityError.d.ts
|
|
687
562
|
declare class SecurityError extends Error {
|
|
688
|
-
|
|
689
|
-
|
|
563
|
+
readonly status = 403;
|
|
564
|
+
readonly code = "ERR_SECURITY";
|
|
690
565
|
}
|
|
691
|
-
|
|
566
|
+
//#endregion
|
|
567
|
+
//#region src/index.d.ts
|
|
692
568
|
declare module "alepha/core" {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
569
|
+
interface Hooks {
|
|
570
|
+
"security:user:created": {
|
|
571
|
+
realm: string;
|
|
572
|
+
user: UserAccountInfo;
|
|
573
|
+
};
|
|
574
|
+
}
|
|
699
575
|
}
|
|
700
576
|
declare class AlephaSecurity {
|
|
701
|
-
|
|
702
|
-
|
|
577
|
+
readonly name = "alepha.security";
|
|
578
|
+
readonly $services: (alepha: Alepha) => Alepha;
|
|
703
579
|
}
|
|
704
|
-
|
|
705
|
-
export { $permission, $realm, $role, $serviceAccount,
|
|
580
|
+
//#endregion
|
|
581
|
+
export { $permission, $realm, $role, $serviceAccount, AccessTokenResponse, AlephaSecurity, ExtendedJWTPayload, InvalidPermissionError, JwtParseResult, JwtProvider, JwtServiceAccountDescriptorOptions, JwtSignOptions, KeyLoader, KeyLoaderHolder, Oauth2ServiceAccountDescriptorOptions, Permission, PermissionDescriptor, PermissionDescriptorOptions, Realm, RealmConfig, RealmDescriptor, RealmDescriptorOptions, Role, RoleDescriptor, RoleDescriptorOptions, SecurityCheckResult, SecurityError, SecurityProvider, SecurityUserAccountProvider, ServiceAccountDescriptor, ServiceAccountDescriptorOptions, ServiceAccountStore, UserAccountInfo, UserAccountToken, permissionSchema, roleSchema };
|
|
582
|
+
//# sourceMappingURL=index.d.ts.map
|