@toa.io/extensions.exposition 1.0.0-alpha.21 → 1.0.0-alpha.22
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/components/context.toa.yaml +2 -2
- package/components/identity.basic/manifest.toa.yaml +18 -9
- package/components/identity.basic/operations/authenticate.d.ts +5 -1
- package/components/identity.basic/operations/authenticate.js +2 -2
- package/components/identity.basic/operations/authenticate.js.map +1 -1
- package/components/identity.basic/operations/incept.d.ts +11 -0
- package/components/identity.basic/operations/incept.js +13 -0
- package/components/identity.basic/operations/incept.js.map +1 -0
- package/components/identity.basic/operations/transit.d.ts +3 -3
- package/components/identity.basic/operations/transit.js +5 -3
- package/components/identity.basic/operations/transit.js.map +1 -1
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/types.d.ts +2 -0
- package/components/identity.basic/source/authenticate.ts +12 -5
- package/components/identity.basic/source/incept.ts +22 -0
- package/components/identity.basic/source/transit.ts +7 -5
- package/components/identity.basic/source/types.ts +2 -0
- package/components/identity.federation/manifest.toa.yaml +28 -11
- package/components/identity.federation/operations/authenticate.d.ts +2 -2
- package/components/identity.federation/operations/authenticate.js +6 -5
- package/components/identity.federation/operations/authenticate.js.map +1 -1
- package/components/identity.federation/operations/incept.d.ts +11 -0
- package/components/identity.federation/operations/{create.js → incept.js} +6 -7
- package/components/identity.federation/operations/incept.js.map +1 -0
- package/components/identity.federation/operations/lib/jwt.js +3 -3
- package/components/identity.federation/operations/lib/jwt.js.map +1 -1
- package/components/identity.federation/operations/schemas.d.ts +7 -3
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/operations/types.d.ts +5 -0
- package/components/identity.federation/source/authenticate.ts +9 -6
- package/components/identity.federation/source/{create.ts → incept.ts} +10 -9
- package/components/identity.federation/source/lib/jwt.test.ts +2 -2
- package/components/identity.federation/source/lib/jwt.ts +3 -3
- package/components/identity.federation/source/schemas.ts +7 -3
- package/components/identity.federation/source/types.ts +6 -0
- package/components/identity.tokens/manifest.toa.yaml +7 -1
- package/components/identity.tokens/operations/authenticate.d.ts +2 -2
- package/components/identity.tokens/operations/authenticate.js +5 -2
- package/components/identity.tokens/operations/authenticate.js.map +1 -1
- package/components/identity.tokens/operations/decrypt.js +1 -0
- package/components/identity.tokens/operations/decrypt.js.map +1 -1
- package/components/identity.tokens/operations/encrypt.js +1 -0
- package/components/identity.tokens/operations/encrypt.js.map +1 -1
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/operations/types.d.ts +7 -0
- package/components/identity.tokens/source/authenticate.test.ts +11 -4
- package/components/identity.tokens/source/authenticate.ts +7 -3
- package/components/identity.tokens/source/decrypt.test.ts +5 -3
- package/components/identity.tokens/source/decrypt.ts +9 -8
- package/components/identity.tokens/source/encrypt.test.ts +4 -1
- package/components/identity.tokens/source/encrypt.ts +1 -0
- package/components/identity.tokens/source/types.ts +8 -0
- package/documentation/authorities.md +53 -0
- package/documentation/components.md +3 -3
- package/documentation/identity.md +17 -22
- package/documentation/vary.md +5 -11
- package/features/access.feature +55 -7
- package/features/annotation.feature +1 -0
- package/features/authorities.basic.feature +140 -0
- package/features/authorities.feature +32 -0
- package/features/authorities.federation.feature +99 -0
- package/features/authorities.tokens.feature +118 -0
- package/features/body.feature +2 -0
- package/features/cache.feature +39 -5
- package/features/cors.feature +4 -0
- package/features/directives.feature +3 -0
- package/features/dynamic.feature +4 -0
- package/features/errors.feature +12 -1
- package/features/etag.feature +6 -0
- package/features/identity.bans.feature +12 -3
- package/features/identity.basic.feature +34 -15
- package/features/identity.feature +7 -2
- package/features/identity.federation.feature +14 -4
- package/features/identity.roles.feature +29 -17
- package/features/identity.tokens.feature +18 -6
- package/features/io.feature +9 -0
- package/features/octets.entries.feature +8 -0
- package/features/octets.feature +22 -0
- package/features/octets.meta.feature +3 -0
- package/features/octets.workflows.feature +13 -0
- package/features/queries.feature +8 -0
- package/features/require.feature +3 -0
- package/features/response.feature +5 -2
- package/features/routes.feature +7 -0
- package/features/steps/Gateway.ts +23 -6
- package/features/streams.feature +1 -0
- package/features/timing.feature +3 -0
- package/features/vary.feature +49 -0
- package/package.json +7 -7
- package/readme.md +19 -14
- package/schemas/annotation.cos.yaml +1 -1
- package/source/Annotation.ts +3 -3
- package/source/Endpoint.ts +1 -1
- package/source/Factory.ts +8 -10
- package/source/Gateway.ts +2 -6
- package/source/HTTP/Context.ts +3 -1
- package/source/HTTP/Server.ts +23 -26
- package/source/HTTP/exceptions.ts +6 -0
- package/source/Query.ts +9 -5
- package/source/deployment.ts +25 -21
- package/source/directives/auth/Authorization.ts +18 -8
- package/source/directives/auth/Incept.ts +2 -1
- package/source/directives/vary/embeddings/Authority.ts +8 -0
- package/source/directives/vary/embeddings/index.ts +3 -1
- package/source/schemas.ts +1 -1
- package/transpiled/Annotation.d.ts +3 -3
- package/transpiled/Endpoint.js +1 -1
- package/transpiled/Endpoint.js.map +1 -1
- package/transpiled/Factory.js +9 -8
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Context.d.ts +2 -1
- package/transpiled/HTTP/Context.js +3 -1
- package/transpiled/HTTP/Context.js.map +1 -1
- package/transpiled/HTTP/Server.d.ts +8 -1
- package/transpiled/HTTP/Server.js +14 -20
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/HTTP/exceptions.d.ts +3 -0
- package/transpiled/HTTP/exceptions.js +7 -1
- package/transpiled/HTTP/exceptions.js.map +1 -1
- package/transpiled/Query.js +2 -2
- package/transpiled/Query.js.map +1 -1
- package/transpiled/deployment.d.ts +1 -1
- package/transpiled/deployment.js +21 -19
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/directives/auth/Authorization.js +9 -4
- package/transpiled/directives/auth/Authorization.js.map +1 -1
- package/transpiled/directives/auth/Incept.js +2 -1
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/directives/vary/embeddings/Authority.d.ts +5 -0
- package/transpiled/directives/vary/embeddings/Authority.js +10 -0
- package/transpiled/directives/vary/embeddings/Authority.js.map +1 -0
- package/transpiled/directives/vary/embeddings/index.js +3 -1
- package/transpiled/directives/vary/embeddings/index.js.map +1 -1
- package/transpiled/schemas.d.ts +1 -1
- package/transpiled/schemas.js +2 -2
- package/transpiled/schemas.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/create.d.ts +0 -10
- package/components/identity.basic/operations/create.js +0 -10
- package/components/identity.basic/operations/create.js.map +0 -1
- package/components/identity.basic/source/create.ts +0 -18
- package/components/identity.federation/operations/create.d.ts +0 -10
- package/components/identity.federation/operations/create.js.map +0 -1
- package/source/HTTP/Server.test.ts +0 -126
|
@@ -23,6 +23,7 @@ Feature: Octets storage workflows
|
|
|
23
23
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
24
24
|
"""
|
|
25
25
|
POST / HTTP/1.1
|
|
26
|
+
host: nex.toa.io
|
|
26
27
|
accept: application/yaml
|
|
27
28
|
content-type: application/octet-stream
|
|
28
29
|
"""
|
|
@@ -49,6 +50,7 @@ Feature: Octets storage workflows
|
|
|
49
50
|
When the following request is received:
|
|
50
51
|
"""
|
|
51
52
|
GET /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
|
|
53
|
+
host: nex.toa.io
|
|
52
54
|
accept: application/vnd.toa.octets.entry+yaml
|
|
53
55
|
"""
|
|
54
56
|
Then the following reply is sent:
|
|
@@ -67,6 +69,7 @@ Feature: Octets storage workflows
|
|
|
67
69
|
When the following request is received:
|
|
68
70
|
"""
|
|
69
71
|
GET /10cf16b458f759e0d617f2f3d83599ff.hello.png HTTP/1.1
|
|
72
|
+
host: nex.toa.io
|
|
70
73
|
"""
|
|
71
74
|
Then the stream equals to `lenna.png` is sent with the following headers:
|
|
72
75
|
"""
|
|
@@ -92,6 +95,7 @@ Feature: Octets storage workflows
|
|
|
92
95
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
93
96
|
"""
|
|
94
97
|
POST / HTTP/1.1
|
|
98
|
+
host: nex.toa.io
|
|
95
99
|
accept: application/yaml
|
|
96
100
|
content-type: application/octet-stream
|
|
97
101
|
"""
|
|
@@ -134,6 +138,7 @@ Feature: Octets storage workflows
|
|
|
134
138
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
135
139
|
"""
|
|
136
140
|
POST / HTTP/1.1
|
|
141
|
+
host: nex.toa.io
|
|
137
142
|
content-type: application/octet-stream
|
|
138
143
|
"""
|
|
139
144
|
Then the following reply is sent:
|
|
@@ -143,6 +148,7 @@ Feature: Octets storage workflows
|
|
|
143
148
|
When the following request is received:
|
|
144
149
|
"""
|
|
145
150
|
DELETE /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
|
|
151
|
+
host: nex.toa.io
|
|
146
152
|
accept: application/yaml
|
|
147
153
|
"""
|
|
148
154
|
Then the following reply is sent:
|
|
@@ -157,6 +163,7 @@ Feature: Octets storage workflows
|
|
|
157
163
|
When the following request is received:
|
|
158
164
|
"""
|
|
159
165
|
GET /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
|
|
166
|
+
host: nex.toa.io
|
|
160
167
|
"""
|
|
161
168
|
Then the following reply is sent:
|
|
162
169
|
"""
|
|
@@ -183,6 +190,7 @@ Feature: Octets storage workflows
|
|
|
183
190
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
184
191
|
"""
|
|
185
192
|
POST / HTTP/1.1
|
|
193
|
+
host: nex.toa.io
|
|
186
194
|
content-type: application/octet-stream
|
|
187
195
|
"""
|
|
188
196
|
Then the following reply is sent:
|
|
@@ -192,6 +200,7 @@ Feature: Octets storage workflows
|
|
|
192
200
|
When the following request is received:
|
|
193
201
|
"""
|
|
194
202
|
DELETE /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
|
|
203
|
+
host: nex.toa.io
|
|
195
204
|
accept: application/yaml
|
|
196
205
|
"""
|
|
197
206
|
Then the following reply is sent:
|
|
@@ -209,6 +218,7 @@ Feature: Octets storage workflows
|
|
|
209
218
|
When the following request is received:
|
|
210
219
|
"""
|
|
211
220
|
GET /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
|
|
221
|
+
host: nex.toa.io
|
|
212
222
|
"""
|
|
213
223
|
Then the following reply is sent:
|
|
214
224
|
"""
|
|
@@ -231,6 +241,7 @@ Feature: Octets storage workflows
|
|
|
231
241
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
232
242
|
"""
|
|
233
243
|
POST /hello/world/ HTTP/1.1
|
|
244
|
+
host: nex.toa.io
|
|
234
245
|
accept: application/yaml
|
|
235
246
|
content-type: application/octet-stream
|
|
236
247
|
"""
|
|
@@ -265,6 +276,7 @@ Feature: Octets storage workflows
|
|
|
265
276
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
266
277
|
"""
|
|
267
278
|
POST / HTTP/1.1
|
|
279
|
+
host: nex.toa.io
|
|
268
280
|
content-type: application/octet-stream
|
|
269
281
|
"""
|
|
270
282
|
Then the following reply is sent:
|
|
@@ -274,6 +286,7 @@ Feature: Octets storage workflows
|
|
|
274
286
|
When the following request is received:
|
|
275
287
|
"""
|
|
276
288
|
DELETE /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
|
|
289
|
+
host: nex.toa.io
|
|
277
290
|
accept: application/yaml
|
|
278
291
|
"""
|
|
279
292
|
Then the following reply is sent:
|
package/features/queries.feature
CHANGED
|
@@ -19,6 +19,7 @@ Feature: Queries
|
|
|
19
19
|
When the following request is received:
|
|
20
20
|
"""
|
|
21
21
|
GET /pots/pot/?id=99988d785d7d445cad45dbf8531f560b HTTP/1.1
|
|
22
|
+
host: nex.toa.io
|
|
22
23
|
accept: application/yaml
|
|
23
24
|
"""
|
|
24
25
|
Then the following reply is sent:
|
|
@@ -42,6 +43,7 @@ Feature: Queries
|
|
|
42
43
|
When the following request is received:
|
|
43
44
|
"""
|
|
44
45
|
GET /pots/?criteria=volume<300&limit=10 HTTP/1.1
|
|
46
|
+
host: nex.toa.io
|
|
45
47
|
accept: application/yaml
|
|
46
48
|
"""
|
|
47
49
|
Then the following reply is sent:
|
|
@@ -68,6 +70,7 @@ Feature: Queries
|
|
|
68
70
|
When the following request is received:
|
|
69
71
|
"""
|
|
70
72
|
GET /pots/?omit=1&limit=2 HTTP/1.1
|
|
73
|
+
host: nex.toa.io
|
|
71
74
|
accept: application/yaml
|
|
72
75
|
"""
|
|
73
76
|
Then the following reply is sent:
|
|
@@ -94,6 +97,7 @@ Feature: Queries
|
|
|
94
97
|
When the following request is received:
|
|
95
98
|
"""
|
|
96
99
|
GET /pots/?sort=volume:desc&limit=2 HTTP/1.1
|
|
100
|
+
host: nex.toa.io
|
|
97
101
|
accept: application/yaml
|
|
98
102
|
"""
|
|
99
103
|
Then the following reply is sent:
|
|
@@ -120,6 +124,7 @@ Feature: Queries
|
|
|
120
124
|
When the following request is received:
|
|
121
125
|
"""
|
|
122
126
|
GET /pots/99988d785d7d445cad45dbf8531f560b/ HTTP/1.1
|
|
127
|
+
host: nex.toa.io
|
|
123
128
|
accept: application/yaml
|
|
124
129
|
"""
|
|
125
130
|
Then the following reply is sent:
|
|
@@ -146,6 +151,7 @@ Feature: Queries
|
|
|
146
151
|
When the following request is received:
|
|
147
152
|
"""
|
|
148
153
|
GET /pots/big/ HTTP/1.1
|
|
154
|
+
host: nex.toa.io
|
|
149
155
|
accept: application/yaml
|
|
150
156
|
"""
|
|
151
157
|
Then the following reply is sent:
|
|
@@ -175,6 +181,7 @@ Feature: Queries
|
|
|
175
181
|
When the following request is received:
|
|
176
182
|
"""
|
|
177
183
|
GET /pots/big/?criteria=temperature>50 HTTP/1.1
|
|
184
|
+
host: nex.toa.io
|
|
178
185
|
accept: application/yaml
|
|
179
186
|
"""
|
|
180
187
|
Then the following reply is sent:
|
|
@@ -204,6 +211,7 @@ Feature: Queries
|
|
|
204
211
|
When the following request is received:
|
|
205
212
|
"""
|
|
206
213
|
GET /pots/hottest2/ HTTP/1.1
|
|
214
|
+
host: nex.toa.io
|
|
207
215
|
accept: application/yaml
|
|
208
216
|
"""
|
|
209
217
|
Then the following reply is sent:
|
package/features/require.feature
CHANGED
|
@@ -17,6 +17,7 @@ Feature: Request requirements
|
|
|
17
17
|
When the following request is received:
|
|
18
18
|
"""
|
|
19
19
|
POST /pots/ HTTP/1.1
|
|
20
|
+
host: nex.toa.io
|
|
20
21
|
content-type: application/yaml
|
|
21
22
|
accept: application/yaml
|
|
22
23
|
|
|
@@ -33,6 +34,7 @@ Feature: Request requirements
|
|
|
33
34
|
When the following request is received:
|
|
34
35
|
"""
|
|
35
36
|
PUT /pots/<variant>/${{ id }}/ HTTP/1.1
|
|
37
|
+
host: nex.toa.io
|
|
36
38
|
content-type: application/yaml
|
|
37
39
|
accept: text/plain
|
|
38
40
|
|
|
@@ -48,6 +50,7 @@ Feature: Request requirements
|
|
|
48
50
|
When the following request is received:
|
|
49
51
|
"""
|
|
50
52
|
PUT /pots/<variant>/${{ id }}/ HTTP/1.1
|
|
53
|
+
host: nex.toa.io
|
|
51
54
|
content-type: application/yaml
|
|
52
55
|
accept: text/plain
|
|
53
56
|
if-match: ${{ etag }}
|
|
@@ -13,6 +13,7 @@ Feature: Response
|
|
|
13
13
|
When the following request is received:
|
|
14
14
|
"""
|
|
15
15
|
GET / HTTP/1.1
|
|
16
|
+
host: nex.toa.io
|
|
16
17
|
accept: application/json
|
|
17
18
|
"""
|
|
18
19
|
Then the following reply is sent:
|
|
@@ -35,11 +36,12 @@ Feature: Response
|
|
|
35
36
|
When the following request is received:
|
|
36
37
|
"""
|
|
37
38
|
GET /echo/ HTTP/1.1
|
|
39
|
+
host: nex.toa.io
|
|
38
40
|
accept: application/yaml
|
|
39
41
|
"""
|
|
40
42
|
Then the following reply is sent:
|
|
41
43
|
"""
|
|
42
|
-
|
|
44
|
+
422 Unprocessable Entity
|
|
43
45
|
content-type: application/yaml
|
|
44
46
|
|
|
45
47
|
code: CODE
|
|
@@ -57,11 +59,12 @@ Feature: Response
|
|
|
57
59
|
When the following request is received:
|
|
58
60
|
"""
|
|
59
61
|
GET /echo/ HTTP/1.1
|
|
62
|
+
host: nex.toa.io
|
|
60
63
|
accept: application/msgpack
|
|
61
64
|
"""
|
|
62
65
|
Then the following reply is sent:
|
|
63
66
|
"""
|
|
64
|
-
|
|
67
|
+
422 Unprocessable Entity
|
|
65
68
|
content-type: application/msgpack
|
|
66
69
|
"""
|
|
67
70
|
And response body contains MessagePack-encoded value:
|
package/features/routes.feature
CHANGED
|
@@ -18,6 +18,7 @@ Feature: Routes
|
|
|
18
18
|
When the following request is received:
|
|
19
19
|
"""
|
|
20
20
|
GET /basic/greeter<route> HTTP/1.1
|
|
21
|
+
host: nex.toa.io
|
|
21
22
|
accept: text/plain
|
|
22
23
|
"""
|
|
23
24
|
Then the following reply is sent:
|
|
@@ -42,6 +43,7 @@ Feature: Routes
|
|
|
42
43
|
When the following request is received:
|
|
43
44
|
"""
|
|
44
45
|
GET /greeter/ HTTP/1.1
|
|
46
|
+
host: nex.toa.io
|
|
45
47
|
accept: text/plain
|
|
46
48
|
"""
|
|
47
49
|
Then the following reply is sent:
|
|
@@ -65,6 +67,7 @@ Feature: Routes
|
|
|
65
67
|
When the following request is received:
|
|
66
68
|
"""
|
|
67
69
|
GET /greeter/baz/ HTTP/1.1
|
|
70
|
+
host: nex.toa.io
|
|
68
71
|
accept: text/plain
|
|
69
72
|
"""
|
|
70
73
|
Then the following reply is sent:
|
|
@@ -76,6 +79,7 @@ Feature: Routes
|
|
|
76
79
|
When the following request is received:
|
|
77
80
|
"""
|
|
78
81
|
GET /greeter/baz/qux/ HTTP/1.1
|
|
82
|
+
host: nex.toa.io
|
|
79
83
|
"""
|
|
80
84
|
Then the following reply is sent:
|
|
81
85
|
"""
|
|
@@ -84,6 +88,7 @@ Feature: Routes
|
|
|
84
88
|
When the following request is received:
|
|
85
89
|
"""
|
|
86
90
|
GET /greeter/foo/baz/bar/ HTTP/1.1
|
|
91
|
+
host: nex.toa.io
|
|
87
92
|
accept: text/plain
|
|
88
93
|
"""
|
|
89
94
|
Then the following reply is sent:
|
|
@@ -112,6 +117,7 @@ Feature: Routes
|
|
|
112
117
|
When the following request is received:
|
|
113
118
|
"""
|
|
114
119
|
GET /users/properties/b5534021e30042259badffbd1831e472/ HTTP/1.1
|
|
120
|
+
host: nex.toa.io
|
|
115
121
|
accept: application/yaml
|
|
116
122
|
"""
|
|
117
123
|
Then the following reply is sent:
|
|
@@ -123,6 +129,7 @@ Feature: Routes
|
|
|
123
129
|
When the following request is received:
|
|
124
130
|
"""
|
|
125
131
|
POST /users/ HTTP/1.1
|
|
132
|
+
host: nex.toa.io
|
|
126
133
|
content-type: application/yaml
|
|
127
134
|
|
|
128
135
|
name: Alice
|
|
@@ -6,6 +6,7 @@ import { encode, timeout } from '@toa.io/generic'
|
|
|
6
6
|
import { Factory } from '../../source'
|
|
7
7
|
import * as syntax from '../../source/RTD/syntax'
|
|
8
8
|
import { shortcuts } from '../../source/Directive'
|
|
9
|
+
import type * as http from '../../source/HTTP'
|
|
9
10
|
|
|
10
11
|
let instance: Connector | null = null
|
|
11
12
|
|
|
@@ -23,11 +24,19 @@ export class Gateway {
|
|
|
23
24
|
process.env.TOA_EXPOSITION = encode(tree)
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const { debug, trace, authorities } = annotation
|
|
28
|
+
const properties = Object.assign({}, DEFAULT_PROPERTIES)
|
|
28
29
|
|
|
29
|
-
if (
|
|
30
|
-
|
|
30
|
+
if (debug !== undefined)
|
|
31
|
+
properties.debug = debug
|
|
32
|
+
|
|
33
|
+
if (trace !== undefined)
|
|
34
|
+
properties.trace = trace
|
|
35
|
+
|
|
36
|
+
if (authorities !== undefined)
|
|
37
|
+
properties.authorities = authorities
|
|
38
|
+
|
|
39
|
+
process.env.TOA_EXPOSITION_PROPERTIES = encode(properties)
|
|
31
40
|
|
|
32
41
|
await Gateway.stop()
|
|
33
42
|
|
|
@@ -54,7 +63,8 @@ export class Gateway {
|
|
|
54
63
|
if (instance !== null)
|
|
55
64
|
return
|
|
56
65
|
|
|
57
|
-
process.env.TOA_EXPOSITION ??=
|
|
66
|
+
process.env.TOA_EXPOSITION ??= DEFAULT_TREE
|
|
67
|
+
process.env.TOA_EXPOSITION_PROPERTIES ??= encode(DEFAULT_PROPERTIES)
|
|
58
68
|
|
|
59
69
|
this.writeConfiguration()
|
|
60
70
|
|
|
@@ -76,6 +86,7 @@ export class Gateway {
|
|
|
76
86
|
return
|
|
77
87
|
|
|
78
88
|
delete process.env.TOA_EXPOSITION
|
|
89
|
+
delete process.env.TOA_EXPOSITION_PROPERTIES
|
|
79
90
|
|
|
80
91
|
await Gateway.stop()
|
|
81
92
|
}
|
|
@@ -96,7 +107,7 @@ export class Gateway {
|
|
|
96
107
|
}
|
|
97
108
|
}
|
|
98
109
|
|
|
99
|
-
const
|
|
110
|
+
const DEFAULT_TREE = encode({
|
|
100
111
|
routes: [],
|
|
101
112
|
methods: [],
|
|
102
113
|
directives: [
|
|
@@ -108,6 +119,12 @@ const DEFAULT_ANNOTATION = encode({
|
|
|
108
119
|
]
|
|
109
120
|
} satisfies syntax.Node)
|
|
110
121
|
|
|
122
|
+
const DEFAULT_PROPERTIES: Partial<http.Options> = {
|
|
123
|
+
authorities: {
|
|
124
|
+
nex: 'nex.toa.io'
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
111
128
|
const DEFAULT_CONFIGURATION: Record<string, object> = {
|
|
112
129
|
'identity.tokens': {
|
|
113
130
|
key0: 'k3.local.pIZT8-9Fa6U_QtfQHOSStfGtmyzPINyKQq2Xk-hd7vA'
|
package/features/streams.feature
CHANGED
package/features/timing.feature
CHANGED
|
@@ -12,6 +12,7 @@ Feature: Server timing
|
|
|
12
12
|
When the following request is received:
|
|
13
13
|
"""
|
|
14
14
|
POST /pots/ HTTP/1.1
|
|
15
|
+
host: nex.toa.io
|
|
15
16
|
content-type: application/yaml
|
|
16
17
|
|
|
17
18
|
title: Hello
|
|
@@ -30,6 +31,7 @@ Feature: Server timing
|
|
|
30
31
|
When the following request is received:
|
|
31
32
|
"""
|
|
32
33
|
POST /pots/ HTTP/1.1
|
|
34
|
+
host: nex.toa.io
|
|
33
35
|
content-type: application/yaml
|
|
34
36
|
|
|
35
37
|
title: Hello
|
|
@@ -56,6 +58,7 @@ Feature: Server timing
|
|
|
56
58
|
When the stream of `lenna.png` is received with the following headers:
|
|
57
59
|
"""
|
|
58
60
|
POST / HTTP/1.1
|
|
61
|
+
host: nex.toa.io
|
|
59
62
|
content-type: application/octet-stream
|
|
60
63
|
"""
|
|
61
64
|
# to debug, break it and look at the console
|
package/features/vary.feature
CHANGED
|
@@ -15,6 +15,7 @@ Feature: The Vary directive family
|
|
|
15
15
|
When the following request is received:
|
|
16
16
|
"""
|
|
17
17
|
GET /echo/ HTTP/1.1
|
|
18
|
+
host: nex.toa.io
|
|
18
19
|
accept: application/yaml
|
|
19
20
|
accept-language: <accept>
|
|
20
21
|
"""
|
|
@@ -54,6 +55,7 @@ Feature: The Vary directive family
|
|
|
54
55
|
When the following request is received:
|
|
55
56
|
"""
|
|
56
57
|
GET /echo/ HTTP/1.1
|
|
58
|
+
host: nex.toa.io
|
|
57
59
|
accept: application/yaml
|
|
58
60
|
accept-language: fr
|
|
59
61
|
"""
|
|
@@ -78,6 +80,7 @@ Feature: The Vary directive family
|
|
|
78
80
|
When the following request is received:
|
|
79
81
|
"""
|
|
80
82
|
GET /echo/ HTTP/1.1
|
|
83
|
+
host: nex.toa.io
|
|
81
84
|
accept: application/yaml
|
|
82
85
|
foo: bar
|
|
83
86
|
"""
|
|
@@ -104,6 +107,7 @@ Feature: The Vary directive family
|
|
|
104
107
|
When the following request is received:
|
|
105
108
|
"""
|
|
106
109
|
GET /echo/ HTTP/1.1
|
|
110
|
+
host: nex.toa.io
|
|
107
111
|
accept: application/yaml
|
|
108
112
|
foo: bar
|
|
109
113
|
"""
|
|
@@ -134,6 +138,7 @@ Feature: The Vary directive family
|
|
|
134
138
|
When the following request is received:
|
|
135
139
|
"""
|
|
136
140
|
GET /echo/ HTTP/1.1
|
|
141
|
+
host: nex.toa.io
|
|
137
142
|
accept: application/yaml
|
|
138
143
|
<header>: <value>
|
|
139
144
|
"""
|
|
@@ -165,6 +170,7 @@ Feature: The Vary directive family
|
|
|
165
170
|
When the following request is received:
|
|
166
171
|
"""
|
|
167
172
|
GET /echo/Ken/ HTTP/1.1
|
|
173
|
+
host: nex.toa.io
|
|
168
174
|
accept: text/plain
|
|
169
175
|
"""
|
|
170
176
|
Then the following reply is sent:
|
|
@@ -193,6 +199,7 @@ Feature: The Vary directive family
|
|
|
193
199
|
When the following request is received:
|
|
194
200
|
"""
|
|
195
201
|
OPTIONS / HTTP/1.1
|
|
202
|
+
host: nex.toa.io
|
|
196
203
|
origin: https://example.com
|
|
197
204
|
access-control-request-headers: whatever
|
|
198
205
|
"""
|
|
@@ -201,3 +208,45 @@ Feature: The Vary directive family
|
|
|
201
208
|
204 No Content
|
|
202
209
|
access-control-allow-headers: accept, authorization, content-type, etag, if-match, if-none-match, accept-language, foo, bar
|
|
203
210
|
"""
|
|
211
|
+
|
|
212
|
+
Scenario: Embedding authority
|
|
213
|
+
Given the annotation:
|
|
214
|
+
"""yaml
|
|
215
|
+
authorities:
|
|
216
|
+
one: the.one.com
|
|
217
|
+
two: the.two.com
|
|
218
|
+
"""
|
|
219
|
+
Given the `echo` is running with the following manifest:
|
|
220
|
+
"""yaml
|
|
221
|
+
exposition:
|
|
222
|
+
/:
|
|
223
|
+
io:output: true
|
|
224
|
+
GET:
|
|
225
|
+
vary:embed:
|
|
226
|
+
name: authority
|
|
227
|
+
endpoint: compute
|
|
228
|
+
"""
|
|
229
|
+
When the following request is received:
|
|
230
|
+
"""
|
|
231
|
+
GET /echo/ HTTP/1.1
|
|
232
|
+
host: the.one.com
|
|
233
|
+
accept: text/plain
|
|
234
|
+
"""
|
|
235
|
+
Then the following reply is sent:
|
|
236
|
+
"""
|
|
237
|
+
200 OK
|
|
238
|
+
|
|
239
|
+
Hello one
|
|
240
|
+
"""
|
|
241
|
+
When the following request is received:
|
|
242
|
+
"""
|
|
243
|
+
GET /echo/ HTTP/1.1
|
|
244
|
+
host: the.two.com
|
|
245
|
+
accept: text/plain
|
|
246
|
+
"""
|
|
247
|
+
Then the following reply is sent:
|
|
248
|
+
"""
|
|
249
|
+
200 OK
|
|
250
|
+
|
|
251
|
+
Hello two
|
|
252
|
+
"""
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/extensions.exposition",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.22",
|
|
4
4
|
"description": "Toa Exposition",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
21
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
22
|
-
"@toa.io/schemas": "1.0.0-alpha.
|
|
20
|
+
"@toa.io/core": "1.0.0-alpha.22",
|
|
21
|
+
"@toa.io/generic": "1.0.0-alpha.22",
|
|
22
|
+
"@toa.io/schemas": "1.0.0-alpha.22",
|
|
23
23
|
"bcryptjs": "2.4.3",
|
|
24
24
|
"error-value": "0.3.0",
|
|
25
25
|
"js-yaml": "4.1.0",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"features:security": "cucumber-js --tags @security"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@toa.io/agent": "1.0.0-alpha.
|
|
49
|
-
"@toa.io/extensions.storages": "1.0.0-alpha.
|
|
48
|
+
"@toa.io/agent": "1.0.0-alpha.22",
|
|
49
|
+
"@toa.io/extensions.storages": "1.0.0-alpha.22",
|
|
50
50
|
"@types/bcryptjs": "2.4.3",
|
|
51
51
|
"@types/cors": "2.8.13",
|
|
52
52
|
"@types/negotiator": "0.6.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "5bc67b81c4c5fbf92db037c805fba84a571ed24b"
|
|
55
55
|
}
|
package/readme.md
CHANGED
|
@@ -20,7 +20,8 @@ exposition:
|
|
|
20
20
|
# context.toa.yaml
|
|
21
21
|
|
|
22
22
|
exposition:
|
|
23
|
-
|
|
23
|
+
authorities:
|
|
24
|
+
example: api.example.com
|
|
24
25
|
```
|
|
25
26
|
|
|
26
27
|
```http
|
|
@@ -117,33 +118,36 @@ The Exposition annotation declares options for its deployment.
|
|
|
117
118
|
```yaml
|
|
118
119
|
annotations:
|
|
119
120
|
'@toa.io/extensions.exposition':
|
|
120
|
-
|
|
121
|
+
authorities:
|
|
122
|
+
example: the.example.com
|
|
121
123
|
```
|
|
122
124
|
|
|
123
125
|
A shortcut is also available.
|
|
124
126
|
|
|
125
127
|
```yaml
|
|
126
128
|
exposition:
|
|
127
|
-
|
|
129
|
+
authorities:
|
|
130
|
+
example: the.example.com
|
|
128
131
|
```
|
|
129
132
|
|
|
130
|
-
| Option |
|
|
131
|
-
|
|
132
|
-
| `
|
|
133
|
-
| `class` |
|
|
134
|
-
| `annotations` |
|
|
135
|
-
| `debug` |
|
|
136
|
-
| `trace` |
|
|
133
|
+
| Option | Description |
|
|
134
|
+
|---------------|-------------------------------------------------------------------------------------------------------------------|
|
|
135
|
+
| `auhorities` | Mapping of authority identifiers to domain names. See [Authorities](documentation/authorities.md). |
|
|
136
|
+
| `class` | Ingress class. |
|
|
137
|
+
| `annotations` | Ingress annotations. |
|
|
138
|
+
| `debug` | Output server errors. Default `false`. |
|
|
139
|
+
| `trace` | Output [server timing](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing). Default `false`. |
|
|
137
140
|
|
|
138
141
|
### Context resources
|
|
139
142
|
|
|
140
|
-
Exposition
|
|
143
|
+
Exposition annotation can contain [resource declaration](documentation/tree.md) under the `/` key.
|
|
141
144
|
|
|
142
145
|
```yaml
|
|
143
146
|
# context.toa.yaml
|
|
144
147
|
|
|
145
148
|
exposition:
|
|
146
|
-
|
|
149
|
+
authorities:
|
|
150
|
+
example: the.example.com
|
|
147
151
|
/:
|
|
148
152
|
/code:
|
|
149
153
|
GET:
|
|
@@ -162,8 +166,9 @@ If component resource branch conflicts with an annotation, the annotation takes
|
|
|
162
166
|
|
|
163
167
|
```yaml
|
|
164
168
|
exposition:
|
|
165
|
-
|
|
166
|
-
|
|
169
|
+
authorities:
|
|
170
|
+
example: the.example.com
|
|
171
|
+
example@staging: the.example.dev
|
|
167
172
|
class: alb
|
|
168
173
|
debug@staging: true
|
|
169
174
|
annotations:
|
package/source/Annotation.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface Annotation {
|
|
2
|
-
|
|
2
|
+
authorities: Record<string, string>
|
|
3
3
|
class?: string
|
|
4
4
|
annotations?: Record<string, string>
|
|
5
|
-
debug
|
|
6
|
-
trace
|
|
5
|
+
debug?: boolean
|
|
6
|
+
trace?: boolean
|
|
7
7
|
'/'?: object // parsed and validated by RTD.syntax.parse
|
|
8
8
|
}
|
package/source/Endpoint.ts
CHANGED
|
@@ -28,7 +28,7 @@ export class Endpoint implements RTD.Endpoint {
|
|
|
28
28
|
const reply = await this.remote.invoke(this.endpoint, request)
|
|
29
29
|
|
|
30
30
|
if (reply instanceof Error)
|
|
31
|
-
throw new http.
|
|
31
|
+
throw new http.UnprocessableEntity(reply)
|
|
32
32
|
|
|
33
33
|
const message: http.OutgoingMessage = {}
|
|
34
34
|
|
package/source/Factory.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
2
|
+
import { decode } from '@toa.io/generic'
|
|
1
3
|
import { Tenant } from './Tenant'
|
|
2
4
|
import { Gateway } from './Gateway'
|
|
3
5
|
import { Remotes } from './Remotes'
|
|
4
6
|
import { Tree, syntax } from './RTD'
|
|
5
|
-
import { Server } from './HTTP'
|
|
6
7
|
import { EndpointsFactory } from './Endpoint'
|
|
7
8
|
import { families, interceptors } from './directives'
|
|
8
9
|
import { DirectivesFactory } from './Directive'
|
|
9
10
|
import { Composition } from './Composition'
|
|
10
11
|
import * as root from './root'
|
|
11
12
|
import { Interception } from './Interception'
|
|
13
|
+
import * as http from './HTTP'
|
|
12
14
|
import type { Broadcast } from './Gateway'
|
|
13
15
|
import type { Connector, Locator, extensions } from '@toa.io/core'
|
|
14
16
|
|
|
@@ -26,16 +28,12 @@ export class Factory implements extensions.Factory {
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
public service (): Connector | null {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const broadcast: Broadcast = this.boot.bindings.broadcast(CHANNEL)
|
|
32
|
-
|
|
33
|
-
const server = Server.create({
|
|
34
|
-
methods: syntax.verbs,
|
|
35
|
-
debug,
|
|
36
|
-
trace
|
|
37
|
-
})
|
|
31
|
+
assert.ok(process.env.TOA_EXPOSITION_PROPERTIES,
|
|
32
|
+
'TOA_EXPOSITION_PROPERTIES is undefined')
|
|
38
33
|
|
|
34
|
+
const options = decode<http.Options>(process.env.TOA_EXPOSITION_PROPERTIES)
|
|
35
|
+
const broadcast: Broadcast = this.boot.bindings.broadcast(CHANNEL)
|
|
36
|
+
const server = http.Server.create({ ...options, methods: syntax.verbs })
|
|
39
37
|
const remotes = new Remotes(this.boot)
|
|
40
38
|
const node = root.resolve()
|
|
41
39
|
const methods = new EndpointsFactory(remotes)
|
package/source/Gateway.ts
CHANGED
|
@@ -33,10 +33,7 @@ export class Gateway extends Connector {
|
|
|
33
33
|
if (match === null)
|
|
34
34
|
throw new http.NotFound('Route not found')
|
|
35
35
|
|
|
36
|
-
const {
|
|
37
|
-
node,
|
|
38
|
-
parameters
|
|
39
|
-
} = match
|
|
36
|
+
const { node, parameters } = match
|
|
40
37
|
|
|
41
38
|
if (!(context.request.method in node.methods))
|
|
42
39
|
throw new http.MethodNotAllowed()
|
|
@@ -65,8 +62,7 @@ export class Gateway extends Connector {
|
|
|
65
62
|
console.info('Gateway is closed.')
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
private async call (method: Method, context: http.Context, parameters: Parameter[]):
|
|
69
|
-
Promise<http.OutgoingMessage> {
|
|
65
|
+
private async call (method: Method, context: http.Context, parameters: Parameter[]): Promise<http.OutgoingMessage> {
|
|
70
66
|
if (context.url.pathname[context.url.pathname.length - 1] !== '/')
|
|
71
67
|
throw new http.NotFound('Trailing slash is required.')
|
|
72
68
|
|