@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.
- package/components/context.toa.yaml +2 -2
- package/components/identity.basic/manifest.toa.yaml +18 -9
- package/components/identity.basic/operations/authenticate.d.ts +5 -1
- package/components/identity.basic/operations/authenticate.js +2 -2
- package/components/identity.basic/operations/authenticate.js.map +1 -1
- package/components/identity.basic/operations/incept.d.ts +11 -0
- package/components/identity.basic/operations/incept.js +13 -0
- package/components/identity.basic/operations/incept.js.map +1 -0
- package/components/identity.basic/operations/transit.d.ts +3 -3
- package/components/identity.basic/operations/transit.js +5 -3
- package/components/identity.basic/operations/transit.js.map +1 -1
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/types.d.ts +2 -0
- package/components/identity.basic/source/authenticate.ts +12 -5
- package/components/identity.basic/source/incept.ts +22 -0
- package/components/identity.basic/source/transit.ts +7 -5
- package/components/identity.basic/source/types.ts +2 -0
- package/components/identity.federation/manifest.toa.yaml +28 -11
- package/components/identity.federation/operations/authenticate.d.ts +2 -2
- package/components/identity.federation/operations/authenticate.js +6 -5
- package/components/identity.federation/operations/authenticate.js.map +1 -1
- package/components/identity.federation/operations/incept.d.ts +11 -0
- package/components/identity.federation/operations/{create.js → incept.js} +6 -7
- package/components/identity.federation/operations/incept.js.map +1 -0
- package/components/identity.federation/operations/lib/jwt.js +3 -3
- package/components/identity.federation/operations/lib/jwt.js.map +1 -1
- package/components/identity.federation/operations/schemas.d.ts +7 -3
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/operations/types.d.ts +5 -0
- package/components/identity.federation/source/authenticate.ts +9 -6
- package/components/identity.federation/source/{create.ts → incept.ts} +10 -9
- package/components/identity.federation/source/lib/jwt.test.ts +2 -2
- package/components/identity.federation/source/lib/jwt.ts +3 -3
- package/components/identity.federation/source/schemas.ts +7 -3
- package/components/identity.federation/source/types.ts +6 -0
- package/components/identity.tokens/manifest.toa.yaml +7 -1
- package/components/identity.tokens/operations/authenticate.d.ts +2 -2
- package/components/identity.tokens/operations/authenticate.js +5 -2
- package/components/identity.tokens/operations/authenticate.js.map +1 -1
- package/components/identity.tokens/operations/decrypt.js +1 -0
- package/components/identity.tokens/operations/decrypt.js.map +1 -1
- package/components/identity.tokens/operations/encrypt.js +1 -0
- package/components/identity.tokens/operations/encrypt.js.map +1 -1
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/operations/types.d.ts +7 -0
- package/components/identity.tokens/source/authenticate.test.ts +11 -4
- package/components/identity.tokens/source/authenticate.ts +7 -3
- package/components/identity.tokens/source/decrypt.test.ts +5 -3
- package/components/identity.tokens/source/decrypt.ts +9 -8
- package/components/identity.tokens/source/encrypt.test.ts +4 -1
- package/components/identity.tokens/source/encrypt.ts +1 -0
- package/components/identity.tokens/source/types.ts +8 -0
- package/components/octets.storage/manifest.toa.yaml +0 -6
- package/documentation/authorities.md +53 -0
- package/documentation/components.md +3 -3
- package/documentation/identity.md +17 -22
- package/documentation/vary.md +5 -11
- package/features/access.feature +55 -7
- package/features/annotation.feature +1 -0
- package/features/authorities.basic.feature +140 -0
- package/features/authorities.feature +32 -0
- package/features/authorities.federation.feature +99 -0
- package/features/authorities.tokens.feature +118 -0
- package/features/body.feature +2 -0
- package/features/cache.feature +39 -5
- package/features/cors.feature +4 -0
- package/features/directives.feature +3 -0
- package/features/dynamic.feature +4 -0
- package/features/errors.feature +12 -1
- package/features/etag.feature +6 -0
- package/features/identity.bans.feature +12 -3
- package/features/identity.basic.feature +34 -15
- package/features/identity.feature +7 -2
- package/features/identity.federation.feature +14 -4
- package/features/identity.roles.feature +29 -17
- package/features/identity.tokens.feature +18 -6
- package/features/io.feature +9 -0
- package/features/octets.entries.feature +8 -0
- package/features/octets.feature +17 -54
- package/features/octets.meta.feature +3 -0
- package/features/octets.workflows.feature +13 -0
- package/features/queries.feature +8 -0
- package/features/require.feature +3 -0
- package/features/response.feature +5 -2
- package/features/routes.feature +7 -0
- package/features/steps/Gateway.ts +23 -6
- package/features/streams.feature +1 -0
- package/features/timing.feature +3 -0
- package/features/vary.feature +49 -0
- package/package.json +7 -7
- package/readme.md +19 -14
- package/schemas/annotation.cos.yaml +1 -1
- package/source/Annotation.ts +3 -3
- package/source/Endpoint.ts +1 -1
- package/source/Factory.ts +8 -10
- package/source/Gateway.ts +2 -6
- package/source/HTTP/Context.ts +3 -1
- package/source/HTTP/Server.ts +23 -26
- package/source/HTTP/exceptions.ts +6 -0
- package/source/Query.ts +9 -5
- package/source/deployment.ts +25 -21
- package/source/directives/auth/Authorization.ts +18 -8
- package/source/directives/auth/Incept.ts +2 -1
- package/source/directives/octets/Octets.ts +0 -2
- package/source/directives/vary/embeddings/Authority.ts +8 -0
- package/source/directives/vary/embeddings/index.ts +3 -1
- package/source/schemas.ts +1 -1
- package/transpiled/Annotation.d.ts +3 -3
- package/transpiled/Endpoint.js +1 -1
- package/transpiled/Endpoint.js.map +1 -1
- package/transpiled/Factory.js +9 -8
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Context.d.ts +2 -1
- package/transpiled/HTTP/Context.js +3 -1
- package/transpiled/HTTP/Context.js.map +1 -1
- package/transpiled/HTTP/Server.d.ts +8 -1
- package/transpiled/HTTP/Server.js +14 -20
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/HTTP/exceptions.d.ts +3 -0
- package/transpiled/HTTP/exceptions.js +7 -1
- package/transpiled/HTTP/exceptions.js.map +1 -1
- package/transpiled/Query.js +2 -2
- package/transpiled/Query.js.map +1 -1
- package/transpiled/deployment.d.ts +1 -1
- package/transpiled/deployment.js +21 -19
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/directives/auth/Authorization.js +9 -4
- package/transpiled/directives/auth/Authorization.js.map +1 -1
- package/transpiled/directives/auth/Incept.js +2 -1
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/directives/octets/Octets.js +0 -2
- package/transpiled/directives/octets/Octets.js.map +1 -1
- package/transpiled/directives/vary/embeddings/Authority.d.ts +5 -0
- package/transpiled/directives/vary/embeddings/Authority.js +10 -0
- package/transpiled/directives/vary/embeddings/Authority.js.map +1 -0
- package/transpiled/directives/vary/embeddings/index.js +3 -1
- package/transpiled/directives/vary/embeddings/index.js.map +1 -1
- package/transpiled/schemas.d.ts +1 -1
- package/transpiled/schemas.js +2 -2
- package/transpiled/schemas.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/create.d.ts +0 -10
- package/components/identity.basic/operations/create.js +0 -10
- package/components/identity.basic/operations/create.js.map +0 -1
- package/components/identity.basic/source/create.ts +0 -18
- package/components/identity.federation/operations/create.d.ts +0 -10
- package/components/identity.federation/operations/create.js.map +0 -1
- package/components/octets.storage/operations/permute.js +0 -7
- package/source/HTTP/Server.test.ts +0 -126
- package/source/directives/octets/Permute.ts +0 -44
- package/transpiled/directives/octets/Permute.d.ts +0 -11
- package/transpiled/directives/octets/Permute.js +0 -58
- package/transpiled/directives/octets/Permute.js.map +0 -1
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto'
|
|
2
|
-
import { Connector } from '@toa.io/core'
|
|
3
|
-
import { type Processing, Server } from './Server'
|
|
4
|
-
import { type OutgoingMessage } from './messages'
|
|
5
|
-
import { BadRequest } from './exceptions'
|
|
6
|
-
|
|
7
|
-
let server: Server
|
|
8
|
-
|
|
9
|
-
beforeAll(() => {
|
|
10
|
-
server = Server.create({ port: 0 })
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('should instance of connector', async () => {
|
|
14
|
-
expect(server).toBeInstanceOf(Connector)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('should start HTTP server', async () => {
|
|
18
|
-
await server.connect()
|
|
19
|
-
|
|
20
|
-
expect(server.connected).toBeTruthy()
|
|
21
|
-
expect(server.port).toBeGreaterThan(0)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('should register request handler', async () => {
|
|
25
|
-
const process: Processing = jest.fn().mockResolvedValue(undefined)
|
|
26
|
-
|
|
27
|
-
server.attach(process)
|
|
28
|
-
|
|
29
|
-
const res = await fetch(`http://localhost:${server.port}`)
|
|
30
|
-
|
|
31
|
-
await res.text()
|
|
32
|
-
|
|
33
|
-
expect(process).toHaveBeenCalledTimes(1)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('should send 501 on unknown method', async () => {
|
|
37
|
-
const head = await fetch(`http://localhost:${server.port}/`, { method: 'COPY' })
|
|
38
|
-
|
|
39
|
-
await head.text()
|
|
40
|
-
expect(head.status).toBe(501)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('should stop HTTP server', async () => {
|
|
44
|
-
await server.connect()
|
|
45
|
-
await server.disconnect()
|
|
46
|
-
expect(server.connected).toBeFalsy()
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
describe('result', () => {
|
|
50
|
-
beforeEach(async () => {
|
|
51
|
-
server = Server.create({ port: 0 })
|
|
52
|
-
await server.connect()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
afterEach(async () => {
|
|
56
|
-
await server.disconnect()
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should send status code 200 if the result has a value', async () => {
|
|
60
|
-
server.attach(async (): Promise<OutgoingMessage> => ({
|
|
61
|
-
headers: new Headers(), body: randomUUID()
|
|
62
|
-
}))
|
|
63
|
-
|
|
64
|
-
const res = await fetch(`http://localhost:${server.port}/`)
|
|
65
|
-
|
|
66
|
-
await res.text()
|
|
67
|
-
expect(res.status).toBe(200)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('should send status code 204 if the result has no value', async () => {
|
|
71
|
-
server.attach(async (): Promise<OutgoingMessage> => ({ headers: new Headers() }))
|
|
72
|
-
|
|
73
|
-
const res = await fetch(`http://localhost:${server.port}/`)
|
|
74
|
-
|
|
75
|
-
await res.text()
|
|
76
|
-
expect(res.status).toBe(204)
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it('should send result', async () => {
|
|
80
|
-
const body = { [randomUUID()]: randomUUID() }
|
|
81
|
-
|
|
82
|
-
server.attach(async (): Promise<OutgoingMessage> =>
|
|
83
|
-
({ headers: new Headers(), body }))
|
|
84
|
-
|
|
85
|
-
const res = await fetch(`http://localhost:${server.port}/`,
|
|
86
|
-
{ headers: { accept: 'application/json' } })
|
|
87
|
-
|
|
88
|
-
const result = await res.json()
|
|
89
|
-
|
|
90
|
-
expect(result).toEqual(body)
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
it('should return 500 on exception', async () => {
|
|
94
|
-
server.attach(jest.fn().mockRejectedValue(new Error('Bad')))
|
|
95
|
-
|
|
96
|
-
const res = await fetch(`http://localhost:${server.port}/`)
|
|
97
|
-
|
|
98
|
-
await res.text()
|
|
99
|
-
expect(res.status).toBe(500)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('should send client error', async () => {
|
|
103
|
-
const message = randomUUID()
|
|
104
|
-
|
|
105
|
-
server.attach(jest.fn().mockRejectedValueOnce(new BadRequest(message)))
|
|
106
|
-
|
|
107
|
-
const res = await fetch(`http://localhost:${server.port}/`)
|
|
108
|
-
const text = await res.text()
|
|
109
|
-
|
|
110
|
-
expect(res.status).toBe(400)
|
|
111
|
-
expect(text).toContain(message)
|
|
112
|
-
})
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
describe('options', () => {
|
|
116
|
-
it('should send 501 on unspecified method', async () => {
|
|
117
|
-
server = Server.create({ methods: new Set(['COPY']), port: 0 })
|
|
118
|
-
await server.connect()
|
|
119
|
-
|
|
120
|
-
const res = await fetch(`http://localhost:${server.port}/`)
|
|
121
|
-
|
|
122
|
-
await res.text()
|
|
123
|
-
await server.disconnect()
|
|
124
|
-
expect(res.status).toBe(501)
|
|
125
|
-
})
|
|
126
|
-
})
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { NotAcceptable, NotFound } from '../../HTTP'
|
|
2
|
-
import * as schemas from './schemas'
|
|
3
|
-
import { Directive } from './Directive'
|
|
4
|
-
import type { Maybe } from '@toa.io/types'
|
|
5
|
-
import type { Component } from '@toa.io/core'
|
|
6
|
-
import type { Output } from '../../io'
|
|
7
|
-
import type { Input } from './types'
|
|
8
|
-
|
|
9
|
-
export class Permute extends Directive {
|
|
10
|
-
public readonly targeted = false
|
|
11
|
-
|
|
12
|
-
private readonly discovery: Promise<Component>
|
|
13
|
-
private storage: Component | null = null
|
|
14
|
-
|
|
15
|
-
public constructor (value: null, discovery: Promise<Component>) {
|
|
16
|
-
super()
|
|
17
|
-
schemas.permute.validate(value)
|
|
18
|
-
|
|
19
|
-
this.discovery = discovery
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public async apply (storage: string, input: Input): Promise<Output> {
|
|
23
|
-
this.storage ??= await this.discovery
|
|
24
|
-
|
|
25
|
-
if (input.encoder === null)
|
|
26
|
-
throw new NotAcceptable()
|
|
27
|
-
|
|
28
|
-
const path = input.request.url
|
|
29
|
-
const list = await input.body()
|
|
30
|
-
|
|
31
|
-
const error = await this.storage.invoke<Maybe<unknown>>('permute', {
|
|
32
|
-
input: {
|
|
33
|
-
storage,
|
|
34
|
-
path,
|
|
35
|
-
list
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
if (error instanceof Error)
|
|
40
|
-
throw new NotFound()
|
|
41
|
-
|
|
42
|
-
return {}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Directive } from './Directive';
|
|
2
|
-
import type { Component } from '@toa.io/core';
|
|
3
|
-
import type { Output } from '../../io';
|
|
4
|
-
import type { Input } from './types';
|
|
5
|
-
export declare class Permute extends Directive {
|
|
6
|
-
readonly targeted = false;
|
|
7
|
-
private readonly discovery;
|
|
8
|
-
private storage;
|
|
9
|
-
constructor(value: null, discovery: Promise<Component>);
|
|
10
|
-
apply(storage: string, input: Input): Promise<Output>;
|
|
11
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Permute = void 0;
|
|
27
|
-
const HTTP_1 = require("../../HTTP");
|
|
28
|
-
const schemas = __importStar(require("./schemas"));
|
|
29
|
-
const Directive_1 = require("./Directive");
|
|
30
|
-
class Permute extends Directive_1.Directive {
|
|
31
|
-
targeted = false;
|
|
32
|
-
discovery;
|
|
33
|
-
storage = null;
|
|
34
|
-
constructor(value, discovery) {
|
|
35
|
-
super();
|
|
36
|
-
schemas.permute.validate(value);
|
|
37
|
-
this.discovery = discovery;
|
|
38
|
-
}
|
|
39
|
-
async apply(storage, input) {
|
|
40
|
-
this.storage ??= await this.discovery;
|
|
41
|
-
if (input.encoder === null)
|
|
42
|
-
throw new HTTP_1.NotAcceptable();
|
|
43
|
-
const path = input.request.url;
|
|
44
|
-
const list = await input.body();
|
|
45
|
-
const error = await this.storage.invoke('permute', {
|
|
46
|
-
input: {
|
|
47
|
-
storage,
|
|
48
|
-
path,
|
|
49
|
-
list
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
if (error instanceof Error)
|
|
53
|
-
throw new HTTP_1.NotFound();
|
|
54
|
-
return {};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.Permute = Permute;
|
|
58
|
-
//# sourceMappingURL=Permute.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Permute.js","sourceRoot":"","sources":["../../../source/directives/octets/Permute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAoD;AACpD,mDAAoC;AACpC,2CAAuC;AAMvC,MAAa,OAAQ,SAAQ,qBAAS;IACpB,QAAQ,GAAG,KAAK,CAAA;IAEf,SAAS,CAAoB;IACtC,OAAO,GAAqB,IAAI,CAAA;IAExC,YAAoB,KAAW,EAAE,SAA6B;QAC5D,KAAK,EAAE,CAAA;QACP,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAE/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,KAAK,CAAE,OAAe,EAAE,KAAY;QAC/C,IAAI,CAAC,OAAO,KAAK,MAAM,IAAI,CAAC,SAAS,CAAA;QAErC,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI;YACxB,MAAM,IAAI,oBAAa,EAAE,CAAA;QAE3B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAA;QAC9B,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAE/B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAiB,SAAS,EAAE;YACjE,KAAK,EAAE;gBACL,OAAO;gBACP,IAAI;gBACJ,IAAI;aACL;SACF,CAAC,CAAA;QAEF,IAAI,KAAK,YAAY,KAAK;YACxB,MAAM,IAAI,eAAQ,EAAE,CAAA;QAEtB,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AAnCD,0BAmCC"}
|