@toa.io/extensions.exposition 1.0.0-alpha.272 → 1.0.0-alpha.274

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 (156) hide show
  1. package/CHANGELOG.md +211 -0
  2. package/components/exposition.atom/manifest.toa.yaml +3 -1
  3. package/components/exposition.octets/manifest.toa.yaml +28 -10
  4. package/components/exposition.octets/operations/put.js +20 -5
  5. package/components/identity.bans/manifest.toa.yaml +26 -7
  6. package/components/identity.bans/operations/tsconfig.tsbuildinfo +1 -1
  7. package/components/identity.basic/manifest.toa.yaml +106 -30
  8. package/components/identity.basic/operations/authenticate.js +7 -4
  9. package/components/identity.basic/operations/authenticate.js.map +1 -1
  10. package/components/identity.basic/operations/incept.js +3 -2
  11. package/components/identity.basic/operations/incept.js.map +1 -1
  12. package/components/identity.basic/operations/transit.js +17 -6
  13. package/components/identity.basic/operations/transit.js.map +1 -1
  14. package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
  15. package/components/identity.basic/operations/types.d.ts +2 -2
  16. package/components/identity.basic/source/authenticate.ts +8 -4
  17. package/components/identity.basic/source/incept.ts +3 -2
  18. package/components/identity.basic/source/transit.ts +20 -6
  19. package/components/identity.basic/source/types.ts +2 -2
  20. package/components/identity.credentials/manifest.toa.yaml +34 -13
  21. package/components/identity.credentials/operations/tsconfig.tsbuildinfo +1 -1
  22. package/components/identity.federation/manifest.toa.yaml +120 -28
  23. package/components/identity.federation/operations/authenticate.js +3 -2
  24. package/components/identity.federation/operations/authenticate.js.map +1 -1
  25. package/components/identity.federation/operations/create.js +4 -2
  26. package/components/identity.federation/operations/create.js.map +1 -1
  27. package/components/identity.federation/operations/lib/errors.d.ts +70 -11
  28. package/components/identity.federation/operations/lib/errors.js +40 -11
  29. package/components/identity.federation/operations/lib/errors.js.map +1 -1
  30. package/components/identity.federation/operations/lib/exchange.js +2 -2
  31. package/components/identity.federation/operations/lib/exchange.js.map +1 -1
  32. package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
  33. package/components/identity.federation/operations/types/configuration.d.ts +3 -2
  34. package/components/identity.federation/source/authenticate.ts +3 -2
  35. package/components/identity.federation/source/create.ts +4 -2
  36. package/components/identity.federation/source/lib/errors.ts +49 -12
  37. package/components/identity.federation/source/lib/exchange.ts +2 -2
  38. package/components/identity.federation/source/types/configuration.ts +4 -2
  39. package/components/identity.keys/manifest.toa.yaml +14 -6
  40. package/components/identity.keys/operations/tsconfig.tsbuildinfo +1 -1
  41. package/components/identity.otp/manifest.toa.yaml +44 -15
  42. package/components/identity.otp/operations/authenticate.js +9 -4
  43. package/components/identity.otp/operations/authenticate.js.map +1 -1
  44. package/components/identity.otp/operations/tsconfig.tsbuildinfo +1 -1
  45. package/components/identity.otp/source/authenticate.ts +11 -4
  46. package/components/identity.passkeys/manifest.toa.yaml +38 -8
  47. package/components/identity.passkeys/operations/authenticate.js +3 -2
  48. package/components/identity.passkeys/operations/authenticate.js.map +1 -1
  49. package/components/identity.passkeys/operations/create.js +6 -3
  50. package/components/identity.passkeys/operations/create.js.map +1 -1
  51. package/components/identity.passkeys/operations/tsconfig.tsbuildinfo +1 -1
  52. package/components/identity.passkeys/operations/use.js +6 -3
  53. package/components/identity.passkeys/operations/use.js.map +1 -1
  54. package/components/identity.passkeys/source/authenticate.ts +3 -2
  55. package/components/identity.passkeys/source/create.ts +7 -3
  56. package/components/identity.passkeys/source/use.ts +7 -3
  57. package/components/identity.roles/manifest.toa.yaml +41 -10
  58. package/components/identity.roles/operations/grant.js +3 -2
  59. package/components/identity.roles/operations/grant.js.map +1 -1
  60. package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
  61. package/components/identity.roles/source/grant.ts +3 -2
  62. package/components/identity.tokens/manifest.toa.yaml +99 -39
  63. package/components/identity.tokens/operations/authenticate.js +6 -3
  64. package/components/identity.tokens/operations/authenticate.js.map +1 -1
  65. package/components/identity.tokens/operations/decrypt.js +10 -5
  66. package/components/identity.tokens/operations/decrypt.js.map +1 -1
  67. package/components/identity.tokens/operations/encrypt.js +4 -3
  68. package/components/identity.tokens/operations/encrypt.js.map +1 -1
  69. package/components/identity.tokens/operations/lib/types.d.ts +3 -2
  70. package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
  71. package/components/identity.tokens/source/authenticate.test.ts +7 -2
  72. package/components/identity.tokens/source/authenticate.ts +7 -3
  73. package/components/identity.tokens/source/decrypt.test.ts +13 -7
  74. package/components/identity.tokens/source/decrypt.ts +12 -5
  75. package/components/identity.tokens/source/encrypt.test.ts +9 -4
  76. package/components/identity.tokens/source/encrypt.ts +4 -3
  77. package/components/identity.tokens/source/lib/types.ts +3 -2
  78. package/context.toa.yaml +2 -2
  79. package/documentation/components.md +1 -1
  80. package/documentation/identity.md +4 -1
  81. package/features/configuration.feature +207 -0
  82. package/features/cors.feature +1 -1
  83. package/features/dev.feature +1 -1
  84. package/features/identity.federation.feature +18 -9
  85. package/features/{identtiy.tokens.custom.feature → identity.tokens.custom.feature} +39 -0
  86. package/features/introspection.map.feature +16 -0
  87. package/features/map.feature +1 -1
  88. package/features/octets.download.feature +1 -1
  89. package/features/octets.meta.feature +1 -1
  90. package/features/passkeys.feature +8 -8
  91. package/features/require.feature +2 -2
  92. package/features/response.feature +3 -3
  93. package/features/steps/Components.ts +41 -4
  94. package/features/steps/Gateway.ts +61 -23
  95. package/features/steps/HTTP.ts +3 -5
  96. package/features/steps/Parameters.ts +2 -3
  97. package/features/steps/Realtime.ts +4 -4
  98. package/features/steps/Workspace.ts +8 -3
  99. package/features/steps/components/audit/manifest.toa.yaml +12 -5
  100. package/features/steps/components/echo/manifest.toa.yaml +33 -8
  101. package/features/steps/components/notify/manifest.toa.yaml +12 -5
  102. package/features/steps/components/octets.tester/manifest.toa.yaml +43 -14
  103. package/features/steps/components/orders/manifest.toa.yaml +22 -5
  104. package/features/steps/components/pots/manifest.toa.yaml +71 -17
  105. package/features/steps/components/pricing/manifest.toa.yaml +8 -2
  106. package/features/steps/components/sequences/manifest.toa.yaml +3 -1
  107. package/features/steps/components/users/manifest.toa.yaml +18 -3
  108. package/features/steps/components/users.properties/manifest.toa.yaml +12 -2
  109. package/package.json +5 -6
  110. package/schemas/annotation.cos.yaml +37 -17
  111. package/schemas/directive.cos.yaml +7 -3
  112. package/schemas/io/throttle.cos.yaml +47 -8
  113. package/schemas/method.cos.yaml +21 -9
  114. package/schemas/node.cos.yaml +22 -7
  115. package/schemas/octets/delete.cos.yaml +15 -2
  116. package/schemas/octets/get.cos.yaml +5 -2
  117. package/schemas/octets/put.cos.yaml +6 -3
  118. package/schemas/octets/workflow.cos.yaml +0 -1
  119. package/schemas/query.cos.yaml +31 -14
  120. package/schemas/querystring.cos.yaml +19 -9
  121. package/schemas/range.cos.yaml +10 -2
  122. package/schemas/route.cos.yaml +6 -2
  123. package/source/Branch.test.ts +37 -0
  124. package/source/Branch.ts +37 -0
  125. package/source/Factory.ts +5 -5
  126. package/source/Gateway.ts +20 -13
  127. package/source/HTTP/formats/yaml.test.ts +10 -2
  128. package/source/HTTP/formats/yaml.ts +21 -1
  129. package/source/RTD/Tree.ts +4 -1
  130. package/source/Tenant.ts +3 -3
  131. package/source/deployment.ts +3 -4
  132. package/source/directives/map/Headers.ts +8 -1
  133. package/source/directives/octets/Put.ts +6 -3
  134. package/source/root.ts +2 -2
  135. package/transpiled/Branch.d.ts +23 -0
  136. package/transpiled/Branch.js +16 -0
  137. package/transpiled/Branch.js.map +1 -1
  138. package/transpiled/Factory.js +4 -4
  139. package/transpiled/Factory.js.map +1 -1
  140. package/transpiled/Gateway.js +17 -7
  141. package/transpiled/Gateway.js.map +1 -1
  142. package/transpiled/HTTP/formats/yaml.js +15 -1
  143. package/transpiled/HTTP/formats/yaml.js.map +1 -1
  144. package/transpiled/RTD/Tree.js +4 -1
  145. package/transpiled/RTD/Tree.js.map +1 -1
  146. package/transpiled/Tenant.d.ts +1 -1
  147. package/transpiled/Tenant.js +1 -1
  148. package/transpiled/Tenant.js.map +1 -1
  149. package/transpiled/deployment.js +3 -4
  150. package/transpiled/deployment.js.map +1 -1
  151. package/transpiled/directives/map/Headers.js +7 -1
  152. package/transpiled/directives/map/Headers.js.map +1 -1
  153. package/transpiled/directives/octets/Put.js.map +1 -1
  154. package/transpiled/root.js +1 -1
  155. package/transpiled/root.js.map +1 -1
  156. package/transpiled/tsconfig.tsbuildinfo +1 -1
@@ -1,3 +1,4 @@
1
+ import type { Secret } from '@toa.io/types';
1
2
  export interface Configuration {
2
3
  trust: Trust[];
3
4
  principal?: Principal;
@@ -6,11 +7,11 @@ export interface Configuration {
6
7
  export interface Trust {
7
8
  iss: string;
8
9
  aud?: string | [string, ...string[]];
9
- secret?: string;
10
+ secret?: Secret;
10
11
  signature?: {
11
12
  iss: string;
12
13
  kid: string;
13
- key: string;
14
+ key: Secret;
14
15
  };
15
16
  }
16
17
  interface Principal {
@@ -1,4 +1,3 @@
1
- import { Err } from 'error-value'
2
1
  import { newid } from '@toa.io/generic'
3
2
  import { resolve } from './lib'
4
3
  import type { JWTPayload } from 'jose'
@@ -35,7 +34,9 @@ export async function effect ({ scheme, authority, credentials }: Input, context
35
34
  return { identity: { id: credential.identity, claims } }
36
35
  }
37
36
 
38
- const ERR_NOT_FOUND = new Err('NOT_FOUND')
37
+ const ERR_NOT_FOUND = new (class NotFoundError extends Error {
38
+ public readonly code = 'NOT_FOUND'
39
+ })()
39
40
 
40
41
  interface Input {
41
42
  scheme: Scheme
@@ -1,4 +1,3 @@
1
- import { Err } from 'error-value'
2
1
  import { resolve } from './lib'
3
2
  import type { Context, Entity, Scheme } from './types'
4
3
 
@@ -36,4 +35,7 @@ export interface Input {
36
35
  id: string
37
36
  }
38
37
 
39
- const ERR_EXISTS = new Err('EXISTS', 'Federation credentials are associated with another Identity')
38
+ const ERR_EXISTS = new (class ExistsError extends Error {
39
+ public readonly code = 'EXISTS'
40
+ public override readonly message = 'Federation credentials are associated with another Identity'
41
+ })()
@@ -1,12 +1,49 @@
1
- import { Err } from 'error-value'
2
-
3
- export const ERR_TRUST = new Err('TRUST', 'Issuer not trusted')
4
- export const ERR_RESPONSE = new Err('RESPONSE', 'Request to IDP failed')
5
- export const ERR_CONFIG = new Err('CONFIG', 'Invalid OpenID configuration')
6
- export const ERR_NO_TOKEN = new Err('NO_TOKEN', 'No ID token received')
7
- export const ERR_ISS = new Err('ISS', 'Invalid issuer claim')
8
- export const ERR_SUB = new Err('SUB', 'Invalid subject claim')
9
- export const ERR_EXP = new Err('EXP', 'Token does not have an expiration time')
10
- export const ERR_REPLAY = new Err('REPLAY', 'Token has already been used')
11
- export const ERR_CODE_NOT_ENABLED = new Err('CODE_NOT_ENABLED', 'Authorization code flow is not configured')
12
- export const ERR_CODE_SCHEMA = new Err('CODE_SCHEMA', 'Invalid code credentials')
1
+ export const ERR_TRUST = new (class TrustError extends Error {
2
+ public readonly code = 'TRUST'
3
+ public override readonly message = 'Issuer not trusted'
4
+ })()
5
+
6
+ export const ERR_RESPONSE = new (class ResponseError extends Error {
7
+ public readonly code = 'RESPONSE'
8
+ public override readonly message = 'Request to IDP failed'
9
+ })()
10
+
11
+ export const ERR_CONFIG = new (class ConfigError extends Error {
12
+ public readonly code = 'CONFIG'
13
+ public override readonly message = 'Invalid OpenID configuration'
14
+ })()
15
+
16
+ export const ERR_NO_TOKEN = new (class NoTokenError extends Error {
17
+ public readonly code = 'NO_TOKEN'
18
+ public override readonly message = 'No ID token received'
19
+ })()
20
+
21
+ export const ERR_ISS = new (class IssError extends Error {
22
+ public readonly code = 'ISS'
23
+ public override readonly message = 'Invalid issuer claim'
24
+ })()
25
+
26
+ export const ERR_SUB = new (class SubError extends Error {
27
+ public readonly code = 'SUB'
28
+ public override readonly message = 'Invalid subject claim'
29
+ })()
30
+
31
+ export const ERR_EXP = new (class ExpError extends Error {
32
+ public readonly code = 'EXP'
33
+ public override readonly message = 'Token does not have an expiration time'
34
+ })()
35
+
36
+ export const ERR_REPLAY = new (class ReplayError extends Error {
37
+ public readonly code = 'REPLAY'
38
+ public override readonly message = 'Token has already been used'
39
+ })()
40
+
41
+ export const ERR_CODE_NOT_ENABLED = new (class CodeNotEnabledError extends Error {
42
+ public readonly code = 'CODE_NOT_ENABLED'
43
+ public override readonly message = 'Authorization code flow is not configured'
44
+ })()
45
+
46
+ export const ERR_CODE_SCHEMA = new (class CodeSchemaError extends Error {
47
+ public readonly code = 'CODE_SCHEMA'
48
+ public override readonly message = 'Invalid code credentials'
49
+ })()
@@ -29,7 +29,7 @@ export async function exchange (credentials: string, ctx: Ctx): Promise<Payload
29
29
 
30
30
  // array actually is not expected here, but it is a valid format
31
31
  const aud = Array.isArray(trusted.aud) ? trusted.aud[0] : trusted.aud
32
- const secret = trusted.secret ?? await sign(trusted)
32
+ const secret = trusted.secret === undefined ? await sign(trusted) : trusted.secret.unwrap()
33
33
  const params = new URLSearchParams()
34
34
 
35
35
  params.append('grant_type', 'authorization_code')
@@ -95,7 +95,7 @@ async function sign (trust: Trust): Promise<string> {
95
95
  const signature = trust.signature!
96
96
  const aud = Array.isArray(trust.aud) ? trust.aud[0] : trust.aud!
97
97
  const now = Math.floor(Date.now() / 1000)
98
- const key = await jose.importPKCS8(signature.key, 'ES256')
98
+ const key = await jose.importPKCS8(signature.key.unwrap(), 'ES256')
99
99
 
100
100
  return await new jose.SignJWT({})
101
101
  .setProtectedHeader({ alg: 'ES256', kid: signature.kid })
@@ -1,3 +1,5 @@
1
+ import type { Secret } from '@toa.io/types'
2
+
1
3
  export interface Configuration {
2
4
  trust: Trust[]
3
5
  principal?: Principal
@@ -7,11 +9,11 @@ export interface Configuration {
7
9
  export interface Trust {
8
10
  iss: string
9
11
  aud?: string | [string, ...string[]]
10
- secret?: string
12
+ secret?: Secret
11
13
  signature?: {
12
14
  iss: string
13
15
  kid: string
14
- key: string
16
+ key: Secret
15
17
  }
16
18
  }
17
19
 
@@ -4,20 +4,21 @@ name: keys
4
4
  entity:
5
5
  schema:
6
6
  properties:
7
- identity: &identity
7
+ identity:
8
8
  type: string
9
9
  key:
10
10
  type: string
11
- label: &label
11
+ label:
12
12
  type: string
13
13
  minLength: 1
14
14
  maxLength: 64
15
- expires: &expires
15
+ expires:
16
16
  type: number
17
17
  required:
18
18
  - identity
19
19
  - key
20
20
  - label
21
+ type: object
21
22
  index:
22
23
  identity:
23
24
  identity: asc
@@ -27,12 +28,18 @@ operations:
27
28
  query: false
28
29
  input:
29
30
  properties:
30
- identity: *identity
31
- label: *label
32
- expires: *expires
31
+ identity:
32
+ type: string
33
+ label:
34
+ type: string
35
+ minLength: 1
36
+ maxLength: 64
37
+ expires:
38
+ type: number
33
39
  required:
34
40
  - identity
35
41
  - label
42
+ type: object
36
43
  output:
37
44
  properties:
38
45
  id:
@@ -42,6 +49,7 @@ operations:
42
49
  required:
43
50
  - id
44
51
  - key
52
+ type: object
45
53
 
46
54
  exposition:
47
55
  /:identity: