@universis/janitor 1.6.3 → 1.8.0

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/README.md CHANGED
@@ -232,15 +232,15 @@ Speed limit headers will be available only if the request is made from the same
232
232
 
233
233
  ## ScopeAccessConfiguration
234
234
 
235
- `ScopeAccessConfiguration` is a configurable application service for limiting access to service endpoints based on user scopes.
235
+ `ScopeAccessConfiguration` is a configurable application configuration strategy for limiting access to service endpoints based on user scopes.
236
236
 
237
- Register service under application services:
237
+ Enable scope access configuration using `EnableScopeAccessConfiguration` service:
238
238
 
239
239
  ```json
240
240
  {
241
241
  "services": [
242
242
  {
243
- "serviceType": "@universis/janitor#ScopeAccessConfiguration"
243
+ "serviceType": "@universis/janitor#EnableScopeAccessConfiguration"
244
244
  }
245
245
  ]
246
246
  }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,213 @@
1
- export * from './RateLimitService';
2
- export * from './SpeedLimitService';
3
- export * from './RedisClientStore';
4
- export * from './ScopeAccessConfiguration';
5
- export * from './validateScope';
6
- export * from './OAuth2ClientService';
7
- export * from './RemoteAddressValidator';
1
+ import { ApplicationService, ConfigurationStrategy, ConfigurationBase, ApplicationBase } from '@themost/common';
2
+ import RedisStore from 'rate-limit-redis';
3
+ import { Handler, Request as Request$1 } from 'express';
4
+ import { DataContext } from '@themost/data';
5
+
6
+ declare class RateLimitService extends ApplicationService {
7
+
8
+ }
9
+
10
+ declare class SpeedLimitService extends ApplicationService {
11
+
12
+ }
13
+
14
+ declare class RedisClientStore extends RedisStore {
15
+ constructor(app: ApplicationService);
16
+ }
17
+
18
+ /**
19
+ * @license
20
+ * Universis Project Version 1.0
21
+ * Copyright (c) 2018, Universis Project All rights reserved
22
+ *
23
+ * Use of this source code is governed by an LGPL 3.0 license that can be
24
+ * found in the LICENSE file at https://universis.io/license
25
+ */
26
+
27
+
28
+ declare class ScopeString {
29
+ constructor(str: string);
30
+ split(): string[];
31
+ }
32
+
33
+ declare interface UniversisConfigurationSection {
34
+ universis: {
35
+ [k: string]: any;
36
+ }
37
+ }
38
+
39
+ declare interface ScopeAccessConfigurationSection {
40
+ janitor: {
41
+ scopeAccess: {
42
+ imports: string[]
43
+ }
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Declares a configuration element for managing scope-based permissions on server resources
49
+ */
50
+ declare interface ScopeAccessConfigurationElement {
51
+ /**
52
+ * Gets or sets an array of strings that holds an array of scopes e.g. students or students:read or students,teachers etc
53
+ */
54
+ scope: string[],
55
+ /**
56
+ * Gets or sets a string which represents the regular expression that is going to be used for validating endpoint
57
+ */
58
+ resource: string;
59
+ /**
60
+ * Gets or sets an array of strings which represents the access levels for the given scopes e.g. READ or READ,WRITE etc
61
+ */
62
+ access: string[];
63
+ /**
64
+ * Gets or sets a string which represents a short description for this item
65
+ */
66
+ description?: string;
67
+ }
68
+
69
+ declare class ScopeAccessConfiguration extends ConfigurationStrategy {
70
+
71
+ constructor(configuration: ConfigurationBase);
72
+
73
+ /**
74
+ * Gets an array of scope access configuration elements
75
+ */
76
+ public elements: ScopeAccessConfigurationElement[];
77
+
78
+ /**
79
+ * Verifies the given request and returns a promise that resolves with a scope access configuration element
80
+ */
81
+ verify(req: Request): Promise<ScopeAccessConfigurationElement>;
82
+ }
83
+
84
+ declare class DefaultScopeAccessConfiguration extends ScopeAccessConfiguration {
85
+
86
+ constructor(configuration: ConfigurationBase);
87
+ /**
88
+ * Gets an array of scope access configuration elements
89
+ */
90
+ public elements: ScopeAccessConfigurationElement[];
91
+ /**
92
+ * Verifies the given request and returns a promise that resolves with a scope access configuration element
93
+ */
94
+ verify(req: Request): Promise<ScopeAccessConfigurationElement>;
95
+
96
+ }
97
+
98
+ declare class EnableScopeAccessConfiguration extends ApplicationService {
99
+ constructor(app: ApplicationBase);
100
+ }
101
+
102
+ declare class ExtendScopeAccessConfiguration extends ApplicationService {
103
+ constructor(app: ApplicationBase);
104
+ }
105
+
106
+ declare function validateScope(): Handler;
107
+
108
+ declare interface OAuth2MethodOptions {
109
+ access_token: string;
110
+ }
111
+
112
+ declare interface OAuth2AuthorizeUser {
113
+ client_id?: string;
114
+ client_secret?: string;
115
+ username: string;
116
+ password: string;
117
+ grant_type: string;
118
+ scope?: string;
119
+ }
120
+
121
+ declare interface OAuth2ServiceSettings {
122
+ unattendedExecutionAccount?: string;
123
+ client_id: string;
124
+ client_secret?: string;
125
+ server_uri: string;
126
+ userinfo_uri?: string;
127
+ introspect_uri?: string;
128
+ admin_uri?: string;
129
+ well_known_configuration_uri?: string;
130
+ adminAccount: {
131
+ username: string;
132
+ password: string;
133
+ client_id: string;
134
+ client_secret?: string;
135
+ scope?: string;
136
+ }
137
+ }
138
+
139
+ declare interface OAuth2UserProfile {
140
+ sub: string;
141
+ name: string;
142
+ preferred_username: string;
143
+ given_name: string;
144
+ family_name: string;
145
+ email: string;
146
+ }
147
+
148
+ declare interface GenericUser {
149
+ id?: any;
150
+ additionalType?: string;
151
+ alternateName?: string;
152
+ description?: string;
153
+ givenName?: string;
154
+ familyName?: string;
155
+ image?: string;
156
+ name?: string;
157
+ url?: string;
158
+ dateCreated?: Date;
159
+ dateModified?: Date;
160
+ createdBy?: any;
161
+ modifiedBy?: any;
162
+ lockoutTime?: Date;
163
+ logonCount?: number;
164
+ enabled?: boolean;
165
+ lastLogon?: Date;
166
+ userCredentials?: {
167
+ userPassword?: string;
168
+ userActivated?: boolean;
169
+ temporary?: boolean;
170
+ }
171
+ }
172
+
173
+ declare interface OAuth2User {
174
+ id?: any;
175
+ username?: string;
176
+ email?: string;
177
+ enabled?: boolean;
178
+ emailVerified?: boolean;
179
+ firstName?: string;
180
+ lastName?: string;
181
+ credentials?: {
182
+ algorithm?: string,
183
+ temporary?: boolean,
184
+ type?: string,
185
+ value?: string
186
+ }
187
+ }
188
+
189
+ declare class OAuth2ClientService extends ApplicationService {
190
+ get settings(): OAuth2ServiceSettings;
191
+ constructor(app: ApplicationBase)
192
+ getUserInfo(context: DataContext, token: string): Promise<OAuth2UserProfile>;
193
+ getTokenInfo(context: DataContext, token: string): Promise<any>;
194
+ getContextTokenInfo(context: DataContext): Promise<any>;
195
+ authorize(authorizeUser: OAuth2AuthorizeUser): Promise<{ access_token?: string, refresh_token?: string}>;
196
+ getUser(username: string, options: OAuth2MethodOptions): Promise<any>;
197
+ getUserById(user_id: any, options: OAuth2MethodOptions): Promise<any>;
198
+ getUserByEmail(email: string, options: OAuth2MethodOptions): Promise<any>;
199
+ updateUser(user: GenericUser | any, options: OAuth2MethodOptions): Promise<any>;
200
+ createUser(user: GenericUser | any, options: OAuth2MethodOptions): Promise<any>;
201
+ deleteUser(user: { id: any }, options: OAuth2MethodOptions): Promise<any>;
202
+ }
203
+
204
+ declare class RemoteAddressValidator extends ApplicationService {
205
+
206
+ constructor(app: ApplicationService);
207
+ validateRemoteAddress(request: Request$1): Promise<boolean>;
208
+ getRemoteAddress(request: Request$1): string;
209
+
210
+ }
211
+
212
+ export { DefaultScopeAccessConfiguration, EnableScopeAccessConfiguration, ExtendScopeAccessConfiguration, OAuth2ClientService, RateLimitService, RedisClientStore, RemoteAddressValidator, ScopeAccessConfiguration, ScopeString, SpeedLimitService, validateScope };
213
+ export type { GenericUser, OAuth2AuthorizeUser, OAuth2MethodOptions, OAuth2ServiceSettings, OAuth2User, OAuth2UserProfile, ScopeAccessConfigurationElement, ScopeAccessConfigurationSection, UniversisConfigurationSection };