@toa.io/extensions.exposition 1.0.0-alpha.21 → 1.0.0-alpha.23

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.
Files changed (154) hide show
  1. package/components/context.toa.yaml +2 -2
  2. package/components/identity.basic/manifest.toa.yaml +18 -9
  3. package/components/identity.basic/operations/authenticate.d.ts +5 -1
  4. package/components/identity.basic/operations/authenticate.js +2 -2
  5. package/components/identity.basic/operations/authenticate.js.map +1 -1
  6. package/components/identity.basic/operations/incept.d.ts +11 -0
  7. package/components/identity.basic/operations/incept.js +13 -0
  8. package/components/identity.basic/operations/incept.js.map +1 -0
  9. package/components/identity.basic/operations/transit.d.ts +3 -3
  10. package/components/identity.basic/operations/transit.js +5 -3
  11. package/components/identity.basic/operations/transit.js.map +1 -1
  12. package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
  13. package/components/identity.basic/operations/types.d.ts +2 -0
  14. package/components/identity.basic/source/authenticate.ts +12 -5
  15. package/components/identity.basic/source/incept.ts +22 -0
  16. package/components/identity.basic/source/transit.ts +7 -5
  17. package/components/identity.basic/source/types.ts +2 -0
  18. package/components/identity.federation/manifest.toa.yaml +28 -11
  19. package/components/identity.federation/operations/authenticate.d.ts +2 -2
  20. package/components/identity.federation/operations/authenticate.js +6 -5
  21. package/components/identity.federation/operations/authenticate.js.map +1 -1
  22. package/components/identity.federation/operations/incept.d.ts +11 -0
  23. package/components/identity.federation/operations/{create.js → incept.js} +6 -7
  24. package/components/identity.federation/operations/incept.js.map +1 -0
  25. package/components/identity.federation/operations/lib/jwt.js +3 -3
  26. package/components/identity.federation/operations/lib/jwt.js.map +1 -1
  27. package/components/identity.federation/operations/schemas.d.ts +7 -3
  28. package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
  29. package/components/identity.federation/operations/types.d.ts +5 -0
  30. package/components/identity.federation/source/authenticate.ts +9 -6
  31. package/components/identity.federation/source/{create.ts → incept.ts} +10 -9
  32. package/components/identity.federation/source/lib/jwt.test.ts +2 -2
  33. package/components/identity.federation/source/lib/jwt.ts +3 -3
  34. package/components/identity.federation/source/schemas.ts +7 -3
  35. package/components/identity.federation/source/types.ts +6 -0
  36. package/components/identity.tokens/manifest.toa.yaml +7 -1
  37. package/components/identity.tokens/operations/authenticate.d.ts +2 -2
  38. package/components/identity.tokens/operations/authenticate.js +5 -2
  39. package/components/identity.tokens/operations/authenticate.js.map +1 -1
  40. package/components/identity.tokens/operations/decrypt.js +1 -0
  41. package/components/identity.tokens/operations/decrypt.js.map +1 -1
  42. package/components/identity.tokens/operations/encrypt.js +1 -0
  43. package/components/identity.tokens/operations/encrypt.js.map +1 -1
  44. package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
  45. package/components/identity.tokens/operations/types.d.ts +7 -0
  46. package/components/identity.tokens/source/authenticate.test.ts +11 -4
  47. package/components/identity.tokens/source/authenticate.ts +7 -3
  48. package/components/identity.tokens/source/decrypt.test.ts +5 -3
  49. package/components/identity.tokens/source/decrypt.ts +9 -8
  50. package/components/identity.tokens/source/encrypt.test.ts +4 -1
  51. package/components/identity.tokens/source/encrypt.ts +1 -0
  52. package/components/identity.tokens/source/types.ts +8 -0
  53. package/components/octets.storage/manifest.toa.yaml +0 -6
  54. package/documentation/authorities.md +53 -0
  55. package/documentation/components.md +3 -3
  56. package/documentation/identity.md +17 -22
  57. package/documentation/vary.md +5 -11
  58. package/features/access.feature +55 -7
  59. package/features/annotation.feature +1 -0
  60. package/features/authorities.basic.feature +140 -0
  61. package/features/authorities.feature +32 -0
  62. package/features/authorities.federation.feature +99 -0
  63. package/features/authorities.tokens.feature +118 -0
  64. package/features/body.feature +2 -0
  65. package/features/cache.feature +39 -5
  66. package/features/cors.feature +4 -0
  67. package/features/directives.feature +3 -0
  68. package/features/dynamic.feature +4 -0
  69. package/features/errors.feature +12 -1
  70. package/features/etag.feature +6 -0
  71. package/features/identity.bans.feature +12 -3
  72. package/features/identity.basic.feature +34 -15
  73. package/features/identity.feature +7 -2
  74. package/features/identity.federation.feature +14 -4
  75. package/features/identity.roles.feature +29 -17
  76. package/features/identity.tokens.feature +18 -6
  77. package/features/io.feature +9 -0
  78. package/features/octets.entries.feature +8 -0
  79. package/features/octets.feature +17 -54
  80. package/features/octets.meta.feature +3 -0
  81. package/features/octets.workflows.feature +13 -0
  82. package/features/queries.feature +8 -0
  83. package/features/require.feature +3 -0
  84. package/features/response.feature +5 -2
  85. package/features/routes.feature +7 -0
  86. package/features/steps/Gateway.ts +23 -6
  87. package/features/streams.feature +1 -0
  88. package/features/timing.feature +3 -0
  89. package/features/vary.feature +49 -0
  90. package/package.json +7 -7
  91. package/readme.md +19 -14
  92. package/schemas/annotation.cos.yaml +1 -1
  93. package/source/Annotation.ts +3 -3
  94. package/source/Endpoint.ts +1 -1
  95. package/source/Factory.ts +8 -10
  96. package/source/Gateway.ts +2 -6
  97. package/source/HTTP/Context.ts +3 -1
  98. package/source/HTTP/Server.ts +23 -26
  99. package/source/HTTP/exceptions.ts +6 -0
  100. package/source/Query.ts +9 -5
  101. package/source/deployment.ts +25 -21
  102. package/source/directives/auth/Authorization.ts +18 -8
  103. package/source/directives/auth/Incept.ts +2 -1
  104. package/source/directives/octets/Octets.ts +0 -2
  105. package/source/directives/vary/embeddings/Authority.ts +8 -0
  106. package/source/directives/vary/embeddings/index.ts +3 -1
  107. package/source/schemas.ts +1 -1
  108. package/transpiled/Annotation.d.ts +3 -3
  109. package/transpiled/Endpoint.js +1 -1
  110. package/transpiled/Endpoint.js.map +1 -1
  111. package/transpiled/Factory.js +9 -8
  112. package/transpiled/Factory.js.map +1 -1
  113. package/transpiled/Gateway.js.map +1 -1
  114. package/transpiled/HTTP/Context.d.ts +2 -1
  115. package/transpiled/HTTP/Context.js +3 -1
  116. package/transpiled/HTTP/Context.js.map +1 -1
  117. package/transpiled/HTTP/Server.d.ts +8 -1
  118. package/transpiled/HTTP/Server.js +14 -20
  119. package/transpiled/HTTP/Server.js.map +1 -1
  120. package/transpiled/HTTP/exceptions.d.ts +3 -0
  121. package/transpiled/HTTP/exceptions.js +7 -1
  122. package/transpiled/HTTP/exceptions.js.map +1 -1
  123. package/transpiled/Query.js +2 -2
  124. package/transpiled/Query.js.map +1 -1
  125. package/transpiled/deployment.d.ts +1 -1
  126. package/transpiled/deployment.js +21 -19
  127. package/transpiled/deployment.js.map +1 -1
  128. package/transpiled/directives/auth/Authorization.js +9 -4
  129. package/transpiled/directives/auth/Authorization.js.map +1 -1
  130. package/transpiled/directives/auth/Incept.js +2 -1
  131. package/transpiled/directives/auth/Incept.js.map +1 -1
  132. package/transpiled/directives/octets/Octets.js +0 -2
  133. package/transpiled/directives/octets/Octets.js.map +1 -1
  134. package/transpiled/directives/vary/embeddings/Authority.d.ts +5 -0
  135. package/transpiled/directives/vary/embeddings/Authority.js +10 -0
  136. package/transpiled/directives/vary/embeddings/Authority.js.map +1 -0
  137. package/transpiled/directives/vary/embeddings/index.js +3 -1
  138. package/transpiled/directives/vary/embeddings/index.js.map +1 -1
  139. package/transpiled/schemas.d.ts +1 -1
  140. package/transpiled/schemas.js +2 -2
  141. package/transpiled/schemas.js.map +1 -1
  142. package/transpiled/tsconfig.tsbuildinfo +1 -1
  143. package/components/identity.basic/operations/create.d.ts +0 -10
  144. package/components/identity.basic/operations/create.js +0 -10
  145. package/components/identity.basic/operations/create.js.map +0 -1
  146. package/components/identity.basic/source/create.ts +0 -18
  147. package/components/identity.federation/operations/create.d.ts +0 -10
  148. package/components/identity.federation/operations/create.js.map +0 -1
  149. package/components/octets.storage/operations/permute.js +0 -7
  150. package/source/HTTP/Server.test.ts +0 -126
  151. package/source/directives/octets/Permute.ts +0 -44
  152. package/transpiled/directives/octets/Permute.d.ts +0 -11
  153. package/transpiled/directives/octets/Permute.js +0 -58
  154. package/transpiled/directives/octets/Permute.js.map +0 -1
@@ -6,6 +6,7 @@ import type { OutgoingMessage } from './messages'
6
6
  import type * as http from 'node:http'
7
7
 
8
8
  export class Context {
9
+ public readonly authority: string
9
10
  public readonly request: IncomingMessage
10
11
  public readonly url: URL
11
12
  public readonly subtype: string | null = null
@@ -17,7 +18,8 @@ export class Context {
17
18
  response: []
18
19
  }
19
20
 
20
- public constructor (request: IncomingMessage, trace = false) {
21
+ public constructor (authority: string, request: IncomingMessage, trace = false) {
22
+ this.authority = authority
21
23
  this.request = request
22
24
 
23
25
  this.url = new URL(request.url, `https://${request.headers.host}`)
@@ -1,10 +1,8 @@
1
1
  import fs from 'node:fs'
2
2
  import os from 'node:os'
3
3
  import * as http from 'node:http'
4
- import assert from 'node:assert'
5
4
  import { once } from 'node:events'
6
5
  import { Connector } from '@toa.io/core'
7
- import { promex } from '@toa.io/generic'
8
6
  import { type OutgoingMessage, write } from './messages'
9
7
  import { ClientError, Exception } from './exceptions'
10
8
  import { Context } from './Context'
@@ -13,12 +11,14 @@ import type { IncomingMessage } from './Context'
13
11
  export class Server extends Connector {
14
12
  private readonly server: http.Server = http.createServer()
15
13
  private readonly properties: Properties
14
+ private readonly authorities: Record<string, string>
16
15
  private process?: Processing
17
16
 
18
17
  private constructor (properties: Properties) {
19
18
  super()
20
19
 
21
20
  this.properties = properties
21
+ this.authorities = Object.fromEntries(Object.entries(properties.authorities).map(([key, value]) => [value, key]))
22
22
 
23
23
  this.server.on('request', (req, res) => this.listener(req, res))
24
24
  }
@@ -35,10 +35,8 @@ export class Server extends Connector {
35
35
  return address.port
36
36
  }
37
37
 
38
- public static create (options?: Partial<Properties>): Server {
39
- const properties = options === undefined
40
- ? DEFAULTS
41
- : { ...DEFAULTS, ...options }
38
+ public static create (options: Options): Server {
39
+ const properties: Properties = Object.assign({}, DEFAULTS, options)
42
40
 
43
41
  return new Server(properties)
44
42
  }
@@ -72,18 +70,16 @@ export class Server extends Connector {
72
70
  return
73
71
  }
74
72
 
75
- if (request.url === undefined) {
76
- response.writeHead(400).end()
73
+ if (request.headers.host === undefined || !(request.headers.host in this.authorities)) {
74
+ response.writeHead(404).end('Unknown authority')
77
75
 
78
76
  return
79
77
  }
80
78
 
81
- assert.ok(this.process !== undefined,
82
- 'No processing function has been attached to the server.')
79
+ const authority = this.authorities[request.headers.host]
80
+ const context = new Context(authority, request as IncomingMessage, this.properties.trace)
83
81
 
84
- const context = new Context(request as IncomingMessage, this.properties.trace)
85
-
86
- this.process(context)
82
+ this.process!(context)
87
83
  .then(this.success(context, response))
88
84
  .catch(this.fail(context, response))
89
85
  }
@@ -112,17 +108,16 @@ export class Server extends Connector {
112
108
  if (!context.request.complete)
113
109
  await adam(context.request)
114
110
 
115
- response.statusCode = exception instanceof Exception
116
- ? exception.status
117
- : 500
111
+ response.statusCode = exception instanceof Exception ? exception.status : 500
118
112
 
119
113
  const message: OutgoingMessage = { status: response.statusCode }
120
114
  const verbose = exception instanceof ClientError || this.properties.debug
121
115
 
122
116
  if (verbose)
123
- message.body = exception instanceof Exception
124
- ? exception.body
125
- : (exception.stack ?? exception.message)
117
+ message.body =
118
+ exception instanceof Exception
119
+ ? exception.body
120
+ : exception.stack ?? exception.message
126
121
 
127
122
  write(context, response, message)
128
123
  }
@@ -130,18 +125,15 @@ export class Server extends Connector {
130
125
  }
131
126
 
132
127
  // https://github.com/whatwg/fetch/issues/1254
133
- async function adam (request: http.IncomingMessage): Promise<void> {
134
- const completed = promex()
128
+ async function adam (request: http.IncomingMessage): Promise<any> {
135
129
  const devnull = fs.createWriteStream(os.devNull)
136
130
 
137
- request
138
- .on('end', completed.callback)
139
- .pipe(devnull)
131
+ request.pipe(devnull)
140
132
 
141
- return completed
133
+ return once(request, 'end')
142
134
  }
143
135
 
144
- const DEFAULTS: Properties = {
136
+ const DEFAULTS: Omit<Properties, 'authorities'> = {
145
137
  methods: new Set<string>(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']),
146
138
  debug: false,
147
139
  trace: false,
@@ -149,10 +141,15 @@ const DEFAULTS: Properties = {
149
141
  }
150
142
 
151
143
  interface Properties {
144
+ authorities: Record<string, string>
152
145
  methods: Set<string>
153
146
  debug: boolean
154
147
  trace: boolean
155
148
  port: number
156
149
  }
157
150
 
151
+ export type Options = { authorities: Properties['authorities'] } & {
152
+ [K in Exclude<keyof Properties, 'authorities'>]?: Properties[K]
153
+ }
154
+
158
155
  export type Processing = (input: Context) => Promise<OutgoingMessage>
@@ -42,6 +42,12 @@ export class Conflict extends ClientError {
42
42
  }
43
43
  }
44
44
 
45
+ export class UnprocessableEntity extends ClientError {
46
+ public constructor (body?: any) {
47
+ super(422, body)
48
+ }
49
+ }
50
+
45
51
  export class MethodNotAllowed extends ClientError {
46
52
  public constructor () {
47
53
  super(405)
package/source/Query.ts CHANGED
@@ -12,8 +12,10 @@ export class Query {
12
12
  if (query.criteria !== undefined) {
13
13
  const open = query.criteria[query.criteria.length - 1] === ';'
14
14
 
15
- if (open) query.criteria = query.criteria.slice(0, -1)
16
- else this.closed = true
15
+ if (open)
16
+ query.criteria = query.criteria.slice(0, -1)
17
+ else
18
+ this.closed = true
17
19
  }
18
20
 
19
21
  this.query = query
@@ -55,8 +57,10 @@ export class Query {
55
57
  }
56
58
 
57
59
  if (query.criteria !== undefined)
58
- if (this.closed) throw new http.BadRequest('Query criteria is closed.')
59
- else criteria.push(query.criteria)
60
+ if (this.closed)
61
+ throw new http.BadRequest('Query criteria is closed')
62
+ else
63
+ criteria.push(query.criteria)
60
64
 
61
65
  switch (criteria.length) {
62
66
  case 0:
@@ -99,7 +103,7 @@ function fit (string: string, range: [number, number], name: string): number {
99
103
 
100
104
  if (number < range[0] || number > range[1])
101
105
  throw new http.BadRequest(`Query ${name} must be between ` +
102
- `${range[0]} and ${range[1]} inclusive.`)
106
+ `${range[0]} and ${range[1]} inclusive`)
103
107
 
104
108
  return number
105
109
  }
@@ -1,3 +1,4 @@
1
+ import assert from 'node:assert'
1
2
  import { type Dependency, type Service } from '@toa.io/operations'
2
3
  import { encode } from '@toa.io/generic'
3
4
  import { type Annotation } from './Annotation'
@@ -6,7 +7,10 @@ import { shortcuts } from './Directive'
6
7
  import { components } from './Composition'
7
8
  import { parse } from './RTD/syntax'
8
9
 
9
- export function deployment (_: unknown, annotation: Annotation | undefined): Dependency {
10
+ export function deployment (_: unknown, annotation?: Annotation): Dependency {
11
+ assert.ok(annotation !== undefined, 'Exposition context annotation is required')
12
+ schemas.annotation.validate(annotation)
13
+
10
14
  const labels = components().labels
11
15
 
12
16
  const service: Service = {
@@ -16,16 +20,10 @@ export function deployment (_: unknown, annotation: Annotation | undefined): Dep
16
20
  // eslint-disable-next-line @typescript-eslint/no-var-requires
17
21
  version: require('../package.json').version,
18
22
  variables: [],
19
- components: labels
23
+ components: labels,
24
+ ingress: { hosts: [] }
20
25
  }
21
26
 
22
- if (annotation?.host !== undefined)
23
- service.ingress = {
24
- host: annotation.host,
25
- class: annotation.class,
26
- annotations: annotation.annotations
27
- }
28
-
29
27
  if (annotation?.['/'] !== undefined) {
30
28
  const tree = parse(annotation['/'], shortcuts)
31
29
 
@@ -35,20 +33,26 @@ export function deployment (_: unknown, annotation: Annotation | undefined): Dep
35
33
  })
36
34
  }
37
35
 
38
- if (annotation?.debug === true)
39
- service.variables.push({
40
- name: 'TOA_EXPOSITION_DEBUG',
41
- value: '1'
42
- })
36
+ const { debug, trace, authorities } = annotation
43
37
 
44
- if (annotation?.trace === true)
45
- service.variables.push({
46
- name: 'TOA_EXPOSITION_TRACE',
47
- value: '1'
48
- })
38
+ service.ingress.hosts = Object.values(authorities)
39
+ service.ingress.class = annotation.class
40
+ service.ingress.annotations = annotation.annotations
41
+
42
+ const properties: Properties = { authorities }
43
+
44
+ if (debug === true)
45
+ properties.debug = true
49
46
 
50
- if (annotation !== undefined)
51
- schemas.annotaion.validate(annotation)
47
+ if (trace === true)
48
+ properties.trace = true
49
+
50
+ service.variables.push({
51
+ name: 'TOA_EXPOSITION_PROPERTIES',
52
+ value: encode(properties)
53
+ })
52
54
 
53
55
  return { services: [service] }
54
56
  }
57
+
58
+ type Properties = Pick<Annotation, 'authorities' | 'debug' | 'trace'>
@@ -56,7 +56,7 @@ export class Authorization implements DirectiveFamily<Directive, Extension> {
56
56
  public async preflight (directives: Directive[],
57
57
  input: Input,
58
58
  parameters: Parameter[]): Promise<Output> {
59
- const identity = await this.resolve(input.request.headers.authorization)
59
+ const identity = await this.resolve(input.authority, input.request.headers.authorization)
60
60
 
61
61
  input.identity = identity
62
62
 
@@ -80,16 +80,22 @@ export class Authorization implements DirectiveFamily<Directive, Extension> {
80
80
 
81
81
  const identity = request.identity
82
82
 
83
- if (identity === null) return
83
+ if (identity === null)
84
+ return
84
85
 
85
- if (identity.scheme === PRIMARY && !identity.refresh) return
86
+ if (identity.scheme === PRIMARY && !identity.refresh)
87
+ return
86
88
 
87
89
  // Role directive may have already set the value
88
- if (identity.roles === undefined) await Role.set(identity, this.discovery.roles)
90
+ if (identity.roles === undefined)
91
+ await Role.set(identity, this.discovery.roles)
89
92
 
90
93
  this.tokens ??= await this.discovery.tokens
91
94
 
92
- const token = await this.tokens.invoke<string>('encrypt', { input: { identity } })
95
+ const token = await this.tokens.invoke<string>('encrypt', {
96
+ input: { authority: request.authority, identity }
97
+ })
98
+
93
99
  const authorization = `Token ${token}`
94
100
 
95
101
  response.headers ??= new Headers()
@@ -97,8 +103,9 @@ export class Authorization implements DirectiveFamily<Directive, Extension> {
97
103
  response.headers.append('cache-control', 'no-store')
98
104
  }
99
105
 
100
- private async resolve (authorization: string | undefined): Promise<Identity | null> {
101
- if (authorization === undefined) return null
106
+ private async resolve (authority: string, authorization: string | undefined): Promise<Identity | null> {
107
+ if (authorization === undefined)
108
+ return null
102
109
 
103
110
  const [scheme, credentials] = split(authorization)
104
111
  const provider = PROVIDERS[scheme]
@@ -109,7 +116,10 @@ export class Authorization implements DirectiveFamily<Directive, Extension> {
109
116
  this.schemes[scheme] ??= await this.discovery[provider]
110
117
 
111
118
  const result = await this.schemes[scheme].invoke<AuthenticationResult>('authenticate', {
112
- input: credentials
119
+ input: {
120
+ authority,
121
+ credentials
122
+ }
113
123
  })
114
124
 
115
125
  if (result instanceof Error) return null
@@ -31,8 +31,9 @@ export class Incept implements Directive {
31
31
  this.schemes[scheme] ??= await this.discovery[provider]
32
32
 
33
33
  const identity = await this.schemes[scheme]
34
- .invoke<Maybe<Identity>>('create', {
34
+ .invoke<Maybe<Identity>>('incept', {
35
35
  input: {
36
+ authority: input.authority,
36
37
  id,
37
38
  credentials
38
39
  }
@@ -4,7 +4,6 @@ import { Store } from './Store'
4
4
  import { Fetch } from './Fetch'
5
5
  import { List } from './List'
6
6
  import { Delete } from './Delete'
7
- import { Permute } from './Permute'
8
7
  import { WorkflowDirective } from './Workflow'
9
8
  import type { Directive } from './Directive'
10
9
  import type { Output } from '../../io'
@@ -66,7 +65,6 @@ const DIRECTIVES: Record<string, Constructor> = {
66
65
  fetch: Fetch,
67
66
  list: List,
68
67
  delete: Delete,
69
- permute: Permute,
70
68
  workflow: WorkflowDirective
71
69
  }
72
70
 
@@ -0,0 +1,8 @@
1
+ import type { Embedding } from './Embedding'
2
+ import type { Input } from '../../../io'
3
+
4
+ export class Authority implements Embedding {
5
+ public resolve (context: Input): string {
6
+ return context.authority
7
+ }
8
+ }
@@ -1,8 +1,10 @@
1
1
  import { Language } from './Language'
2
+ import { Authority } from './Authority'
2
3
  import type { Embedding } from './Embedding'
3
4
 
4
5
  export const embeddings: Record<string, new () => Embedding> = {
5
- language: Language
6
+ language: Language,
7
+ authority: Authority
6
8
  }
7
9
 
8
10
  export type { Embedding }
package/source/schemas.ts CHANGED
@@ -9,5 +9,5 @@ const path = resolve(__dirname, '../schemas')
9
9
  const namespace = schemas.namespace(path)
10
10
 
11
11
  export const querystring: Schema<Query> = namespace.schema('querystring')
12
- export const annotaion: Schema<Annotation> = namespace.schema('annotation')
12
+ export const annotation: Schema<Annotation> = namespace.schema('annotation')
13
13
  export const node: Schema<Node> = namespace.schema('node')
@@ -1,8 +1,8 @@
1
1
  export interface Annotation {
2
- host?: string;
2
+ authorities: Record<string, string>;
3
3
  class?: string;
4
4
  annotations?: Record<string, string>;
5
- debug: boolean;
6
- trace: boolean;
5
+ debug?: boolean;
6
+ trace?: boolean;
7
7
  '/'?: object;
8
8
  }
@@ -43,7 +43,7 @@ class Endpoint {
43
43
  this.remote ??= await this.discovery;
44
44
  const reply = await this.remote.invoke(this.endpoint, request);
45
45
  if (reply instanceof Error)
46
- throw new http.Conflict(reply);
46
+ throw new http.UnprocessableEntity(reply);
47
47
  const message = {};
48
48
  if (typeof reply === 'object' && reply !== null && '_version' in reply) {
49
49
  const etag = context.request.headers['if-none-match'];
@@ -1 +1 @@
1
- {"version":3,"file":"Endpoint.js","sourceRoot":"","sources":["../source/Endpoint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAAmC;AAEnC,6CAA8B;AAG9B,MAAa,QAAQ;IACF,QAAQ,CAAQ;IAChB,OAAO,CAAS;IAChB,SAAS,CAAoB;IACtC,MAAM,GAAqB,IAAI,CAAA;IAEvC,YAAoB,QAAgB,EAAE,OAAgB,EAAE,SAA6B;QACnF,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,IAAI,CAChB,OAAqB,EAAE,UAA2B;QACjD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;QAEzD,IAAI,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,SAAS,CAAA;QAEpC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAE9D,IAAI,KAAK,YAAY,KAAK;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A;QAE5C,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAO,CAAC,OAAO,CAAC,CAAA;IAC/C,CAAC;CACF;AAtED,4BAsEC;AAED,MAAa,gBAAgB;IACV,OAAO,CAAS;IAEjC,YAAoB,OAAgB;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAEM,MAAM,CAAE,MAAyB,EAAE,OAAgB;QACxD,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;YAC9B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;QAE5D,MAAM,OAAO,GAAG,iBAAO,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACpD,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,EAAE,SAAS,CAAA;QAC1E,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,EAAE,SAAS,CAAA;QAE1E,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS;YACpD,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAElE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAE7D,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IAClE,CAAC;CACF;AAtBD,4CAsBC;AAED,MAAM,IAAI,GAAG,0BAA0B,CAAA;AAEvC,MAAM,SAAS,GAAG,IAAI,CAAA"}
@@ -22,19 +22,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  exports.Factory = void 0;
30
+ const node_assert_1 = __importDefault(require("node:assert"));
31
+ const generic_1 = require("@toa.io/generic");
27
32
  const Tenant_1 = require("./Tenant");
28
33
  const Gateway_1 = require("./Gateway");
29
34
  const Remotes_1 = require("./Remotes");
30
35
  const RTD_1 = require("./RTD");
31
- const HTTP_1 = require("./HTTP");
32
36
  const Endpoint_1 = require("./Endpoint");
33
37
  const directives_1 = require("./directives");
34
38
  const Directive_1 = require("./Directive");
35
39
  const Composition_1 = require("./Composition");
36
40
  const root = __importStar(require("./root"));
37
41
  const Interception_1 = require("./Interception");
42
+ const http = __importStar(require("./HTTP"));
38
43
  class Factory {
39
44
  boot;
40
45
  constructor(boot) {
@@ -45,14 +50,10 @@ class Factory {
45
50
  return new Tenant_1.Tenant(broadcast, locator, node);
46
51
  }
47
52
  service() {
48
- const debug = process.env.TOA_EXPOSITION_DEBUG === '1';
49
- const trace = process.env.TOA_EXPOSITION_TRACE === '1';
53
+ node_assert_1.default.ok(process.env.TOA_EXPOSITION_PROPERTIES, 'TOA_EXPOSITION_PROPERTIES is undefined');
54
+ const options = (0, generic_1.decode)(process.env.TOA_EXPOSITION_PROPERTIES);
50
55
  const broadcast = this.boot.bindings.broadcast(CHANNEL);
51
- const server = HTTP_1.Server.create({
52
- methods: RTD_1.syntax.verbs,
53
- debug,
54
- trace
55
- });
56
+ const server = http.Server.create({ ...options, methods: RTD_1.syntax.verbs });
56
57
  const remotes = new Remotes_1.Remotes(this.boot);
57
58
  const node = root.resolve();
58
59
  const methods = new Endpoint_1.EndpointsFactory(remotes);
@@ -1 +1 @@
1
- {"version":3,"file":"Factory.js","sourceRoot":"","sources":["../source/Factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAiC;AACjC,uCAAmC;AACnC,uCAAmC;AACnC,+BAAoC;AACpC,iCAA+B;AAC/B,yCAA6C;AAC7C,6CAAqD;AACrD,2CAA+C;AAC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;QACjE,CAAC;QAAC,OAAO,SAAS,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;CACF;AAtFD,0BAsFC"}
@@ -4,13 +4,14 @@ import { type Format } from './formats';
4
4
  import type { OutgoingMessage } from './messages';
5
5
  import type * as http from 'node:http';
6
6
  export declare class Context {
7
+ readonly authority: string;
7
8
  readonly request: IncomingMessage;
8
9
  readonly url: URL;
9
10
  readonly subtype: string | null;
10
11
  readonly encoder: Format | null;
11
12
  readonly timing: Timing;
12
13
  readonly pipelines: Pipelines;
13
- constructor(request: IncomingMessage, trace?: boolean);
14
+ constructor(authority: string, request: IncomingMessage, trace?: boolean);
14
15
  body<T>(): Promise<T>;
15
16
  }
16
17
  export interface IncomingMessage extends http.IncomingMessage {
@@ -9,6 +9,7 @@ const Timing_1 = require("./Timing");
9
9
  const formats_1 = require("./formats");
10
10
  const messages_1 = require("./messages");
11
11
  class Context {
12
+ authority;
12
13
  request;
13
14
  url;
14
15
  subtype = null;
@@ -18,7 +19,8 @@ class Context {
18
19
  body: [],
19
20
  response: []
20
21
  };
21
- constructor(request, trace = false) {
22
+ constructor(authority, request, trace = false) {
23
+ this.authority = authority;
22
24
  this.request = request;
23
25
  this.url = new URL(request.url, `https://${request.headers.host}`);
24
26
  this.timing = new Timing_1.Timing(trace);
@@ -1 +1 @@
1
- {"version":3,"file":"Context.js","sourceRoot":"","sources":["../../source/HTTP/Context.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAmC;AACnC,qCAAiC;AACjC,uCAAuD;AACvD,yCAAiC;AAIjC,MAAa,OAAO;IACF,OAAO,CAAiB;IACxB,GAAG,CAAK;IACR,OAAO,GAAkB,IAAI,CAAA;IAC7B,OAAO,GAAkB,IAAI,CAAA;IAC7B,MAAM,CAAQ;IAEd,SAAS,GAAc;QACrC,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;KACb,CAAA;IAED,YAAoB,OAAwB,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I,IAAI,MAAM,EAAE,CAAA;gBACjD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;YACxB,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,oBAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/C,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,eAAK,CAAC,CAAA;QAE7C,IAAI,SAAS,KAAK,SAAS;YACzB,IAAI,CAAC,OAAO,GAAG,iBAAO,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,MAAM,KAAK,GAAG,MAAM,IAAA,eAAI,EAAC,IAAI,CAAC,CAAA;QAE9B,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;YACrC,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAA;IAC/E,CAAC;CACF;AAjDD,0BAiDC;AAYD,MAAM,OAAO,GAAG,4EAA4E,CAAA"}
@@ -4,10 +4,11 @@ import { Context } from './Context';
4
4
  export declare class Server extends Connector {
5
5
  private readonly server;
6
6
  private readonly properties;
7
+ private readonly authorities;
7
8
  private process?;
8
9
  private constructor();
9
10
  get port(): number;
10
- static create(options?: Partial<Properties>): Server;
11
+ static create(options: Options): Server;
11
12
  attach(process: Processing): void;
12
13
  protected open(): Promise<void>;
13
14
  protected close(): Promise<void>;
@@ -16,10 +17,16 @@ export declare class Server extends Connector {
16
17
  private fail;
17
18
  }
18
19
  interface Properties {
20
+ authorities: Record<string, string>;
19
21
  methods: Set<string>;
20
22
  debug: boolean;
21
23
  trace: boolean;
22
24
  port: number;
23
25
  }
26
+ export type Options = {
27
+ authorities: Properties['authorities'];
28
+ } & {
29
+ [K in Exclude<keyof Properties, 'authorities'>]?: Properties[K];
30
+ };
24
31
  export type Processing = (input: Context) => Promise<OutgoingMessage>;
25
32
  export {};