@toa.io/extensions.exposition 1.0.0-alpha.217 → 1.0.0-alpha.219

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.
@@ -69,3 +69,33 @@ Feature: OTP authentication
69
69
  """
70
70
  401 Unauthorized
71
71
  """
72
+
73
+ Scenario: Generate own OTP
74
+ Given transient identity bob
75
+ When the following request is received:
76
+ """
77
+ POST /identity/otp/${{ bob.id }}/ HTTP/1.1
78
+ host: nex.toa.io
79
+ authorization: Token ${{ bob.token }}
80
+ accept: application/yaml
81
+ """
82
+ Then the following reply is sent:
83
+ """
84
+ 201 Created
85
+
86
+ code: '${{ bob.code }}'
87
+ """
88
+
89
+ When the following request is received:
90
+ """
91
+ GET /identity/ HTTP/1.1
92
+ host: nex.toa.io
93
+ authorization: OTP #{{ otp bob }}
94
+ accept: application/yaml
95
+ """
96
+ Then the following reply is sent:
97
+ """
98
+ 200 OK
99
+
100
+ id: ${{ bob.id }}
101
+ """
@@ -3,4 +3,16 @@ import { binding } from 'cucumber-tsflow'
3
3
 
4
4
  @binding()
5
5
  export class Captures extends http.Captures {
6
+ public constructor () {
7
+ super(functions)
8
+ }
9
+ }
10
+
11
+ const functions: http.Functions = {
12
+ otp: function (this: Captures, value: string, arg: string): string {
13
+ const identity = this.get(arg + '.id')
14
+ const code = this.get(arg + '.code')
15
+
16
+ return Buffer.from(`${identity}:${code}`).toString('base64')
17
+ }
6
18
  }
@@ -23,6 +23,7 @@ export class HTTP extends http.Agent {
23
23
  @when('the following request is received:')
24
24
  public override async request (input: string): Promise<any> {
25
25
  await this.gateway.start()
26
+
26
27
  this.fetched = await super.request(input)
27
28
  }
28
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/extensions.exposition",
3
- "version": "1.0.0-alpha.217",
3
+ "version": "1.0.0-alpha.219",
4
4
  "description": "Toa Exposition",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -19,14 +19,14 @@
19
19
  "dependencies": {
20
20
  "@aws-sdk/protocol-http": "3.370.0",
21
21
  "@simplewebauthn/server": "13.1.1",
22
- "@toa.io/core": "1.0.0-alpha.212",
23
- "@toa.io/generic": "1.0.0-alpha.208",
24
- "@toa.io/schemas": "1.0.0-alpha.208",
22
+ "@toa.io/core": "1.0.0-alpha.219",
23
+ "@toa.io/generic": "1.0.0-alpha.219",
24
+ "@toa.io/schemas": "1.0.0-alpha.219",
25
25
  "bcryptjs": "2.4.3",
26
26
  "content-type": "1.0.5",
27
27
  "error-value": "0.4.2",
28
28
  "jose": "5.10.0",
29
- "js-yaml": "4.1.1",
29
+ "js-yaml": "4.2.0",
30
30
  "lru-cache": "11.2.7",
31
31
  "matchacho": "0.3.5",
32
32
  "minimatch": "10.2.4",
@@ -64,5 +64,5 @@
64
64
  },
65
65
  "testEnvironment": "node"
66
66
  },
67
- "gitHead": "7ee2397d08eaf64a4e41c0eaee037ffe797db5ba"
67
+ "gitHead": "c9f3ec1d4b3a17bbe445315f255e589267956eb0"
68
68
  }