@toa.io/extensions.exposition 1.0.0-alpha.130 → 1.0.0-alpha.131
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/identity.passkeys/manifest.toa.yaml +7 -2
- package/components/identity.passkeys/operations/challenge.d.ts +7 -3
- package/components/identity.passkeys/operations/challenge.js +25 -16
- package/components/identity.passkeys/operations/challenge.js.map +1 -1
- package/components/identity.passkeys/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.passkeys/source/challenge.ts +35 -21
- package/features/passkeys.feature +34 -0
- package/package.json +2 -2
- package/source/directives/auth/Incept.ts +12 -1
- package/transpiled/directives/auth/Incept.js +10 -1
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
|
@@ -12,12 +12,46 @@ Feature: Web Authentication
|
|
|
12
12
|
host: nex.toa.io
|
|
13
13
|
authorization: Token ${{ identity.token }}
|
|
14
14
|
accept: application/yaml
|
|
15
|
+
content-type: application/yaml
|
|
16
|
+
|
|
17
|
+
type: creation
|
|
18
|
+
"""
|
|
19
|
+
Then the following reply is sent:
|
|
20
|
+
"""
|
|
21
|
+
201 Created
|
|
22
|
+
|
|
23
|
+
challenge: ${{ challenge }}
|
|
24
|
+
identity: ${{ identity.id }}
|
|
25
|
+
timeout: 60000
|
|
26
|
+
pubKeyCredParams:
|
|
27
|
+
- type: public-key
|
|
28
|
+
alg: -7
|
|
29
|
+
- type: public-key
|
|
30
|
+
alg: -257
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
Scenario: Create a challenge to create a passkey to new identity
|
|
34
|
+
Given the `identity.passkeys` configuration:
|
|
35
|
+
"""yaml
|
|
36
|
+
name: Nex
|
|
37
|
+
"""
|
|
38
|
+
And transient identity
|
|
39
|
+
When the following request is received:
|
|
40
|
+
"""
|
|
41
|
+
POST /identity/passkeys/challenges/ HTTP/1.1
|
|
42
|
+
host: nex.toa.io
|
|
43
|
+
accept: application/yaml
|
|
44
|
+
content-type: application/yaml
|
|
45
|
+
|
|
46
|
+
type: creation
|
|
15
47
|
"""
|
|
16
48
|
Then the following reply is sent:
|
|
17
49
|
"""
|
|
18
50
|
201 Created
|
|
51
|
+
authorization: Token ${{ token }}
|
|
19
52
|
|
|
20
53
|
challenge: ${{ challenge }}
|
|
54
|
+
identity: ${{ identity }}
|
|
21
55
|
timeout: 60000
|
|
22
56
|
pubKeyCredParams:
|
|
23
57
|
- type: public-key
|
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.131",
|
|
4
4
|
"description": "Toa Exposition",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"@types/negotiator": "0.6.1",
|
|
64
64
|
"jest-esbuild": "0.3.0"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "e1cf8fb46f50cdacff0f3f32d03e032929c9e629"
|
|
67
67
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import assert from 'node:assert'
|
|
2
|
+
import { console } from 'openspan'
|
|
2
3
|
import * as http from '../../HTTP'
|
|
3
4
|
import { split } from './split'
|
|
4
5
|
import { create } from './create'
|
|
@@ -35,12 +36,21 @@ export class Incept implements Directive {
|
|
|
35
36
|
public async settle (context: Context, response: http.OutgoingMessage): Promise<void> {
|
|
36
37
|
const id = response.body?.[this.property ?? 'id']
|
|
37
38
|
|
|
39
|
+
if (id === undefined) {
|
|
40
|
+
console.debug('Inception skipped: response does not contain expected property', {
|
|
41
|
+
property: this.property,
|
|
42
|
+
response
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
assert(typeof id === 'string', `Response body property "${this.property}" expected to be a string`)
|
|
39
49
|
|
|
40
50
|
if (context.request.headers.authorization !== undefined)
|
|
41
51
|
context.identity = await this.incept(context, id)
|
|
42
52
|
else
|
|
43
|
-
context.identity = { id, scheme: null, refresh: true }
|
|
53
|
+
context.identity = { id, scheme: null, refresh: true, roles: [] }
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
private async incept (context: Context, id: string): Promise<Identity> {
|
|
@@ -67,6 +77,7 @@ export class Incept implements Directive {
|
|
|
67
77
|
throw new http.UnprocessableEntity(identity)
|
|
68
78
|
|
|
69
79
|
identity.scheme = scheme
|
|
80
|
+
identity.roles = []
|
|
70
81
|
|
|
71
82
|
return identity
|
|
72
83
|
}
|
|
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Incept = void 0;
|
|
30
30
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
31
|
+
const openspan_1 = require("openspan");
|
|
31
32
|
const http = __importStar(require("../../HTTP"));
|
|
32
33
|
const split_1 = require("./split");
|
|
33
34
|
const create_1 = require("./create");
|
|
@@ -52,11 +53,18 @@ class Incept {
|
|
|
52
53
|
}
|
|
53
54
|
async settle(context, response) {
|
|
54
55
|
const id = response.body?.[this.property ?? 'id'];
|
|
56
|
+
if (id === undefined) {
|
|
57
|
+
openspan_1.console.debug('Inception skipped: response does not contain expected property', {
|
|
58
|
+
property: this.property,
|
|
59
|
+
response
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
55
63
|
(0, node_assert_1.default)(typeof id === 'string', `Response body property "${this.property}" expected to be a string`);
|
|
56
64
|
if (context.request.headers.authorization !== undefined)
|
|
57
65
|
context.identity = await this.incept(context, id);
|
|
58
66
|
else
|
|
59
|
-
context.identity = { id, scheme: null, refresh: true };
|
|
67
|
+
context.identity = { id, scheme: null, refresh: true, roles: [] };
|
|
60
68
|
}
|
|
61
69
|
async incept(context, id) {
|
|
62
70
|
const [scheme, credentials] = (0, split_1.split)(context.request.headers.authorization);
|
|
@@ -76,6 +84,7 @@ class Incept {
|
|
|
76
84
|
if (identity instanceof Error)
|
|
77
85
|
throw new http.UnprocessableEntity(identity);
|
|
78
86
|
identity.scheme = scheme;
|
|
87
|
+
identity.roles = [];
|
|
79
88
|
return identity;
|
|
80
89
|
}
|
|
81
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Incept.js","sourceRoot":"","sources":["../../../source/directives/auth/Incept.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgC;AAChC,iDAAkC;AAClC,mCAA+B;AAC/B,qCAAiC;AACjC,uCAAgD;AAIhD,MAAa,MAAM;IACA,QAAQ,CAAe;IACvB,SAAS,CAAW;IACpB,OAAO,GAAY,EAAwB,CAAA;IAE5D,YAAoB,QAAgB,EAAE,SAAoB;QACxD,qBAAM,CAAC,EAAE,CAAC,QAAQ,KAAK,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ,EACzD,8CAA8C,CAAC,CAAA;QAEjD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,SAAS,CAAE,QAAyB;QACzC,OAAO,QAAQ,KAAK,IAAI,CAAA;IAC1B,CAAC;IAEM,KAAK,CAAE,OAAgB;QAC5B,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI;YACxB,OAAO,IAAI,CAAA;QAEb,MAAM,IAAI,GAAG,IAAA,eAAM,EAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QAE1D,OAAO,EAAE,IAAI,EAAE,CAAA;IACjB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAE,OAAgB,EAAE,QAA8B;QACnE,MAAM,EAAE,GAAG,QAAQ,CAAC,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