alepha 0.8.1 → 0.9.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 +47 -17
- package/batch.d.ts +83 -117
- package/bucket.cjs +8 -0
- package/bucket.d.ts +194 -0
- package/bucket.js +1 -0
- package/cache/redis.d.ts +14 -14
- package/cache.d.ts +101 -238
- package/command.d.ts +66 -71
- package/core.d.ts +1003 -851
- package/datetime.d.ts +90 -116
- package/file.d.ts +23 -13
- package/lock/redis.d.ts +11 -11
- package/lock.d.ts +121 -111
- package/package.json +54 -40
- package/postgres.d.ts +218 -393
- package/queue/redis.d.ts +13 -13
- package/queue.d.ts +84 -198
- package/react/auth.d.ts +47 -53
- package/react/head.d.ts +4 -7
- package/react.d.ts +47 -183
- package/redis.d.ts +31 -16
- package/retry.d.ts +70 -59
- package/router.d.ts +9 -9
- package/scheduler.d.ts +54 -93
- package/security.d.ts +95 -276
- package/server/cache.d.ts +22 -28
- package/server/compress.d.ts +16 -7
- package/server/cookies.d.ts +65 -233
- package/server/cors.d.ts +15 -13
- package/server/health.d.ts +23 -23
- package/server/helmet.d.ts +17 -18
- package/server/links.d.ts +108 -88
- package/server/metrics.d.ts +25 -21
- package/server/multipart.d.ts +12 -14
- package/server/proxy.d.ts +22 -17
- package/server/security.cjs +8 -0
- package/server/security.d.ts +90 -0
- package/server/security.js +1 -0
- package/server/static.d.ts +63 -67
- package/server/swagger.d.ts +73 -62
- package/server.d.ts +250 -446
- package/topic/redis.d.ts +25 -24
- package/topic.d.ts +68 -115
package/server/links.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import * as _alepha_core1 from "alepha";
|
|
2
|
+
import * as _alepha_core0$1 from "alepha";
|
|
3
|
+
import * as _alepha_core0 from "alepha";
|
|
4
|
+
import { Alepha, Descriptor, KIND, Logger } from "alepha";
|
|
5
|
+
import * as _alepha_server0 from "alepha/server";
|
|
6
|
+
import { ActionDescriptor, ApiLink, ApiLinksResponse, ClientRequestEntry, ClientRequestOptions, ClientRequestResponse, FetchResponse, HttpClient, RequestConfigSchema, ServerHandler, ServerRequestConfigEntry } from "alepha/server";
|
|
7
|
+
import * as _alepha_retry0 from "alepha/retry";
|
|
8
|
+
import { ProxyDescriptorOptions, ServerProxyProvider } from "alepha/server/proxy";
|
|
5
9
|
import { ServiceAccountDescriptor, UserAccountToken } from "alepha/security";
|
|
10
|
+
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
6
11
|
|
|
7
12
|
//#region src/providers/LinkProvider.d.ts
|
|
8
13
|
declare class LinkProvider {
|
|
@@ -15,24 +20,20 @@ declare class LinkProvider {
|
|
|
15
20
|
getLinks(force?: boolean): Promise<HttpClientLink[]>;
|
|
16
21
|
client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
17
22
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
* Resolve a link by its name and call it.
|
|
24
|
+
* - If link is local, it will call the local handler.
|
|
25
|
+
* - If link is remote, it will make a fetch request to the remote server.
|
|
26
|
+
*/
|
|
22
27
|
follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
|
|
23
28
|
protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
|
|
24
29
|
can(name: string): boolean;
|
|
25
30
|
protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
|
|
26
31
|
}
|
|
27
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
28
32
|
interface HttpClientLink extends ApiLink {
|
|
29
33
|
secured?: boolean;
|
|
30
34
|
prefix?: string;
|
|
31
|
-
// -- server only --
|
|
32
|
-
// only for remote actions
|
|
33
35
|
host?: string;
|
|
34
36
|
service?: string;
|
|
35
|
-
// used only for local actions, not for remote actions
|
|
36
37
|
schema?: RequestConfigSchema;
|
|
37
38
|
handler?: ServerHandler;
|
|
38
39
|
}
|
|
@@ -40,80 +41,86 @@ interface ClientScope {
|
|
|
40
41
|
group?: string;
|
|
41
42
|
service?: string;
|
|
42
43
|
}
|
|
43
|
-
type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? T[K] & {
|
|
44
|
+
type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? T[K] & {
|
|
45
|
+
(config?: ClientRequestEntry<Schema>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<Schema>>;
|
|
44
46
|
can: () => boolean;
|
|
45
47
|
schema: Schema;
|
|
46
48
|
} : never };
|
|
49
|
+
//# sourceMappingURL=LinkProvider.d.ts.map
|
|
47
50
|
//#endregion
|
|
48
51
|
//#region src/descriptors/$client.d.ts
|
|
49
52
|
/**
|
|
50
|
-
* Create a new client.
|
|
51
|
-
*/
|
|
52
|
-
declare const $client:
|
|
53
|
+
* Create a new client.
|
|
54
|
+
*/
|
|
55
|
+
declare const $client: {
|
|
56
|
+
<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
57
|
+
[KIND]: string;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=$client.d.ts.map
|
|
60
|
+
|
|
53
61
|
//#endregion
|
|
54
62
|
//#region src/descriptors/$remote.d.ts
|
|
55
|
-
declare const KEY = "REMOTE";
|
|
56
63
|
/**
|
|
57
|
-
* $remote is a descriptor that allows you to define remote service access.
|
|
58
|
-
*
|
|
59
|
-
* Use it only when you have 2 or more services that need to communicate with each other.
|
|
60
|
-
*
|
|
61
|
-
* All remote services can be exposed as actions, ... or not.
|
|
62
|
-
*
|
|
63
|
-
* You can add a service account if you want to use a security layer.
|
|
64
|
-
*/
|
|
64
|
+
* $remote is a descriptor that allows you to define remote service access.
|
|
65
|
+
*
|
|
66
|
+
* Use it only when you have 2 or more services that need to communicate with each other.
|
|
67
|
+
*
|
|
68
|
+
* All remote services can be exposed as actions, ... or not.
|
|
69
|
+
*
|
|
70
|
+
* You can add a service account if you want to use a security layer.
|
|
71
|
+
*/
|
|
65
72
|
declare const $remote: {
|
|
66
73
|
(options: RemoteDescriptorOptions): RemoteDescriptor;
|
|
67
|
-
[KIND]:
|
|
74
|
+
[KIND]: typeof RemoteDescriptor;
|
|
68
75
|
};
|
|
69
76
|
interface RemoteDescriptorOptions {
|
|
70
77
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
* The URL of the remote service.
|
|
79
|
+
* You can use a function to generate the URL dynamically.
|
|
80
|
+
* You probably should use $env(env) to get the URL from the environment.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { $remote } from "alepha/server";
|
|
85
|
+
* import { $inject, t } from "alepha";
|
|
86
|
+
*
|
|
87
|
+
* class App {
|
|
88
|
+
* env = $env(t.object({
|
|
89
|
+
* REMOTE_URL: t.string({default: "http://localhost:3000"}),
|
|
90
|
+
* }));
|
|
91
|
+
* remote = $remote({
|
|
92
|
+
* url: this.env.REMOTE_URL,
|
|
93
|
+
* });
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
90
97
|
url: string | (() => string);
|
|
91
98
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
* The name of the remote service.
|
|
100
|
+
*
|
|
101
|
+
* @default Member of the class containing the remote service.
|
|
102
|
+
*/
|
|
96
103
|
name?: string;
|
|
97
104
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
* If true, all methods of the remote service will be exposed as actions in this context.
|
|
106
|
+
* > Note: Proxy will never use the service account, it just... proxies the request.
|
|
107
|
+
*/
|
|
101
108
|
proxy?: boolean | Partial<ProxyDescriptorOptions & {
|
|
102
109
|
/**
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
* If true, the remote service won't be available internally, only through the proxy.
|
|
111
|
+
*/
|
|
105
112
|
noInternal: boolean;
|
|
106
113
|
}>;
|
|
107
114
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
* For communication between the server and the remote service with a security layer.
|
|
116
|
+
* This will be used for internal communication and will not be exposed to the client.
|
|
117
|
+
*/
|
|
111
118
|
serviceAccount?: ServiceAccountDescriptor;
|
|
112
119
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
[OPTIONS]: RemoteDescriptorOptions;
|
|
120
|
+
declare class RemoteDescriptor extends Descriptor<RemoteDescriptorOptions> {
|
|
121
|
+
get name(): string;
|
|
116
122
|
}
|
|
123
|
+
//# sourceMappingURL=$remote.d.ts.map
|
|
117
124
|
//#endregion
|
|
118
125
|
//#region src/providers/RemoteDescriptorProvider.d.ts
|
|
119
126
|
declare class RemoteDescriptorProvider {
|
|
@@ -122,47 +129,61 @@ declare class RemoteDescriptorProvider {
|
|
|
122
129
|
};
|
|
123
130
|
protected readonly alepha: Alepha;
|
|
124
131
|
protected readonly client: LinkProvider;
|
|
125
|
-
protected readonly proxyProvider:
|
|
132
|
+
protected readonly proxyProvider: ServerProxyProvider;
|
|
126
133
|
protected readonly remotes: Array<ServerRemote>;
|
|
127
134
|
protected readonly log: Logger;
|
|
128
135
|
getRemotes(): ServerRemote[];
|
|
129
|
-
readonly configure: HookDescriptor<"configure">;
|
|
130
|
-
readonly start: HookDescriptor<"start">;
|
|
131
|
-
registerRemote(value: RemoteDescriptor
|
|
132
|
-
protected readonly fetchLinks:
|
|
136
|
+
readonly configure: _alepha_core1.HookDescriptor<"configure">;
|
|
137
|
+
readonly start: _alepha_core1.HookDescriptor<"start">;
|
|
138
|
+
registerRemote(value: RemoteDescriptor): Promise<void>;
|
|
139
|
+
protected readonly fetchLinks: _alepha_retry0.RetryDescriptorFn<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
|
|
133
140
|
}
|
|
134
141
|
interface FetchLinksOptions {
|
|
135
142
|
service: string;
|
|
136
143
|
url: string;
|
|
137
144
|
authorization?: string;
|
|
138
145
|
}
|
|
146
|
+
interface ServerRemote {
|
|
147
|
+
url: string;
|
|
148
|
+
name: string;
|
|
149
|
+
proxy: boolean;
|
|
150
|
+
internal: boolean;
|
|
151
|
+
links: (args: {
|
|
152
|
+
authorization?: string;
|
|
153
|
+
}) => Promise<ApiLinksResponse>;
|
|
154
|
+
schema: (args: {
|
|
155
|
+
name: string;
|
|
156
|
+
authorization?: string;
|
|
157
|
+
}) => Promise<any>;
|
|
158
|
+
serviceAccount?: ServiceAccountDescriptor;
|
|
159
|
+
prefix: string;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=RemoteDescriptorProvider.d.ts.map
|
|
139
162
|
//#endregion
|
|
140
163
|
//#region src/providers/ServerLinksProvider.d.ts
|
|
141
164
|
declare class ServerLinksProvider {
|
|
142
165
|
protected readonly alepha: Alepha;
|
|
143
166
|
protected readonly client: LinkProvider;
|
|
144
|
-
protected readonly helper: ActionDescriptorHelper;
|
|
145
167
|
protected readonly remoteProvider: RemoteDescriptorProvider;
|
|
146
|
-
|
|
147
|
-
readonly
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
service: TOptional<TString>;
|
|
168
|
+
readonly onRoute: _alepha_core0$1.HookDescriptor<"configure">;
|
|
169
|
+
readonly links: _alepha_server0.RouteDescriptor<{
|
|
170
|
+
response: _sinclair_typebox0.TObject<{
|
|
171
|
+
prefix: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
172
|
+
links: _sinclair_typebox0.TArray<_sinclair_typebox0.TObject<{
|
|
173
|
+
name: _sinclair_typebox0.TString;
|
|
174
|
+
path: _sinclair_typebox0.TString;
|
|
175
|
+
method: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
176
|
+
group: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
177
|
+
requestBodyType: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
178
|
+
service: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
158
179
|
}>>;
|
|
159
180
|
}>;
|
|
160
181
|
}>;
|
|
161
|
-
readonly schema: RouteDescriptor<{
|
|
162
|
-
params: TObject<{
|
|
163
|
-
name: TString;
|
|
182
|
+
readonly schema: _alepha_server0.RouteDescriptor<{
|
|
183
|
+
params: _sinclair_typebox0.TObject<{
|
|
184
|
+
name: _sinclair_typebox0.TString;
|
|
164
185
|
}>;
|
|
165
|
-
response: TRecord<TString, TAny>;
|
|
186
|
+
response: _sinclair_typebox0.TRecord<_sinclair_typebox0.TString, _sinclair_typebox0.TAny>;
|
|
166
187
|
}>;
|
|
167
188
|
getLinks(options: GetLinksOptions): Promise<ApiLinksResponse>;
|
|
168
189
|
}
|
|
@@ -170,13 +191,12 @@ interface GetLinksOptions {
|
|
|
170
191
|
user?: UserAccountToken;
|
|
171
192
|
authorization?: string;
|
|
172
193
|
}
|
|
194
|
+
//# sourceMappingURL=ServerLinksProvider.d.ts.map
|
|
173
195
|
//#endregion
|
|
174
196
|
//#region src/index.d.ts
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
readonly $services: (alepha: Alepha) => void;
|
|
179
|
-
}
|
|
197
|
+
declare const AlephaServerLinks: _alepha_core0.ModuleDescriptor;
|
|
198
|
+
//# sourceMappingURL=index.d.ts.map
|
|
199
|
+
|
|
180
200
|
//#endregion
|
|
181
|
-
export { $client, $remote, AlephaServerLinks, ClientScope, FetchLinksOptions, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider };
|
|
201
|
+
export { $client, $remote, AlephaServerLinks, ClientScope, FetchLinksOptions, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider, ServerRemote };
|
|
182
202
|
//# sourceMappingURL=index.d.ts.map
|
package/server/metrics.d.ts
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import * as _alepha_core0$1 from "alepha";
|
|
2
|
+
import * as _alepha_core0 from "alepha";
|
|
3
|
+
import { Alepha } from "alepha";
|
|
4
|
+
import * as _alepha_server0 from "alepha/server";
|
|
5
|
+
import { Histogram, Registry } from "prom-client";
|
|
4
6
|
|
|
5
7
|
//#region src/providers/ServerMetricsProvider.d.ts
|
|
8
|
+
declare class ServerMetricsProvider {
|
|
9
|
+
protected readonly register: Registry;
|
|
10
|
+
protected readonly alepha: Alepha;
|
|
11
|
+
protected httpRequestDuration?: Histogram<string>;
|
|
12
|
+
readonly options: ServerMetricsProviderOptions;
|
|
13
|
+
readonly metrics: _alepha_server0.RouteDescriptor<_alepha_server0.RequestConfigSchema>;
|
|
14
|
+
protected readonly onStart: _alepha_core0$1.HookDescriptor<"start">;
|
|
15
|
+
protected readonly onRequest: _alepha_core0$1.HookDescriptor<"server:onRequest">;
|
|
16
|
+
protected readonly onResponse: _alepha_core0$1.HookDescriptor<"server:onResponse">;
|
|
17
|
+
}
|
|
6
18
|
interface ServerMetricsProviderOptions {
|
|
7
19
|
prefix?: string;
|
|
8
20
|
gcDurationBuckets?: number[];
|
|
9
21
|
eventLoopMonitoringPrecision?: number;
|
|
10
22
|
labels?: object;
|
|
11
23
|
}
|
|
12
|
-
|
|
13
|
-
protected readonly register: Registry;
|
|
14
|
-
protected readonly alepha: Alepha;
|
|
15
|
-
readonly options: ServerMetricsProviderOptions;
|
|
16
|
-
readonly metrics: RouteDescriptor;
|
|
17
|
-
protected readonly onStart: HookDescriptor<"start">;
|
|
18
|
-
}
|
|
24
|
+
//# sourceMappingURL=ServerMetricsProvider.d.ts.map
|
|
19
25
|
//#endregion
|
|
20
26
|
//#region src/index.d.ts
|
|
21
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
22
27
|
/**
|
|
23
|
-
* This module provides prometheus metrics for the Alepha server.
|
|
24
|
-
* Metrics are exposed at the `/metrics` endpoint.
|
|
25
|
-
*
|
|
26
|
-
* @see {@link ServerMetricsProvider}
|
|
27
|
-
* @module alepha.server.metrics
|
|
28
|
-
*/
|
|
29
|
-
declare
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
28
|
+
* This module provides prometheus metrics for the Alepha server.
|
|
29
|
+
* Metrics are exposed at the `/metrics` endpoint.
|
|
30
|
+
*
|
|
31
|
+
* @see {@link ServerMetricsProvider}
|
|
32
|
+
* @module alepha.server.metrics
|
|
33
|
+
*/
|
|
34
|
+
declare const AlephaServerMetrics: _alepha_core0.ModuleDescriptor;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
36
|
+
|
|
33
37
|
//#endregion
|
|
34
38
|
export { AlephaServerMetrics, ServerMetricsProvider, ServerMetricsProviderOptions };
|
|
35
39
|
//# sourceMappingURL=index.d.ts.map
|
package/server/multipart.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Alepha, FileLike, HookDescriptor
|
|
1
|
+
import * as _alepha_core0 from "alepha";
|
|
2
|
+
import { Alepha, FileLike, HookDescriptor } from "alepha";
|
|
3
|
+
import { ServerRoute } from "alepha/server";
|
|
3
4
|
import { BusboyConfig } from "@fastify/busboy";
|
|
4
5
|
import { IncomingMessage } from "node:http";
|
|
5
6
|
|
|
6
7
|
//#region src/providers/ServerMultipartProvider.d.ts
|
|
7
8
|
declare class ServerMultipartProvider {
|
|
8
|
-
protected readonly helper: ActionDescriptorHelper;
|
|
9
9
|
protected readonly alepha: Alepha;
|
|
10
10
|
readonly onRequest: HookDescriptor<"server:onRequest">;
|
|
11
11
|
readonly onSend: HookDescriptor<"server:onResponse">;
|
|
@@ -29,18 +29,16 @@ interface HybridFile extends FileLike {
|
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/index.d.ts
|
|
32
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
33
32
|
/**
|
|
34
|
-
* This module provides support for handling multipart/form-data requests.
|
|
35
|
-
* It allows to parse body data containing t.file().
|
|
36
|
-
*
|
|
37
|
-
* @see {@link ServerMultipartProvider}
|
|
38
|
-
* @module alepha.server.multipart
|
|
39
|
-
*/
|
|
40
|
-
declare
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
33
|
+
* This module provides support for handling multipart/form-data requests.
|
|
34
|
+
* It allows to parse body data containing t.file().
|
|
35
|
+
*
|
|
36
|
+
* @see {@link ServerMultipartProvider}
|
|
37
|
+
* @module alepha.server.multipart
|
|
38
|
+
*/
|
|
39
|
+
declare const AlephaServerMultipart: _alepha_core0.ModuleDescriptor;
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
41
|
+
|
|
44
42
|
//#endregion
|
|
45
43
|
export { AlephaServerMultipart, ServerMultipartProvider };
|
|
46
44
|
//# sourceMappingURL=index.d.ts.map
|
package/server/proxy.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _alepha_core0$1 from "alepha";
|
|
2
|
+
import * as _alepha_core0 from "alepha";
|
|
3
|
+
import { Alepha, Async, Descriptor, KIND } from "alepha";
|
|
2
4
|
import { ServerHandler, ServerRequest, ServerRouterProvider } from "alepha/server";
|
|
3
5
|
|
|
4
6
|
//#region src/descriptors/$proxy.d.ts
|
|
5
7
|
declare const $proxy: {
|
|
6
8
|
(options: ProxyDescriptorOptions): ProxyDescriptor;
|
|
7
|
-
[KIND]:
|
|
9
|
+
[KIND]: typeof ProxyDescriptor;
|
|
8
10
|
};
|
|
9
11
|
type ProxyDescriptorOptions = {
|
|
10
12
|
path: string;
|
|
@@ -14,28 +16,31 @@ type ProxyDescriptorOptions = {
|
|
|
14
16
|
afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
|
|
15
17
|
rewrite?: (url: URL) => void;
|
|
16
18
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
[OPTIONS]: ProxyDescriptorOptions;
|
|
20
|
-
}
|
|
19
|
+
declare class ProxyDescriptor extends Descriptor<ProxyDescriptorOptions> {}
|
|
20
|
+
//# sourceMappingURL=$proxy.d.ts.map
|
|
21
21
|
//#endregion
|
|
22
|
-
//#region src/providers/
|
|
23
|
-
declare class
|
|
24
|
-
protected readonly log: Logger;
|
|
22
|
+
//#region src/providers/ServerProxyProvider.d.ts
|
|
23
|
+
declare class ServerProxyProvider {
|
|
24
|
+
protected readonly log: _alepha_core0$1.Logger;
|
|
25
25
|
protected readonly routerProvider: ServerRouterProvider;
|
|
26
26
|
protected readonly alepha: Alepha;
|
|
27
|
-
readonly configure: HookDescriptor<"configure">;
|
|
27
|
+
protected readonly configure: _alepha_core0$1.HookDescriptor<"configure">;
|
|
28
|
+
createProxy(options: ProxyDescriptorOptions): void;
|
|
28
29
|
createProxyHandler(target: string, options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
|
|
29
|
-
proxy(options: ProxyDescriptorOptions): Promise<void>;
|
|
30
30
|
private getRawRequestBody;
|
|
31
31
|
}
|
|
32
|
+
//# sourceMappingURL=ServerProxyProvider.d.ts.map
|
|
32
33
|
//#endregion
|
|
33
34
|
//#region src/index.d.ts
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Plugin for Alepha that provides a proxy server functionality.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link $proxy}
|
|
39
|
+
* @module alepha.server.proxy
|
|
40
|
+
*/
|
|
41
|
+
declare const AlephaServerProxy: _alepha_core0.ModuleDescriptor;
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
43
|
+
|
|
39
44
|
//#endregion
|
|
40
|
-
export { $proxy, AlephaServerProxy, ProxyDescriptor, ProxyDescriptorOptions,
|
|
45
|
+
export { $proxy, AlephaServerProxy, ProxyDescriptor, ProxyDescriptorOptions, ServerProxyProvider };
|
|
41
46
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var m = require('@alepha/server-security');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
4
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () { return m[k]; }
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as _alepha_core0$1 from "alepha";
|
|
2
|
+
import * as _alepha_core0 from "alepha";
|
|
3
|
+
import { Alepha } from "alepha";
|
|
4
|
+
import { JwtProvider, Permission, SecurityProvider, UserAccountToken } from "alepha/security";
|
|
5
|
+
import { FetchOptions } from "alepha/server";
|
|
6
|
+
|
|
7
|
+
//#region src/providers/ServerSecurityProvider.d.ts
|
|
8
|
+
declare class ServerSecurityProvider {
|
|
9
|
+
protected readonly log: _alepha_core0$1.Logger;
|
|
10
|
+
protected readonly securityProvider: SecurityProvider;
|
|
11
|
+
protected readonly jwtProvider: JwtProvider;
|
|
12
|
+
protected readonly alepha: Alepha;
|
|
13
|
+
protected readonly onConfigure: _alepha_core0$1.HookDescriptor<"configure">;
|
|
14
|
+
protected readonly onActionRequest: _alepha_core0$1.HookDescriptor<"action:onRequest">;
|
|
15
|
+
protected readonly onRequest: _alepha_core0$1.HookDescriptor<"server:onRequest">;
|
|
16
|
+
/**
|
|
17
|
+
* Get the user account token for a local action call.
|
|
18
|
+
* There are three possible sources for the user:
|
|
19
|
+
* - `options.user`: the user passed in the options
|
|
20
|
+
* - `"system"`: the system user from the state (you MUST set state `server.security.system.user`)
|
|
21
|
+
* - `"context"`: the user from the request context (you MUST be in an HTTP request context)
|
|
22
|
+
*
|
|
23
|
+
* Priority order: `options.user` > `"system"` > `"context"`.
|
|
24
|
+
*
|
|
25
|
+
* In testing environment, if no user is provided, a test user is created based on the SecurityProvider's roles.
|
|
26
|
+
*/
|
|
27
|
+
protected createUserFromLocalFunctionContext(options: {
|
|
28
|
+
user?: UserAccountToken | "system" | "context";
|
|
29
|
+
}, permission?: Permission): UserAccountToken;
|
|
30
|
+
protected createTestUser(): UserAccountToken;
|
|
31
|
+
protected readonly onClientRequest: _alepha_core0$1.HookDescriptor<"client:onRequest">;
|
|
32
|
+
}
|
|
33
|
+
type ServerRouteSecure = boolean | {
|
|
34
|
+
permissions?: string[];
|
|
35
|
+
roles?: string[];
|
|
36
|
+
realms?: string[];
|
|
37
|
+
organizations?: string[];
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=ServerSecurityProvider.d.ts.map
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/index.d.ts
|
|
42
|
+
declare module "alepha" {
|
|
43
|
+
interface State {
|
|
44
|
+
/**
|
|
45
|
+
* Real (or fake) user account, used for internal actions.
|
|
46
|
+
*
|
|
47
|
+
* If you define this, you assume that all actions are executed by this user by default.
|
|
48
|
+
* > To force a different user, you need to pass it explicitly in the options.
|
|
49
|
+
*/
|
|
50
|
+
"server.security.system.user"?: UserAccountToken;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
declare module "alepha/server" {
|
|
54
|
+
interface ServerRequest<TConfig> {
|
|
55
|
+
user?: UserAccountToken;
|
|
56
|
+
}
|
|
57
|
+
interface ServerActionRequest<TConfig> {
|
|
58
|
+
user: UserAccountToken;
|
|
59
|
+
}
|
|
60
|
+
interface ServerRoute {
|
|
61
|
+
/**
|
|
62
|
+
* If true, the route will be protected by the security provider.
|
|
63
|
+
* All actions are secure by default, but you can disable it for specific actions.
|
|
64
|
+
*/
|
|
65
|
+
secure?: boolean;
|
|
66
|
+
}
|
|
67
|
+
interface ClientRequestOptions extends FetchOptions {
|
|
68
|
+
/**
|
|
69
|
+
* Forward user from the previous request.
|
|
70
|
+
* If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
|
|
71
|
+
* If "context", use the user from the current context (e.g. request).
|
|
72
|
+
*
|
|
73
|
+
* @default "system" is provided, else "context" is used.
|
|
74
|
+
*/
|
|
75
|
+
user?: UserAccountToken | "system" | "context";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Plugin for Alepha Server that provides security features. Based on the Alepha Security module.
|
|
80
|
+
*
|
|
81
|
+
* By default, all $action will be guarded by a permission check.
|
|
82
|
+
*
|
|
83
|
+
* @see {@link ServerSecurityProvider}
|
|
84
|
+
* @module alepha.server.security
|
|
85
|
+
*/
|
|
86
|
+
declare const AlephaServerSecurity: _alepha_core0.ModuleDescriptor;
|
|
87
|
+
//# sourceMappingURL=index.d.ts.map
|
|
88
|
+
//#endregion
|
|
89
|
+
export { AlephaServerSecurity, ServerRouteSecure, ServerSecurityProvider };
|
|
90
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/server-security'
|