@toa.io/extensions.exposition 1.0.0-alpha.211 → 1.0.0-alpha.216
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.bans/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.keys/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.otp/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.passkeys/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
- package/documentation/map.md +19 -0
- package/features/body.feature +27 -0
- package/features/map.feature +28 -0
- package/features/steps/components/echo/manifest.toa.yaml +5 -0
- package/features/steps/components/echo/operations/unwrap.js +7 -0
- package/package.json +5 -3
- package/source/HTTP/Context.ts +10 -1
- package/source/HTTP/formats/index.ts +1 -1
- package/source/HTTP/formats/json.ts +2 -2
- package/source/HTTP/formats/text.ts +2 -2
- package/source/HTTP/formats/yaml.ts +2 -2
- package/source/HTTP/messages.test.ts +23 -3
- package/source/HTTP/messages.ts +11 -11
- package/source/directives/map/Buffer.ts +15 -0
- package/source/directives/map/Map.ts +2 -0
- package/transpiled/HTTP/Context.d.ts +4 -0
- package/transpiled/HTTP/Context.js +7 -1
- package/transpiled/HTTP/Context.js.map +1 -1
- package/transpiled/HTTP/formats/index.d.ts +1 -1
- package/transpiled/HTTP/formats/json.d.ts +1 -1
- package/transpiled/HTTP/formats/json.js +2 -2
- package/transpiled/HTTP/formats/json.js.map +1 -1
- package/transpiled/HTTP/formats/text.d.ts +1 -1
- package/transpiled/HTTP/formats/text.js +2 -2
- package/transpiled/HTTP/formats/text.js.map +1 -1
- package/transpiled/HTTP/formats/yaml.d.ts +1 -1
- package/transpiled/HTTP/formats/yaml.js +2 -2
- package/transpiled/HTTP/formats/yaml.js.map +1 -1
- package/transpiled/HTTP/messages.js +13 -9
- package/transpiled/HTTP/messages.js.map +1 -1
- package/transpiled/directives/map/Buffer.d.ts +6 -0
- package/transpiled/directives/map/Buffer.js +19 -0
- package/transpiled/directives/map/Buffer.js.map +1 -0
- package/transpiled/directives/map/Map.js +2 -0
- package/transpiled/directives/map/Map.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
package/documentation/map.md
CHANGED
|
@@ -15,6 +15,7 @@ exposition:
|
|
|
15
15
|
map:language: lang # requested language
|
|
16
16
|
map:headers: # raw header values
|
|
17
17
|
token: x-access-token
|
|
18
|
+
map:buffer: body # unparsed request body
|
|
18
19
|
map:segments: # route parameters
|
|
19
20
|
group: group
|
|
20
21
|
map:claims: # Bearer token claims
|
|
@@ -56,6 +57,24 @@ of the [CORS](protocol.md#cors).
|
|
|
56
57
|
[Multiple header fields](https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2) are combined
|
|
57
58
|
as a comma-separated list.
|
|
58
59
|
|
|
60
|
+
## Raw body
|
|
61
|
+
|
|
62
|
+
The `map:buffer` directive maps the unparsed request body to an operation call input property.
|
|
63
|
+
The directive value is the name of the input property.
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
/webhook:
|
|
67
|
+
POST:
|
|
68
|
+
map:buffer: body
|
|
69
|
+
map:headers:
|
|
70
|
+
signature: x-signature
|
|
71
|
+
endpoint: verify
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The body is read from the request stream as raw bytes and delivered as a UTF-8 string.
|
|
75
|
+
|
|
76
|
+
Body parsing is bypassed, so the route does not depend on a supported `Content-Type` or format decoding. The request stream is consumed; a route with `map:buffer` cannot also receive a parsed body from the same request.
|
|
77
|
+
|
|
59
78
|
## Route parameters
|
|
60
79
|
|
|
61
80
|
The `map:segments` directive maps the values of route parameters to operation call input properties.
|
package/features/body.feature
CHANGED
|
@@ -47,3 +47,30 @@ Feature: Request body
|
|
|
47
47
|
| operation |
|
|
48
48
|
| compute |
|
|
49
49
|
| affect |
|
|
50
|
+
|
|
51
|
+
Scenario: JSON body with charset in content-type
|
|
52
|
+
Given the `echo` is running with the following manifest:
|
|
53
|
+
"""yaml
|
|
54
|
+
exposition:
|
|
55
|
+
/:
|
|
56
|
+
io:output: true
|
|
57
|
+
POST:
|
|
58
|
+
endpoint: echo
|
|
59
|
+
"""
|
|
60
|
+
When the following request is received:
|
|
61
|
+
"""
|
|
62
|
+
POST /echo/ HTTP/1.1
|
|
63
|
+
host: nex.toa.io
|
|
64
|
+
accept: application/json
|
|
65
|
+
content-type: application/json; charset=utf-8
|
|
66
|
+
|
|
67
|
+
{"foo":"bar"}
|
|
68
|
+
"""
|
|
69
|
+
Then the following reply is sent:
|
|
70
|
+
"""
|
|
71
|
+
201 Created
|
|
72
|
+
content-type: application/json
|
|
73
|
+
vary: accept
|
|
74
|
+
|
|
75
|
+
{"foo":"bar"}
|
|
76
|
+
"""
|
package/features/map.feature
CHANGED
|
@@ -326,3 +326,31 @@ Feature: HTTP context mapping
|
|
|
326
326
|
|
|
327
327
|
Hello the.one.com
|
|
328
328
|
"""
|
|
329
|
+
|
|
330
|
+
Scenario: Mapping the raw request body
|
|
331
|
+
Given the `echo` is running with the following manifest:
|
|
332
|
+
"""yaml
|
|
333
|
+
exposition:
|
|
334
|
+
/:
|
|
335
|
+
POST:
|
|
336
|
+
io:output: true
|
|
337
|
+
map:buffer: buf
|
|
338
|
+
endpoint: unwrap
|
|
339
|
+
"""
|
|
340
|
+
When the following request is received:
|
|
341
|
+
"""
|
|
342
|
+
POST /echo/ HTTP/1.1
|
|
343
|
+
host: nex.toa.io
|
|
344
|
+
accept: application/json
|
|
345
|
+
content-type: application/json; charset=utf-8
|
|
346
|
+
|
|
347
|
+
{"foo":"bar"}
|
|
348
|
+
"""
|
|
349
|
+
Then the following reply is sent:
|
|
350
|
+
"""
|
|
351
|
+
201 Created
|
|
352
|
+
content-type: application/json
|
|
353
|
+
vary: accept
|
|
354
|
+
|
|
355
|
+
{"foo":"bar"}
|
|
356
|
+
"""
|
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.216",
|
|
4
4
|
"description": "Toa Exposition",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -19,10 +19,11 @@
|
|
|
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.
|
|
22
|
+
"@toa.io/core": "1.0.0-alpha.212",
|
|
23
23
|
"@toa.io/generic": "1.0.0-alpha.208",
|
|
24
24
|
"@toa.io/schemas": "1.0.0-alpha.208",
|
|
25
25
|
"bcryptjs": "2.4.3",
|
|
26
|
+
"content-type": "1.0.5",
|
|
26
27
|
"error-value": "0.4.2",
|
|
27
28
|
"jose": "5.10.0",
|
|
28
29
|
"js-yaml": "4.1.1",
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@toa.io/extensions.storages": "*",
|
|
54
55
|
"@types/bcryptjs": "2.4.6",
|
|
56
|
+
"@types/content-type": "1.1.9",
|
|
55
57
|
"@types/cors": "2.8.19",
|
|
56
58
|
"@types/negotiator": "0.6.4",
|
|
57
59
|
"jest-esbuild": "0.4.0"
|
|
@@ -62,5 +64,5 @@
|
|
|
62
64
|
},
|
|
63
65
|
"testEnvironment": "node"
|
|
64
66
|
},
|
|
65
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "2b139f2dfbcd9ee58a39075f2c71cad45c47478b"
|
|
66
68
|
}
|
package/source/HTTP/Context.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import crypto from 'node:crypto'
|
|
2
|
+
import { buffer } from 'node:stream/consumers'
|
|
2
3
|
import Negotiator from 'negotiator'
|
|
3
4
|
import { console } from 'openspan'
|
|
4
5
|
import { Timing } from './Timing'
|
|
@@ -22,6 +23,8 @@ export class Context {
|
|
|
22
23
|
response: []
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
private consumed = false
|
|
27
|
+
|
|
25
28
|
public constructor (authority: string, request: IncomingMessage, properties: Properties) {
|
|
26
29
|
this.authority = authority
|
|
27
30
|
this.request = request
|
|
@@ -54,8 +57,14 @@ export class Context {
|
|
|
54
57
|
this.encoder = formats[mediaType]
|
|
55
58
|
}
|
|
56
59
|
|
|
60
|
+
public async buffer (): Promise<Buffer> {
|
|
61
|
+
this.consumed = true
|
|
62
|
+
|
|
63
|
+
return await buffer(this.request)
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
public async body<T>(): Promise<T> {
|
|
58
|
-
let value = await read(this)
|
|
67
|
+
let value = this.consumed ? null : await read(this)
|
|
59
68
|
|
|
60
69
|
for (const transform of this.pipelines.body)
|
|
61
70
|
value = await transform(value)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export const type = 'application/json'
|
|
2
2
|
export const multipart = 'multipart/json'
|
|
3
3
|
|
|
4
|
-
export function decode (buffer: Buffer): any {
|
|
5
|
-
const text = buffer.toString()
|
|
4
|
+
export function decode (buffer: Buffer, charset = 'utf-8'): any {
|
|
5
|
+
const text = buffer.toString(charset as BufferEncoding)
|
|
6
6
|
|
|
7
7
|
return JSON.parse(text)
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export const type = 'text/plain'
|
|
2
2
|
export const multipart = 'multipart/text'
|
|
3
3
|
|
|
4
|
-
export function decode (buffer: Buffer): any {
|
|
5
|
-
return buffer.toString()
|
|
4
|
+
export function decode (buffer: Buffer, charset = 'utf-8'): any {
|
|
5
|
+
return buffer.toString(charset as BufferEncoding)
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export function encode (value: { toString: () => string }): Buffer {
|
|
@@ -3,8 +3,8 @@ import * as yaml from 'js-yaml'
|
|
|
3
3
|
export const type = 'application/yaml'
|
|
4
4
|
export const multipart = 'multipart/yaml'
|
|
5
5
|
|
|
6
|
-
export function decode (buffer: Buffer): any {
|
|
7
|
-
const text = buffer.toString()
|
|
6
|
+
export function decode (buffer: Buffer, charset = 'utf-8'): any {
|
|
7
|
+
const text = buffer.toString(charset as BufferEncoding)
|
|
8
8
|
|
|
9
9
|
return yaml.load(text)
|
|
10
10
|
}
|
|
@@ -57,6 +57,17 @@ describe('read', () => {
|
|
|
57
57
|
expect(output).toStrictEqual(input)
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
+
it('should parse application/json with charset parameter', async () => {
|
|
61
|
+
const path = generate()
|
|
62
|
+
const headers = { 'content-type': 'application/json; charset=utf-8' }
|
|
63
|
+
const input = { [generate()]: generate() }
|
|
64
|
+
const json = JSON.stringify(input)
|
|
65
|
+
const context = createContext(path, headers, json)
|
|
66
|
+
const output = await read(context)
|
|
67
|
+
|
|
68
|
+
expect(output).toStrictEqual(input)
|
|
69
|
+
})
|
|
70
|
+
|
|
60
71
|
it('should throw on unsupported request media type', async () => {
|
|
61
72
|
const path = generate()
|
|
62
73
|
const headers = { 'content-type': 'wtf/' + generate() }
|
|
@@ -116,8 +127,9 @@ describe('read', () => {
|
|
|
116
127
|
|
|
117
128
|
export function createContext (url: string, headers: Record<string, string> = {}, content: string | Buffer = ''):
|
|
118
129
|
jest.MockedObject<Context> {
|
|
119
|
-
const
|
|
120
|
-
const stream = Readable.from(
|
|
130
|
+
const data = Buffer.isBuffer(content) ? content : Buffer.from(content)
|
|
131
|
+
const stream = Readable.from(data)
|
|
132
|
+
let consumed = false
|
|
121
133
|
|
|
122
134
|
const mock: Partial<Context> = {
|
|
123
135
|
request: Object.assign(stream, {
|
|
@@ -125,7 +137,15 @@ jest.MockedObject<Context> {
|
|
|
125
137
|
headers
|
|
126
138
|
}) as unknown as Context['request'],
|
|
127
139
|
url: new URL(url, 'https://host.local'),
|
|
128
|
-
timing: new Timing(false)
|
|
140
|
+
timing: new Timing(false),
|
|
141
|
+
buffer: async () => {
|
|
142
|
+
if (consumed)
|
|
143
|
+
throw new Error('Request body already consumed')
|
|
144
|
+
|
|
145
|
+
consumed = true
|
|
146
|
+
|
|
147
|
+
return data
|
|
148
|
+
}
|
|
129
149
|
}
|
|
130
150
|
|
|
131
151
|
return mock as unknown as jest.MockedObject<Context>
|
package/source/HTTP/messages.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
|
-
import
|
|
2
|
+
import contentType from 'content-type'
|
|
3
3
|
import { console } from 'openspan'
|
|
4
4
|
import { formats } from './formats'
|
|
5
5
|
import { BadRequest, NotAcceptable, UnsupportedMediaType } from './exceptions'
|
|
@@ -39,26 +39,26 @@ export async function write (context: Context, response: http.ServerResponse, me
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export async function read (context: Context): Promise<any> {
|
|
42
|
-
const
|
|
42
|
+
const header = context.request.headers['content-type']
|
|
43
43
|
|
|
44
|
-
if (
|
|
44
|
+
if (header === undefined)
|
|
45
45
|
return undefined
|
|
46
46
|
|
|
47
|
+
const { type, parameters } = contentType.parse(header)
|
|
48
|
+
|
|
47
49
|
if (!(type in formats))
|
|
48
50
|
throw new UnsupportedMediaType()
|
|
49
51
|
|
|
50
52
|
const format = formats[type]
|
|
51
|
-
const buf = await context.
|
|
53
|
+
const buf = await context.buffer()
|
|
52
54
|
|
|
53
55
|
try {
|
|
54
|
-
return format.decode(buf)
|
|
56
|
+
return format.decode(buf, parameters.charset)
|
|
55
57
|
} catch (error: unknown) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
console.debug('Failed to decode message', entry)
|
|
58
|
+
console.debug('Failed to decode message', {
|
|
59
|
+
path: context.url.pathname,
|
|
60
|
+
error: error?.toString?.()
|
|
61
|
+
})
|
|
62
62
|
|
|
63
63
|
throw new BadRequest()
|
|
64
64
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
2
|
+
import { Mapping } from './Mapping'
|
|
3
|
+
import type { Input } from '../../io'
|
|
4
|
+
|
|
5
|
+
export class BufferMapping extends Mapping<string> {
|
|
6
|
+
public constructor (property: string) {
|
|
7
|
+
assert.ok(typeof property === 'string', '`map:buffer` must be a string')
|
|
8
|
+
|
|
9
|
+
super(property)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public override async properties (context: Input): Promise<Record<string, string>> {
|
|
13
|
+
return { [this.value]: (await context.buffer()).toString('utf8') }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -6,6 +6,7 @@ import { Languages } from './Languages'
|
|
|
6
6
|
import { Language } from './Language'
|
|
7
7
|
import { Segments } from './Segments'
|
|
8
8
|
import { Authority } from './Authority'
|
|
9
|
+
import { BufferMapping } from './Buffer'
|
|
9
10
|
import { Claims } from './Claims'
|
|
10
11
|
import type { Directive } from './Directive'
|
|
11
12
|
import type { Properties } from './Properties'
|
|
@@ -53,6 +54,7 @@ type PV = Properties[PN]
|
|
|
53
54
|
|
|
54
55
|
const mappings: Record<string, new (value: any, remotes: Remotes) => Directive> = {
|
|
55
56
|
authority: Authority,
|
|
57
|
+
buffer: BufferMapping,
|
|
56
58
|
headers: Headers,
|
|
57
59
|
languages: Languages,
|
|
58
60
|
language: Language,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
2
4
|
import { Timing } from './Timing';
|
|
3
5
|
import { type Format } from './formats';
|
|
4
6
|
import type { OutgoingMessage } from './messages';
|
|
@@ -13,7 +15,9 @@ export declare class Context {
|
|
|
13
15
|
readonly timing: Timing;
|
|
14
16
|
readonly debug: boolean;
|
|
15
17
|
readonly pipelines: Pipelines;
|
|
18
|
+
private consumed;
|
|
16
19
|
constructor(authority: string, request: IncomingMessage, properties: Properties);
|
|
20
|
+
buffer(): Promise<Buffer>;
|
|
17
21
|
body<T>(): Promise<T>;
|
|
18
22
|
private log;
|
|
19
23
|
}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Context = void 0;
|
|
7
7
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
8
|
+
const consumers_1 = require("node:stream/consumers");
|
|
8
9
|
const negotiator_1 = __importDefault(require("negotiator"));
|
|
9
10
|
const openspan_1 = require("openspan");
|
|
10
11
|
const Timing_1 = require("./Timing");
|
|
@@ -23,6 +24,7 @@ class Context {
|
|
|
23
24
|
body: [],
|
|
24
25
|
response: []
|
|
25
26
|
};
|
|
27
|
+
consumed = false;
|
|
26
28
|
constructor(authority, request, properties) {
|
|
27
29
|
this.authority = authority;
|
|
28
30
|
this.request = request;
|
|
@@ -44,8 +46,12 @@ class Context {
|
|
|
44
46
|
if (mediaType !== undefined)
|
|
45
47
|
this.encoder = formats_1.formats[mediaType];
|
|
46
48
|
}
|
|
49
|
+
async buffer() {
|
|
50
|
+
this.consumed = true;
|
|
51
|
+
return await (0, consumers_1.buffer)(this.request);
|
|
52
|
+
}
|
|
47
53
|
async body() {
|
|
48
|
-
let value = await (0, messages_1.read)(this);
|
|
54
|
+
let value = this.consumed ? null : await (0, messages_1.read)(this);
|
|
49
55
|
for (const transform of this.pipelines.body)
|
|
50
56
|
value = await transform(value);
|
|
51
57
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../source/HTTP/Context.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAChC,4DAAmC;AACnC,uCAAkC;AAClC,qCAAiC;AACjC,uCAAuD;AACvD,yCAAi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,OAAO,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAA;QAEtC,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS;YACrC,cAAc;YACd,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;QAE5F,kBAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;IAC1F,CAAC;CACF;AAzED,0BAyEC;AAiBD,MAAM,OAAO,GAAG,4EAA4E,CAAA"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
export declare const type = "application/json";
|
|
4
4
|
export declare const multipart = "multipart/json";
|
|
5
|
-
export declare function decode(buffer: Buffer): any;
|
|
5
|
+
export declare function decode(buffer: Buffer, charset?: string): any;
|
|
6
6
|
export declare function encode(value: any): Buffer;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.encode = exports.decode = exports.multipart = exports.type = void 0;
|
|
4
4
|
exports.type = 'application/json';
|
|
5
5
|
exports.multipart = 'multipart/json';
|
|
6
|
-
function decode(buffer) {
|
|
7
|
-
const text = buffer.toString();
|
|
6
|
+
function decode(buffer, charset = 'utf-8') {
|
|
7
|
+
const text = buffer.toString(charset);
|
|
8
8
|
return JSON.parse(text);
|
|
9
9
|
}
|
|
10
10
|
exports.decode = decode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../source/HTTP/formats/json.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,kBAAkB,CAAA;AACzB,QAAA,SAAS,GAAG,gBAAgB,CAAA;AAEzC,SAAgB,MAAM,CAAE,MAAc;
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../source/HTTP/formats/json.ts"],"names":[],"mappings":";;;AAAa,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,KAAK,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAJD,wBAIC;AAED,SAAgB,MAAM,CAAE,KAAU;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAElC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAJD,wBAIC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
export declare const type = "text/plain";
|
|
4
4
|
export declare const multipart = "multipart/text";
|
|
5
|
-
export declare function decode(buffer: Buffer): any;
|
|
5
|
+
export declare function decode(buffer: Buffer, charset?: string): any;
|
|
6
6
|
export declare function encode(value: {
|
|
7
7
|
toString: () => string;
|
|
8
8
|
}): Buffer;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.encode = exports.decode = exports.multipart = exports.type = void 0;
|
|
4
4
|
exports.type = 'text/plain';
|
|
5
5
|
exports.multipart = 'multipart/text';
|
|
6
|
-
function decode(buffer) {
|
|
7
|
-
return buffer.toString();
|
|
6
|
+
function decode(buffer, charset = 'utf-8') {
|
|
7
|
+
return buffer.toString(charset);
|
|
8
8
|
}
|
|
9
9
|
exports.decode = decode;
|
|
10
10
|
function encode(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../source/HTTP/formats/text.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,YAAY,CAAA;AACnB,QAAA,SAAS,GAAG,gBAAgB,CAAA;AAEzC,SAAgB,MAAM,CAAE,MAAc;
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../source/HTTP/formats/text.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,YAAY,CAAA;AACnB,QAAA,SAAS,GAAG,gBAAgB,CAAA;AAEzC,SAAgB,MAAM,CAAE,MAAc,EAAE,OAAO,GAAG,OAAO;IACvD,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAyB,CAAC,CAAA;AACnD,CAAC;AAFD,wBAEC;AAED,SAAgB,MAAM,CAAE,KAAiC;IACvD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;AACtC,CAAC;AAFD,wBAEC"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
export declare const type = "application/yaml";
|
|
4
4
|
export declare const multipart = "multipart/yaml";
|
|
5
|
-
export declare function decode(buffer: Buffer): any;
|
|
5
|
+
export declare function decode(buffer: Buffer, charset?: string): any;
|
|
6
6
|
export declare function encode(value: any): Buffer;
|
|
@@ -27,8 +27,8 @@ exports.encode = exports.decode = exports.multipart = exports.type = void 0;
|
|
|
27
27
|
const yaml = __importStar(require("js-yaml"));
|
|
28
28
|
exports.type = 'application/yaml';
|
|
29
29
|
exports.multipart = 'multipart/yaml';
|
|
30
|
-
function decode(buffer) {
|
|
31
|
-
const text = buffer.toString();
|
|
30
|
+
function decode(buffer, charset = 'utf-8') {
|
|
31
|
+
const text = buffer.toString(charset);
|
|
32
32
|
return yaml.load(text);
|
|
33
33
|
}
|
|
34
34
|
exports.decode = decode;
|
|
@@ -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;
|
|
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,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.multipart = exports.read = exports.write = void 0;
|
|
4
7
|
const node_stream_1 = require("node:stream");
|
|
5
|
-
const
|
|
8
|
+
const content_type_1 = __importDefault(require("content-type"));
|
|
6
9
|
const openspan_1 = require("openspan");
|
|
7
10
|
const formats_1 = require("./formats");
|
|
8
11
|
const exceptions_1 = require("./exceptions");
|
|
@@ -30,21 +33,22 @@ async function write(context, response, message) {
|
|
|
30
33
|
}
|
|
31
34
|
exports.write = write;
|
|
32
35
|
async function read(context) {
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
36
|
+
const header = context.request.headers['content-type'];
|
|
37
|
+
if (header === undefined)
|
|
35
38
|
return undefined;
|
|
39
|
+
const { type, parameters } = content_type_1.default.parse(header);
|
|
36
40
|
if (!(type in formats_1.formats))
|
|
37
41
|
throw new exceptions_1.UnsupportedMediaType();
|
|
38
42
|
const format = formats_1.formats[type];
|
|
39
|
-
const buf = await context.
|
|
43
|
+
const buf = await context.buffer();
|
|
40
44
|
try {
|
|
41
|
-
return format.decode(buf);
|
|
45
|
+
return format.decode(buf, parameters.charset);
|
|
42
46
|
}
|
|
43
47
|
catch (error) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
openspan_1.console.debug('Failed to decode message', {
|
|
49
|
+
path: context.url.pathname,
|
|
50
|
+
error: error?.toString?.()
|
|
51
|
+
});
|
|
48
52
|
throw new exceptions_1.BadRequest();
|
|
49
53
|
}
|
|
50
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../source/HTTP/messages.ts"],"names":[],"mappings":"
|
|
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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AAO,CAAC,KAAK,CAAC,eAAe,EAAE,GAAG,CAAC,CAAA;IACnC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;IAE5B,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACxB,kBAAO,CAAC,KAAK,CAAC,eAAe,EAAE,GAAG,CAAC,CAAA;QACnC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAE1B,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACvB,IAAI,eAAe,KAAK,IAAI;gBAC1B,aAAa,CAAC,eAAe,CAAC,CAAA;YAEhC,eAAe,GAAG,IAAI,CAAA;QACxB,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,IAAI,eAAe,KAAK,IAAI;QAC1B,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE,CACjC,kBAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,EAC1D,sBAAsB,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BufferMapping = void 0;
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const Mapping_1 = require("./Mapping");
|
|
9
|
+
class BufferMapping extends Mapping_1.Mapping {
|
|
10
|
+
constructor(property) {
|
|
11
|
+
node_assert_1.default.ok(typeof property === 'string', '`map:buffer` must be a string');
|
|
12
|
+
super(property);
|
|
13
|
+
}
|
|
14
|
+
async properties(context) {
|
|
15
|
+
return { [this.value]: (await context.buffer()).toString('utf8') };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.BufferMapping = BufferMapping;
|
|
19
|
+
//# sourceMappingURL=Buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Buffer.js","sourceRoot":"","sources":["../../../source/directives/map/Buffer.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAChC,uCAAmC;AAGnC,MAAa,aAAc,SAAQ,iBAAe;IAChD,YAAoB,QAAgB;QAClC,qBAAM,CAAC,EAAE,CAAC,OAAO,QAAQ,KAAK,QAAQ,EAAE,+BAA+B,CAAC,CAAA;QAExE,KAAK,CAAC,QAAQ,CAAC,CAAA;IACjB,CAAC;IAEe,KAAK,CAAC,UAAU,CAAE,OAAc;QAC9C,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAA;IACpE,CAAC;CACF;AAVD,sCAUC"}
|
|
@@ -9,6 +9,7 @@ const Languages_1 = require("./Languages");
|
|
|
9
9
|
const Language_1 = require("./Language");
|
|
10
10
|
const Segments_1 = require("./Segments");
|
|
11
11
|
const Authority_1 = require("./Authority");
|
|
12
|
+
const Buffer_1 = require("./Buffer");
|
|
12
13
|
const Claims_1 = require("./Claims");
|
|
13
14
|
class Map {
|
|
14
15
|
name = 'map';
|
|
@@ -37,6 +38,7 @@ class Map {
|
|
|
37
38
|
exports.Map = Map;
|
|
38
39
|
const mappings = {
|
|
39
40
|
authority: Authority_1.Authority,
|
|
41
|
+
buffer: Buffer_1.BufferMapping,
|
|
40
42
|
headers: Headers_1.Headers,
|
|
41
43
|
languages: Languages_1.Languages,
|
|
42
44
|
language: Language_1.Language,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Map.js","sourceRoot":"","sources":["../../../source/directives/map/Map.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AACjC,6CAAmD;AACnD,uCAAmC;AACnC,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