@toa.io/extensions.exposition 1.0.0-alpha.253 → 1.0.0-alpha.256

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 (106) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/components/identity.bans/operations/tsconfig.tsbuildinfo +1 -1
  3. package/components/identity.basic/manifest.toa.yaml +1 -1
  4. package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
  5. package/components/identity.credentials/operations/tsconfig.tsbuildinfo +1 -1
  6. package/components/identity.federation/manifest.toa.yaml +4 -4
  7. package/components/identity.federation/operations/authenticate.js +2 -1
  8. package/components/identity.federation/operations/authenticate.js.map +1 -1
  9. package/components/identity.federation/operations/decode.js +2 -1
  10. package/components/identity.federation/operations/decode.js.map +1 -1
  11. package/components/identity.federation/operations/delete.d.ts +2 -2
  12. package/components/identity.federation/operations/delete.js +3 -3
  13. package/components/identity.federation/operations/delete.js.map +1 -1
  14. package/components/identity.federation/operations/incept.js +2 -1
  15. package/components/identity.federation/operations/incept.js.map +1 -1
  16. package/components/identity.federation/operations/lib/Ctx.d.ts +2 -0
  17. package/components/identity.federation/operations/lib/decode.js +4 -27
  18. package/components/identity.federation/operations/lib/decode.js.map +1 -1
  19. package/components/identity.federation/operations/lib/discovery.d.ts +4 -3
  20. package/components/identity.federation/operations/lib/discovery.js +21 -31
  21. package/components/identity.federation/operations/lib/discovery.js.map +1 -1
  22. package/components/identity.federation/operations/lib/exchange.js +7 -6
  23. package/components/identity.federation/operations/lib/exchange.js.map +1 -1
  24. package/components/identity.federation/operations/lib/jose.d.ts +41 -0
  25. package/components/identity.federation/operations/lib/jose.js +27 -0
  26. package/components/identity.federation/operations/lib/jose.js.map +1 -0
  27. package/components/identity.federation/operations/list.js +2 -1
  28. package/components/identity.federation/operations/list.js.map +1 -1
  29. package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
  30. package/components/identity.federation/operations/types/context.d.ts +2 -0
  31. package/components/identity.federation/source/authenticate.ts +2 -1
  32. package/components/identity.federation/source/decode.ts +2 -1
  33. package/components/identity.federation/source/delete.ts +4 -4
  34. package/components/identity.federation/source/incept.ts +2 -1
  35. package/components/identity.federation/source/lib/Ctx.ts +2 -0
  36. package/components/identity.federation/source/lib/decode.ts +4 -5
  37. package/components/identity.federation/source/lib/discovery.test.ts +45 -0
  38. package/components/identity.federation/source/lib/discovery.ts +27 -8
  39. package/components/identity.federation/source/lib/exchange.ts +7 -7
  40. package/components/identity.federation/source/lib/jose.d.ts +1 -0
  41. package/components/identity.federation/source/lib/jose.js +5 -0
  42. package/components/identity.federation/source/list.test.ts +2 -1
  43. package/components/identity.federation/source/list.ts +2 -1
  44. package/components/identity.federation/source/types/context.ts +3 -0
  45. package/components/identity.federation/tsconfig.json +1 -4
  46. package/components/identity.keys/manifest.toa.yaml +1 -0
  47. package/components/identity.keys/operations/create.js +2 -2
  48. package/components/identity.keys/operations/create.js.map +1 -1
  49. package/components/identity.keys/operations/tsconfig.tsbuildinfo +1 -1
  50. package/components/identity.keys/source/create.ts +2 -2
  51. package/components/identity.otp/operations/tsconfig.tsbuildinfo +1 -1
  52. package/components/identity.passkeys/operations/tsconfig.tsbuildinfo +1 -1
  53. package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
  54. package/components/identity.tokens/manifest.toa.yaml +21 -4
  55. package/components/identity.tokens/operations/decrypt.d.ts +4 -2
  56. package/components/identity.tokens/operations/decrypt.js +60 -12
  57. package/components/identity.tokens/operations/decrypt.js.map +1 -1
  58. package/components/identity.tokens/operations/encrypt.js +14 -13
  59. package/components/identity.tokens/operations/encrypt.js.map +1 -1
  60. package/components/identity.tokens/operations/lib/index.d.ts +1 -0
  61. package/components/identity.tokens/operations/lib/index.js +3 -0
  62. package/components/identity.tokens/operations/lib/index.js.map +1 -1
  63. package/components/identity.tokens/operations/lib/jose.d.ts +41 -0
  64. package/components/identity.tokens/operations/lib/jose.js +27 -0
  65. package/components/identity.tokens/operations/lib/jose.js.map +1 -0
  66. package/components/identity.tokens/operations/lib/key.d.ts +1 -0
  67. package/components/identity.tokens/operations/lib/key.js +11 -0
  68. package/components/identity.tokens/operations/lib/key.js.map +1 -0
  69. package/components/identity.tokens/operations/lib/types.d.ts +10 -1
  70. package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
  71. package/components/identity.tokens/source/authenticate.test.ts +4 -3
  72. package/components/identity.tokens/source/decrypt.test.ts +69 -8
  73. package/components/identity.tokens/source/decrypt.ts +72 -14
  74. package/components/identity.tokens/source/encrypt.test.ts +30 -3
  75. package/components/identity.tokens/source/encrypt.ts +18 -16
  76. package/components/identity.tokens/source/lib/index.ts +1 -0
  77. package/components/identity.tokens/source/lib/jose.d.ts +1 -0
  78. package/components/identity.tokens/source/lib/jose.js +5 -0
  79. package/components/identity.tokens/source/lib/key.ts +8 -0
  80. package/components/identity.tokens/source/lib/types.ts +12 -1
  81. package/{components/context.toa.yaml → context.toa.yaml} +6 -2
  82. package/documentation/authorities.md +1 -1
  83. package/documentation/components.md +70 -30
  84. package/documentation/identity.md +12 -14
  85. package/features/access.feature +1 -1
  86. package/features/cache.feature +5 -5
  87. package/features/cors.feature +4 -4
  88. package/features/credentials.feature +3 -3
  89. package/features/identity.basic.feature +1 -1
  90. package/features/identity.federation.feature +4 -5
  91. package/features/identity.roles.feature +1 -1
  92. package/features/identity.tokens.feature +3 -3
  93. package/features/steps/Gateway.ts +11 -3
  94. package/package.json +18 -21
  95. package/source/HTTP/formats/yaml.test.ts +9 -0
  96. package/source/HTTP/formats/yaml.ts +2 -1
  97. package/source/HTTP/messages.ts +1 -1
  98. package/source/directives/io/lib/throttle/Interval.ts +10 -1
  99. package/transpiled/HTTP/formats/yaml.js +2 -1
  100. package/transpiled/HTTP/formats/yaml.js.map +1 -1
  101. package/transpiled/HTTP/messages.js +24 -4
  102. package/transpiled/HTTP/messages.js.map +1 -1
  103. package/transpiled/directives/io/lib/throttle/Interval.d.ts +1 -0
  104. package/transpiled/directives/io/lib/throttle/Interval.js +9 -1
  105. package/transpiled/directives/io/lib/throttle/Interval.js.map +1 -1
  106. package/transpiled/tsconfig.tsbuildinfo +1 -1
@@ -41,19 +41,22 @@ See [`identity.basic` component](components.md#basic-credentials).
41
41
 
42
42
  ### Token scheme
43
43
 
44
- Tokens issued by the Authentication system. These tokens are [PASETO](https://paseto.io).
44
+ Tokens issued by the Authentication system. New tokens are compact
45
+ [JSON Web Encryption (JWE)](https://www.rfc-editor.org/rfc/rfc7516) values using direct symmetric
46
+ encryption (`alg: dir`) and AES-256-GCM (`enc: A256GCM`). Legacy PASETO V3.local tokens remain
47
+ accepted during migration and are always replaced on successful authentication.
45
48
 
46
49
  ```http
47
- Authrization: Token v4.local.eyJzdWIiOiJqb2hu...
50
+ Authorization: Token eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwidHlwIjoiSldUIiwia2lkIjo...
48
51
  ```
49
52
 
50
53
  The `Token` is the **primary** authentication scheme.
51
54
  If request originators use an alternative authentication scheme, they will receive a response
52
- containing `Token`credentials and will be required to switch to the `Token` scheme for any
55
+ containing `Token` credentials and will be required to switch to the `Token` scheme for any
53
56
  subsequent requests.
54
57
  Continued use of other authentication schemes will result in temporary blocking of requests.
55
58
 
56
- See [`identity.tokens` component](components.md#stateless-tokens).
59
+ See [`identity.tokens` component](components.md#local-tokens).
57
60
 
58
61
  ### Bearer scheme
59
62
 
@@ -66,7 +69,8 @@ to [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.ht
66
69
  Authorization: Bearer eyJhbGciOiJIUzI1...
67
70
  ```
68
71
 
69
- Trusted providers are specified using the `identity.federation` configuration.
72
+ Trusted providers are specified using the `identity.federation` configuration. Provider metadata
73
+ and signing keys are discovered using OpenID Connect discovery and JWKS.
70
74
 
71
75
  ```yaml
72
76
  # context.toa.yaml
@@ -80,23 +84,17 @@ configuration:
80
84
  - iss: https://appleid.apple.com
81
85
  aud: <APPLE_CLIENT_ID>
82
86
  secret: <APPLE_CLIENT_SECRET> # enables Authorization Code Flow
83
-
84
- - iss: private.entity
85
- secrets:
86
- HS384:
87
- key0: <THE-SECRET-STRING-FOR-HS384>
88
- key1: <THE-SECRET-STRING-FOR-HS384> # selected by `kid` in the JWT header
89
87
  principal:
90
88
  iss: https://accounts.google.com
91
89
  sub: 4218230498234
92
- implicit: true
90
+ assert: true
93
91
  ```
94
92
 
95
93
  `principal` specifies the values of the `iss` and `sub` claims of an Identity that will be granted
96
94
  with a `system` role.
97
95
 
98
- `implicit` indicates whether the Identity should be implicitly created when a valid token for a
99
- non-existent Identity is provided (default `false`).
96
+ `assert` indicates whether the Identity should be implicitly created when valid credentials for a
97
+ non-existent Identity are provided (default `true`).
100
98
 
101
99
  ### Authorization Code Flow
102
100
 
@@ -414,8 +414,8 @@ Feature: Access authorization
414
414
  Then the following reply is sent:
415
415
  """
416
416
  200 OK
417
- content-type: application/yaml
418
417
  authorization: Token ${{ token }}
418
+ content-type: application/yaml
419
419
 
420
420
  access: granted!
421
421
  """
@@ -64,8 +64,8 @@ Feature: Caching
64
64
  Then the following reply is sent:
65
65
  """
66
66
  200 OK
67
- content-type: text/plain
68
67
  cache-control: max-age=60000
68
+ content-type: text/plain
69
69
 
70
70
  hello
71
71
  """
@@ -110,8 +110,8 @@ Feature: Caching
110
110
  Then the following reply is sent:
111
111
  """
112
112
  200 OK
113
- content-type: text/plain
114
113
  cache-control: max-age=30000
114
+ content-type: text/plain
115
115
 
116
116
  hello
117
117
  """
@@ -125,8 +125,8 @@ Feature: Caching
125
125
  Then the following reply is sent:
126
126
  """
127
127
  200 OK
128
- content-type: text/plain
129
128
  cache-control: private, max-age=30000
129
+ content-type: text/plain
130
130
 
131
131
  hello
132
132
  """
@@ -140,8 +140,8 @@ Feature: Caching
140
140
  Then the following reply is sent:
141
141
  """
142
142
  200 OK
143
- content-type: text/plain
144
143
  cache-control: no-cache, max-age=60000, public
144
+ content-type: text/plain
145
145
 
146
146
  hello
147
147
  """
@@ -203,8 +203,8 @@ Feature: Caching
203
203
  Then the following reply is sent:
204
204
  """
205
205
  200 OK
206
- content-type: text/plain
207
206
  cache-control: max-age=60000, public
207
+ content-type: text/plain
208
208
 
209
209
  hello
210
210
  """
@@ -19,10 +19,10 @@ Feature: CORS Support
19
19
  Then the following reply is sent:
20
20
  """
21
21
  204 No Content
22
- access-control-allow-origin: https://hello.world
23
- access-control-allow-methods: GET, POST, PUT, PATCH, DELETE, LOCK, UNLOCK
24
- access-control-allow-headers: accept, authorization, content-type, if-match, if-none-match
25
22
  access-control-allow-credentials: true
23
+ access-control-allow-headers: accept, authorization, content-type, if-match, if-none-match, origin
24
+ access-control-allow-methods: GET, POST, PUT, PATCH, DELETE, LOCK, UNLOCK
25
+ access-control-allow-origin: https://hello.world
26
26
  access-control-max-age: 3600
27
27
  cache-control: max-age=3600
28
28
  vary: origin
@@ -36,8 +36,8 @@ Feature: CORS Support
36
36
  Then the following reply is sent:
37
37
  """
38
38
  200 OK
39
- access-control-allow-origin: https://hello.world
40
39
  access-control-allow-credentials: true
40
+ access-control-allow-origin: https://hello.world
41
41
  access-control-expose-headers: authorization, content-type, content-length, date, etag, last-modified
42
42
  vary: origin
43
43
  """
@@ -64,7 +64,7 @@ Feature: Persistent credentials management
64
64
  """
65
65
  Then the following reply is sent:
66
66
  """
67
- 204 No Content
67
+ 200 OK
68
68
  """
69
69
  When the following request is received:
70
70
  """
@@ -74,7 +74,7 @@ Feature: Persistent credentials management
74
74
  """
75
75
  Then the following reply is sent:
76
76
  """
77
- 204 No Content
77
+ 200 OK
78
78
  """
79
79
  When the following request is received:
80
80
  """
@@ -84,7 +84,7 @@ Feature: Persistent credentials management
84
84
  """
85
85
  Then the following reply is sent:
86
86
  """
87
- 204 No Content
87
+ 200 OK
88
88
  """
89
89
  When the following request is received:
90
90
  """
@@ -307,7 +307,7 @@ Feature: Basic authentication
307
307
  """
308
308
  PATCH /identity/basic/${{ id }}/ HTTP/1.1
309
309
  host: nex.toa.io
310
- authorization: Token ${{ token }}
310
+ authorization: Basic cm9vdDpzZWNyZXQjMTIzNA==
311
311
  accept: application/yaml
312
312
  content-type: application/yaml
313
313
 
@@ -88,10 +88,8 @@ Feature: Identity Federation
88
88
  """
89
89
  201 Created
90
90
  authorization: Token ${{ Bill.token }}
91
-
92
- id: ${{ Bill.id }}
93
91
  """
94
- # check that both tokens corresponds to the same id
92
+ # check that both tokens authenticate the created federation identity
95
93
  When the following request is received:
96
94
  """
97
95
  GET /identity/ HTTP/1.1
@@ -102,7 +100,7 @@ Feature: Identity Federation
102
100
  Then the following reply is sent:
103
101
  """
104
102
  200 OK
105
- id: ${{ Bill.id }}
103
+ roles: []
106
104
  """
107
105
  When the following request is received:
108
106
  """
@@ -115,7 +113,7 @@ Feature: Identity Federation
115
113
  """
116
114
  200 OK
117
115
 
118
- id: ${{ Bill.id }}
116
+ roles: []
119
117
  """
120
118
  And the following request is received:
121
119
  # same credentials
@@ -216,6 +214,7 @@ Feature: Identity Federation
216
214
  content-type: application/yaml
217
215
  accept: application/yaml
218
216
 
217
+ scheme: bearer
219
218
  credentials: ${{ Bob.id_token }}
220
219
  """
221
220
  Then the following reply is sent:
@@ -181,7 +181,7 @@ Feature: Roles management
181
181
  """
182
182
  422 Unprocessable Entity
183
183
 
184
- code: OUT_OF_SCOPE
184
+ code: INACCESSIBLE_SCOPE
185
185
  """
186
186
 
187
187
  Scenario: Delegating role without `system:identity:roles:delegation` role
@@ -24,8 +24,8 @@ Feature: Tokens lifecycle
24
24
  Then the following reply is sent:
25
25
  """
26
26
  200 OK
27
- content-type: text/plain
28
27
  authorization: Token ${{ token }}
28
+ content-type: text/plain
29
29
 
30
30
  Hello
31
31
  """
@@ -89,7 +89,7 @@ Feature: Tokens lifecycle
89
89
  """
90
90
  And the `identity.tokens` configuration:
91
91
  """yaml
92
- refresh: 0.1
92
+ refresh: 1
93
93
  """
94
94
  And the `identity.basic` database contains:
95
95
  | _id | _version | authority | username | password |
@@ -118,7 +118,7 @@ Feature: Tokens lifecycle
118
118
  """
119
119
  200 OK
120
120
  """
121
- Then after 0.2 seconds
121
+ Then after 1.1 seconds
122
122
  When the following request is received:
123
123
  """
124
124
  GET /efe3a65ebbee47ed95a73edd911ea328/ HTTP/1.1
@@ -135,8 +135,16 @@ const DEFAULT_PROPERTIES: Partial<http.Options> = {
135
135
 
136
136
  const DEFAULT_CONFIGURATION: Record<string, object> = {
137
137
  'identity.tokens': {
138
- keys: {
139
- 0: 'k3.local.pIZT8-9Fa6U_QtfQHOSStfGtmyzPINyKQq2Xk-hd7vA'
140
- }
138
+ keys: [
139
+ {
140
+ id: 'key0',
141
+ key: 'sTxL6qVOadKkUJwh3FveU53XgTEo3Sdfg7k2FfiIKfs'
142
+ },
143
+ {
144
+ id: 'legacy0',
145
+ key: 'k3.local.pIZT8-9Fa6U_QtfQHOSStfGtmyzPINyKQq2Xk-hd7vA',
146
+ format: 'paseto'
147
+ }
148
+ ]
141
149
  }
142
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/extensions.exposition",
3
- "version": "1.0.0-alpha.253",
3
+ "version": "1.0.0-alpha.256",
4
4
  "description": "Toa Exposition",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -17,26 +17,25 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@aws-sdk/protocol-http": "3.370.0",
21
- "@simplewebauthn/server": "13.1.1",
22
- "@toa.io/core": "1.0.0-alpha.252",
23
- "@toa.io/generic": "1.0.0-alpha.225",
24
- "@toa.io/schemas": "1.0.0-alpha.246",
25
- "bcryptjs": "2.4.3",
26
- "content-type": "1.0.5",
27
- "error-value": "0.4.2",
28
- "jose": "5.10.0",
29
- "js-yaml": "4.3.1",
30
- "lru-cache": "11.2.7",
31
- "matchacho": "0.3.5",
32
- "minimatch": "10.2.4",
33
- "msgpackr": "1.11.9",
20
+ "@simplewebauthn/server": "13.3.2",
21
+ "@toa.io/core": "1.0.0-alpha.254",
22
+ "@toa.io/generic": "1.0.0-alpha.254",
23
+ "@toa.io/schemas": "1.0.0-alpha.254",
24
+ "bcryptjs": "3.0.3",
25
+ "content-type": "2.0.0",
26
+ "error-value": "0.4.4",
27
+ "jose": "6.2.8",
28
+ "js-yaml": "5.2.3",
29
+ "lru-cache": "11.5.2",
30
+ "matchacho": "0.6.0",
31
+ "minimatch": "10.2.6",
32
+ "msgpackr": "2.0.5",
34
33
  "negotiator": "1.0.0",
35
- "openspan": "1.0.0-alpha.252",
34
+ "openspan": "1.0.0-alpha.254",
36
35
  "paseto": "3.1.4"
37
36
  },
38
37
  "scripts": {
39
- "test": "jest",
38
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
40
39
  "transpile": "tsc && npm run transpile:bans && npm run transpile:basic && npm run transpile:tokens && npm run transpile:roles && npm run transpile:federation && npm run transpile:credentials && npm run transpile:keys && npm run transpile:passkeys && npm run transpile:otp",
41
40
  "transpile:bans": "tsc -p ./components/identity.bans",
42
41
  "transpile:basic": "tsc -p ./components/identity.basic",
@@ -53,10 +52,8 @@
53
52
  },
54
53
  "devDependencies": {
55
54
  "@toa.io/extensions.storages": "*",
56
- "@types/bcryptjs": "2.4.6",
57
- "@types/content-type": "1.1.9",
58
55
  "@types/cors": "2.8.19",
59
- "@types/negotiator": "0.6.4",
56
+ "@types/negotiator": "0.6.5",
60
57
  "jest-esbuild": "0.4.0"
61
58
  },
62
59
  "jest": {
@@ -65,5 +62,5 @@
65
62
  },
66
63
  "testEnvironment": "node"
67
64
  },
68
- "gitHead": "ca97991a1c8a6e770a51e0899b0c5dbeacbb89ed"
65
+ "gitHead": "a8990df97f971060686bd70a965f78e98070a983"
69
66
  }
@@ -0,0 +1,9 @@
1
+ import { Err } from 'error-value'
2
+ import { encode } from './yaml'
3
+
4
+ it('encodes error values as their public properties', () => {
5
+ const value = new Err('INVALID_USERNAME', 'Username is not meeting the requirements')
6
+
7
+ expect(encode(value).toString())
8
+ .toBe('code: INVALID_USERNAME\nmessage: Username is not meeting the requirements\n')
9
+ })
@@ -10,7 +10,8 @@ export function decode (buffer: Buffer, charset = 'utf-8'): any {
10
10
  }
11
11
 
12
12
  export function encode (value: any): Buffer {
13
- const text = yaml.dump(value, { lineWidth: -1, noRefs: true })
13
+ const serializable = value instanceof Error ? Object.assign({}, value) : value
14
+ const text = yaml.dump(serializable, { lineWidth: -1, noRefs: true })
14
15
 
15
16
  return Buffer.from(text)
16
17
  }
@@ -1,5 +1,5 @@
1
1
  import { Readable } from 'node:stream'
2
- import contentType from 'content-type'
2
+ import * as contentType from 'content-type'
3
3
  import { console } from 'openspan'
4
4
  import { formats } from './formats'
5
5
  import { BadRequest, NotAcceptable, UnsupportedMediaType } from './exceptions'
@@ -3,6 +3,7 @@ import { EventEmitter } from 'node:events'
3
3
 
4
4
  export class Interval extends EventEmitter {
5
5
  public number: number = 0
6
+ private timeout: ReturnType<typeof setTimeout> | null = null
6
7
  private interval: ReturnType<typeof setInterval> | null = null
7
8
 
8
9
  public constructor (interval: number) {
@@ -13,14 +14,22 @@ export class Interval extends EventEmitter {
13
14
 
14
15
  assert.ok(shift >= 0, 'shift must be positive')
15
16
 
16
- setTimeout(() => this.start(interval), shift)
17
+ this.timeout = setTimeout(() => this.start(interval), shift)
18
+ this.timeout.unref()
17
19
  }
18
20
 
19
21
  public start (interval: number): void {
22
+ this.timeout = null
20
23
  this.interval = setInterval(() => this.emit('tick'), interval)
24
+ this.interval.unref()
21
25
  }
22
26
 
23
27
  public dispose (): void {
28
+ if (this.timeout !== null) {
29
+ clearTimeout(this.timeout)
30
+ this.timeout = null
31
+ }
32
+
24
33
  if (this.interval !== null) {
25
34
  clearInterval(this.interval)
26
35
  this.interval = null
@@ -33,7 +33,8 @@ function decode(buffer, charset = 'utf-8') {
33
33
  }
34
34
  exports.decode = decode;
35
35
  function encode(value) {
36
- const text = yaml.dump(value, { lineWidth: -1, noRefs: true });
36
+ const serializable = value instanceof Error ? Object.assign({}, value) : value;
37
+ const text = yaml.dump(serializable, { lineWidth: -1, noRefs: true });
37
38
  return Buffer.from(text);
38
39
  }
39
40
  exports.encode = encode;
@@ -1 +1 @@
1
- {"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../../source/HTTP/formats/yaml.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA+B;AAElB,QAAA,IAAI,GAAG,kBAAkB,CAAA;AACzB,QAAA,SAAS,GAAG,gBAAgB,CAAA;AAEzC,SAAgB,MAAM,CAAE,MAAc,EAAE,OAAO,GAAG,OAAO;IACvD,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAyB,CAAC,CAAA;IAEvD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC;AAJD,wBAIC;AAED,SAAgB,MAAM,CAAE,KAAU;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAE9D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAJD,wBAIC"}
1
+ {"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../../source/HTTP/formats/yaml.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA+B;AAElB,QAAA,IAAI,GAAG,kBAAkB,CAAA;AACzB,QAAA,SAAS,GAAG,gBAAgB,CAAA;AAEzC,SAAgB,MAAM,CAAE,MAAc,EAAE,OAAO,GAAG,OAAO;IACvD,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAyB,CAAC,CAAA;IAEvD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC;AAJD,wBAIC;AAED,SAAgB,MAAM,CAAE,KAAU;IAChC,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IAC9E,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAErE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AALD,wBAKC"}
@@ -1,11 +1,31 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.multipart = exports.read = exports.write = void 0;
7
27
  const node_stream_1 = require("node:stream");
8
- const content_type_1 = __importDefault(require("content-type"));
28
+ const contentType = __importStar(require("content-type"));
9
29
  const openspan_1 = require("openspan");
10
30
  const formats_1 = require("./formats");
11
31
  const exceptions_1 = require("./exceptions");
@@ -36,7 +56,7 @@ async function read(context) {
36
56
  const header = context.request.headers['content-type'];
37
57
  if (header === undefined)
38
58
  return undefined;
39
- const { type, parameters } = content_type_1.default.parse(header);
59
+ const { type, parameters } = contentType.parse(header);
40
60
  if (!(type in formats_1.formats))
41
61
  throw new exceptions_1.UnsupportedMediaType();
42
62
  const format = formats_1.formats[type];
@@ -1 +1 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../source/HTTP/messages.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAsC;AACtC,gEAAsC;AACtC,uCAAkC;AAClC,uCAAmC;AACnC,6CAA8E;AAI9E,MAAM,MAAM,GAAG,cAAc,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE;IAClE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QAC3E,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;AAEzE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;AAEzC,KAAK,UAAU,KAAK,CAAE,OAAgB,EAAE,QAA6B,EAAE,OAAwB;IACpG,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ;QAChD,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;IAE1B,IAAI,OAAO,EAAE,MAAM,KAAK,SAAS;QAC/B,QAAQ,CAAC,UAAU,GAAG,OAAO,CAAC,MAAM,CAAA;IAEtC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACpC,OAAO,CAAC,OAAO,EAAE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,CACjC,kBAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,EAC1D,sBAAsB,CAAC,CAAA;AAC3B,CAAC"}
@@ -2,6 +2,7 @@
2
2
  import { EventEmitter } from 'node:events';
3
3
  export declare class Interval extends EventEmitter {
4
4
  number: number;
5
+ private timeout;
5
6
  private interval;
6
7
  constructor(interval: number);
7
8
  start(interval: number): void;
@@ -8,18 +8,26 @@ const node_assert_1 = __importDefault(require("node:assert"));
8
8
  const node_events_1 = require("node:events");
9
9
  class Interval extends node_events_1.EventEmitter {
10
10
  number = 0;
11
+ timeout = null;
11
12
  interval = null;
12
13
  constructor(interval) {
13
14
  super();
14
15
  const number = Math.ceil(Date.now() / interval);
15
16
  const shift = number * interval - Date.now();
16
17
  node_assert_1.default.ok(shift >= 0, 'shift must be positive');
17
- setTimeout(() => this.start(interval), shift);
18
+ this.timeout = setTimeout(() => this.start(interval), shift);
19
+ this.timeout.unref();
18
20
  }
19
21
  start(interval) {
22
+ this.timeout = null;
20
23
  this.interval = setInterval(() => this.emit('tick'), interval);
24
+ this.interval.unref();
21
25
  }
22
26
  dispose() {
27
+ if (this.timeout !== null) {
28
+ clearTimeout(this.timeout);
29
+ this.timeout = null;
30
+ }
23
31
  if (this.interval !== null) {
24
32
  clearInterval(this.interval);
25
33
  this.interval = null;
@@ -1 +1 @@
1
- {"version":3,"file":"Interval.js","sourceRoot":"","sources":["../../../../../source/directives/io/lib/throttle/Interval.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAChC,6CAA0C;AAE1C,MAAa,QAAS,SAAQ,0BAAY;IACjC,MAAM,GAAW,CAAC,CAAA;IACjB,QAAQ,GAA0C,IAAI,CAAA;IAE9D,YAAoB,QAAgB;QAClC,KAAK,EAAE,CAAA;QAEP,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAA;Q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