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