@redocly/cli 2.0.0-next.8 → 2.0.0
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/lib/commands/auth.d.ts +4 -4
- package/lib/commands/auth.d.ts.map +1 -1
- package/lib/commands/auth.js.map +1 -1
- package/lib/commands/build-docs/utils.js +1 -1
- package/lib/commands/build-docs/utils.js.map +1 -1
- package/lib/commands/bundle.d.ts +4 -4
- package/lib/commands/bundle.d.ts.map +1 -1
- package/lib/commands/bundle.js.map +1 -1
- package/lib/commands/eject.d.ts +2 -2
- package/lib/commands/eject.d.ts.map +1 -1
- package/lib/commands/eject.js.map +1 -1
- package/lib/commands/generate-arazzo.d.ts +8 -0
- package/lib/commands/generate-arazzo.d.ts.map +1 -0
- package/lib/commands/generate-arazzo.js +25 -0
- package/lib/commands/generate-arazzo.js.map +1 -0
- package/lib/commands/join.d.ts +2 -2
- package/lib/commands/join.d.ts.map +1 -1
- package/lib/commands/join.js +7 -8
- package/lib/commands/join.js.map +1 -1
- package/lib/commands/lint.d.ts +4 -4
- package/lib/commands/lint.d.ts.map +1 -1
- package/lib/commands/lint.js +1 -4
- package/lib/commands/lint.js.map +1 -1
- package/lib/commands/preview-project/index.d.ts +2 -2
- package/lib/commands/preview-project/index.d.ts.map +1 -1
- package/lib/commands/preview-project/index.js.map +1 -1
- package/lib/commands/preview-project/types.d.ts +1 -1
- package/lib/commands/preview-project/types.d.ts.map +1 -1
- package/lib/commands/respect/display-files-summary-table.d.ts +12 -0
- package/lib/commands/respect/display-files-summary-table.d.ts.map +1 -0
- package/lib/commands/respect/display-files-summary-table.js +65 -0
- package/lib/commands/respect/display-files-summary-table.js.map +1 -0
- package/lib/commands/respect/har-logs/har-logs.d.ts +6 -0
- package/lib/commands/respect/har-logs/har-logs.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/har-logs.js +28 -0
- package/lib/commands/respect/har-logs/har-logs.js.map +1 -0
- package/lib/commands/respect/har-logs/helpers/add-headers.d.ts +2 -0
- package/lib/commands/respect/har-logs/helpers/add-headers.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/helpers/add-headers.js +17 -0
- package/lib/commands/respect/har-logs/helpers/add-headers.js.map +1 -0
- package/lib/commands/respect/har-logs/helpers/build-headers.d.ts +10 -0
- package/lib/commands/respect/har-logs/helpers/build-headers.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/helpers/build-headers.js +32 -0
- package/lib/commands/respect/har-logs/helpers/build-headers.js.map +1 -0
- package/lib/commands/respect/har-logs/helpers/build-params.d.ts +2 -0
- package/lib/commands/respect/har-logs/helpers/build-params.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/helpers/build-params.js +18 -0
- package/lib/commands/respect/har-logs/helpers/build-params.js.map +1 -0
- package/lib/commands/respect/har-logs/helpers/build-request-cookies.d.ts +2 -0
- package/lib/commands/respect/har-logs/helpers/build-request-cookies.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/helpers/build-request-cookies.js +18 -0
- package/lib/commands/respect/har-logs/helpers/build-request-cookies.js.map +1 -0
- package/lib/commands/respect/har-logs/helpers/build-response-cookies.d.ts +2 -0
- package/lib/commands/respect/har-logs/helpers/build-response-cookies.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/helpers/build-response-cookies.js +40 -0
- package/lib/commands/respect/har-logs/helpers/build-response-cookies.js.map +1 -0
- package/lib/commands/respect/har-logs/helpers/get-agent.d.ts +2 -0
- package/lib/commands/respect/har-logs/helpers/get-agent.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/helpers/get-agent.js +89 -0
- package/lib/commands/respect/har-logs/helpers/get-agent.js.map +1 -0
- package/lib/commands/respect/har-logs/helpers/get-duration.d.ts +2 -0
- package/lib/commands/respect/har-logs/helpers/get-duration.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/helpers/get-duration.js +6 -0
- package/lib/commands/respect/har-logs/helpers/get-duration.js.map +1 -0
- package/lib/commands/respect/har-logs/helpers/get-input-url.d.ts +2 -0
- package/lib/commands/respect/har-logs/helpers/get-input-url.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/helpers/get-input-url.js +5 -0
- package/lib/commands/respect/har-logs/helpers/get-input-url.js.map +1 -0
- package/lib/commands/respect/har-logs/helpers/handle-request.d.ts +9 -0
- package/lib/commands/respect/har-logs/helpers/handle-request.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/helpers/handle-request.js +199 -0
- package/lib/commands/respect/har-logs/helpers/handle-request.js.map +1 -0
- package/lib/commands/respect/har-logs/index.d.ts +2 -0
- package/lib/commands/respect/har-logs/index.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/index.js +2 -0
- package/lib/commands/respect/har-logs/index.js.map +1 -0
- package/lib/commands/respect/har-logs/with-har.d.ts +7 -0
- package/lib/commands/respect/har-logs/with-har.d.ts.map +1 -0
- package/lib/commands/respect/har-logs/with-har.js +188 -0
- package/lib/commands/respect/har-logs/with-har.js.map +1 -0
- package/lib/commands/respect/index.d.ts +21 -0
- package/lib/commands/respect/index.d.ts.map +1 -0
- package/lib/commands/respect/index.js +109 -0
- package/lib/commands/respect/index.js.map +1 -0
- package/lib/commands/respect/json-logs.d.ts +10 -0
- package/lib/commands/respect/json-logs.d.ts.map +1 -0
- package/lib/commands/respect/json-logs.js +80 -0
- package/lib/commands/respect/json-logs.js.map +1 -0
- package/lib/commands/respect/mtls/create-mtls-client.d.ts +9 -0
- package/lib/commands/respect/mtls/create-mtls-client.d.ts.map +1 -0
- package/lib/commands/respect/mtls/create-mtls-client.js +32 -0
- package/lib/commands/respect/mtls/create-mtls-client.js.map +1 -0
- package/lib/commands/respect/mtls/resolve-mtls-certificates.d.ts +7 -0
- package/lib/commands/respect/mtls/resolve-mtls-certificates.d.ts.map +1 -0
- package/lib/commands/respect/mtls/resolve-mtls-certificates.js +45 -0
- package/lib/commands/respect/mtls/resolve-mtls-certificates.js.map +1 -0
- package/lib/commands/split/index.d.ts +2 -2
- package/lib/commands/split/index.d.ts.map +1 -1
- package/lib/commands/split/index.js +17 -13
- package/lib/commands/split/index.js.map +1 -1
- package/lib/commands/split/types.d.ts +4 -23
- package/lib/commands/split/types.d.ts.map +1 -1
- package/lib/commands/split/types.js +17 -40
- package/lib/commands/split/types.js.map +1 -1
- package/lib/commands/stats.d.ts +2 -2
- package/lib/commands/stats.d.ts.map +1 -1
- package/lib/commands/stats.js.map +1 -1
- package/lib/commands/translations.d.ts +2 -2
- package/lib/commands/translations.d.ts.map +1 -1
- package/lib/commands/translations.js.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/reunite/commands/push-status.d.ts +2 -2
- package/lib/reunite/commands/push-status.d.ts.map +1 -1
- package/lib/reunite/commands/push-status.js +1 -2
- package/lib/reunite/commands/push-status.js.map +1 -1
- package/lib/reunite/commands/push.d.ts +2 -2
- package/lib/reunite/commands/push.d.ts.map +1 -1
- package/lib/reunite/commands/push.js.map +1 -1
- package/lib/types.d.ts +17 -16
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/miscellaneous.d.ts +9 -9
- package/lib/utils/miscellaneous.d.ts.map +1 -1
- package/lib/utils/miscellaneous.js +8 -14
- package/lib/utils/miscellaneous.js.map +1 -1
- package/lib/utils/read-env-variables.d.ts +2 -0
- package/lib/utils/read-env-variables.d.ts.map +1 -0
- package/lib/utils/read-env-variables.js +18 -0
- package/lib/utils/read-env-variables.js.map +1 -0
- package/lib/utils/telemetry.d.ts +3 -3
- package/lib/utils/telemetry.d.ts.map +1 -1
- package/lib/utils/telemetry.js.map +1 -1
- package/lib/wrapper.d.ts +3 -3
- package/lib/wrapper.d.ts.map +1 -1
- package/package.json +9 -5
- package/lib/utils/js-utils.d.ts +0 -6
- package/lib/utils/js-utils.d.ts.map +0 -1
- package/lib/utils/js-utils.js +0 -24
- package/lib/utils/js-utils.js.map +0 -1
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/* istanbul ignore file */
|
|
2
|
+
// Forked from:
|
|
3
|
+
// https://github.com/exogen/node-fetch-har
|
|
4
|
+
// Changes made:
|
|
5
|
+
// - Allow to pass body as FormData
|
|
6
|
+
// - removed nanoid and replaced with crypto.randomUUID
|
|
7
|
+
// - migrated to be used with undici
|
|
8
|
+
import { URL } from 'url';
|
|
9
|
+
import { Client } from 'undici';
|
|
10
|
+
import { addHeaders } from './helpers/add-headers.js';
|
|
11
|
+
import { getDuration } from './helpers/get-duration.js';
|
|
12
|
+
import { buildRequestCookies } from './helpers/build-request-cookies.js';
|
|
13
|
+
import { buildHeaders } from './helpers/build-headers.js';
|
|
14
|
+
import { buildResponseCookies } from './helpers/build-response-cookies.js';
|
|
15
|
+
const HAR_HEADER_NAME = 'x-har-request-id';
|
|
16
|
+
const harEntryMap = new Map();
|
|
17
|
+
export const withHar = function (baseFetch, defaults = {}) {
|
|
18
|
+
withHar.harEntryMap = harEntryMap;
|
|
19
|
+
return async function fetch(input, options = {}) {
|
|
20
|
+
const { har = defaults.har, harPageRef = defaults.harPageRef, onHarEntry = defaults.onHarEntry, } = options;
|
|
21
|
+
if (har === false) {
|
|
22
|
+
return baseFetch(input, options);
|
|
23
|
+
}
|
|
24
|
+
const requestId = crypto.randomUUID();
|
|
25
|
+
const startTime = process.hrtime();
|
|
26
|
+
const url = new URL(typeof input === 'string' ? input : input.url);
|
|
27
|
+
const entry = {
|
|
28
|
+
_compressed: false,
|
|
29
|
+
_resourceType: 'fetch',
|
|
30
|
+
_timestamps: {
|
|
31
|
+
start: startTime,
|
|
32
|
+
socket: startTime,
|
|
33
|
+
lookup: startTime,
|
|
34
|
+
connect: startTime,
|
|
35
|
+
secureConnect: startTime,
|
|
36
|
+
sent: startTime,
|
|
37
|
+
firstByte: startTime,
|
|
38
|
+
received: startTime,
|
|
39
|
+
},
|
|
40
|
+
timings: {
|
|
41
|
+
blocked: -1,
|
|
42
|
+
dns: -1,
|
|
43
|
+
connect: -1,
|
|
44
|
+
send: 0,
|
|
45
|
+
wait: 0,
|
|
46
|
+
receive: 0,
|
|
47
|
+
ssl: -1,
|
|
48
|
+
},
|
|
49
|
+
time: 0,
|
|
50
|
+
startedDateTime: new Date().toISOString(),
|
|
51
|
+
cache: {
|
|
52
|
+
beforeRequest: null,
|
|
53
|
+
afterRequest: null,
|
|
54
|
+
},
|
|
55
|
+
request: {
|
|
56
|
+
method: options.method || 'GET',
|
|
57
|
+
url: url.href,
|
|
58
|
+
cookies: buildRequestCookies(options.headers || {}),
|
|
59
|
+
headers: buildHeaders(options.headers || {}),
|
|
60
|
+
queryString: [...url.searchParams].map(([name, value]) => ({
|
|
61
|
+
name,
|
|
62
|
+
value,
|
|
63
|
+
})),
|
|
64
|
+
headersSize: -1,
|
|
65
|
+
bodySize: -1,
|
|
66
|
+
postData: {},
|
|
67
|
+
httpVersion: 'HTTP/1.1',
|
|
68
|
+
},
|
|
69
|
+
response: {},
|
|
70
|
+
pageref: '',
|
|
71
|
+
};
|
|
72
|
+
// Replace the Dispatcher initialization with Client
|
|
73
|
+
const client = options.dispatcher || new Client(url.origin);
|
|
74
|
+
// Listen to Undici dispatcher events
|
|
75
|
+
client.on('connect', () => (entry._timestamps.connect = process.hrtime()));
|
|
76
|
+
// Pass the dispatcher in options
|
|
77
|
+
options = Object.assign({}, options, {
|
|
78
|
+
headers: addHeaders(options.headers, { [HAR_HEADER_NAME]: requestId }),
|
|
79
|
+
dispatcher: client, // Use client as dispatcher
|
|
80
|
+
});
|
|
81
|
+
harEntryMap.set(requestId, entry);
|
|
82
|
+
// Update sent time just before the request
|
|
83
|
+
entry._timestamps.sent = process.hrtime();
|
|
84
|
+
// Make the request
|
|
85
|
+
const response = await baseFetch(input, options);
|
|
86
|
+
// Need to clone response to get both text and arrayBuffer
|
|
87
|
+
const responseClone = response.clone();
|
|
88
|
+
// Update firstByte time when we get the response
|
|
89
|
+
entry._timestamps.firstByte = process.hrtime();
|
|
90
|
+
// Get the response body and update received time
|
|
91
|
+
const text = await response.text();
|
|
92
|
+
entry._timestamps.received = process.hrtime();
|
|
93
|
+
const harEntry = harEntryMap.get(requestId);
|
|
94
|
+
harEntryMap.delete(requestId);
|
|
95
|
+
if (!harEntry) {
|
|
96
|
+
return response;
|
|
97
|
+
}
|
|
98
|
+
// Add response info
|
|
99
|
+
if (!harEntry.response) {
|
|
100
|
+
harEntry.response = {};
|
|
101
|
+
}
|
|
102
|
+
// Calculate total bytes of headers including the double CRLF before body
|
|
103
|
+
const headerLines = [...response.headers.entries()].map(([name, value]) => `${name}: ${value}`);
|
|
104
|
+
const statusLine = `HTTP/1.1 ${response.status} ${response.statusText}`;
|
|
105
|
+
const headerBytes = Buffer.byteLength(statusLine + '\r\n' + headerLines.join('\r\n') + '\r\n\r\n');
|
|
106
|
+
harEntry._compressed = /^(gzip|compress|deflate|br)$/.test(response.headers.get('content-encoding') || '');
|
|
107
|
+
if (!harEntry.response.content) {
|
|
108
|
+
harEntry.response.content = {
|
|
109
|
+
size: -1,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (harEntry._compressed) {
|
|
113
|
+
const rawBody = await responseClone.arrayBuffer();
|
|
114
|
+
harEntry.response.content.size = rawBody.byteLength;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
harEntry.response.content.size = text ? Buffer.byteLength(text) : -1;
|
|
118
|
+
}
|
|
119
|
+
const bodySize = text ? Buffer.byteLength(text) : -1;
|
|
120
|
+
harEntry.response = {
|
|
121
|
+
headers: buildHeaders(response.headers),
|
|
122
|
+
cookies: buildResponseCookies(response.headers),
|
|
123
|
+
status: response.status,
|
|
124
|
+
statusText: response.statusText || '',
|
|
125
|
+
httpVersion: response.httpVersion ? `HTTP/${response.httpVersion}` : 'HTTP/1.1',
|
|
126
|
+
redirectURL: response.headers.location || '',
|
|
127
|
+
content: {
|
|
128
|
+
size: harEntry._compressed && harEntry.response.content.size !== -1
|
|
129
|
+
? harEntry.response.content.size
|
|
130
|
+
: Buffer.byteLength(text),
|
|
131
|
+
mimeType: response.headers.get('content-type') || '',
|
|
132
|
+
text,
|
|
133
|
+
compression: harEntry._compressed && harEntry.response.content.size !== -1
|
|
134
|
+
? harEntry.response.content.size - bodySize
|
|
135
|
+
: 0,
|
|
136
|
+
},
|
|
137
|
+
bodySize,
|
|
138
|
+
headersSize: headerBytes,
|
|
139
|
+
};
|
|
140
|
+
// Calculate timings
|
|
141
|
+
const { _timestamps: time } = harEntry;
|
|
142
|
+
harEntry.timings = {
|
|
143
|
+
blocked: Math.max(getDuration(time.start, time.socket), 0.01),
|
|
144
|
+
dns: -1,
|
|
145
|
+
connect: Math.max(getDuration(time.lookup, time.connect), -1),
|
|
146
|
+
ssl: time.secureConnect ? Math.max(getDuration(time.connect, time.secureConnect), -1) : -1,
|
|
147
|
+
send: getDuration(time.secureConnect || time.connect, time.sent),
|
|
148
|
+
wait: Math.max(getDuration(time.sent, time.firstByte), 0),
|
|
149
|
+
receive: getDuration(time.firstByte, time.received),
|
|
150
|
+
};
|
|
151
|
+
// Calculate total time
|
|
152
|
+
harEntry.time = getDuration(time.start, time.received);
|
|
153
|
+
const parents = [];
|
|
154
|
+
let child = harEntry;
|
|
155
|
+
do {
|
|
156
|
+
const parent = child._parent;
|
|
157
|
+
delete child._parent;
|
|
158
|
+
if (parent) {
|
|
159
|
+
parents.unshift(parent);
|
|
160
|
+
}
|
|
161
|
+
child = parent;
|
|
162
|
+
} while (child);
|
|
163
|
+
// Allow grouping by pages.
|
|
164
|
+
entry.pageref = harPageRef || 'page_1';
|
|
165
|
+
parents.forEach((parent) => {
|
|
166
|
+
parent.pageref = entry.pageref;
|
|
167
|
+
});
|
|
168
|
+
const Response = defaults.Response || baseFetch.Response || global.Response || response.constructor;
|
|
169
|
+
const responseCopy = new Response(text, {
|
|
170
|
+
status: response.statusCode,
|
|
171
|
+
statusText: response.statusText || '',
|
|
172
|
+
headers: response.headers,
|
|
173
|
+
url: response.url,
|
|
174
|
+
});
|
|
175
|
+
responseCopy.harEntry = entry;
|
|
176
|
+
if (har && typeof har === 'object') {
|
|
177
|
+
har.log.entries.push(...parents, entry);
|
|
178
|
+
}
|
|
179
|
+
if (onHarEntry) {
|
|
180
|
+
parents.forEach((parent) => {
|
|
181
|
+
onHarEntry(parent);
|
|
182
|
+
});
|
|
183
|
+
onHarEntry(entry);
|
|
184
|
+
}
|
|
185
|
+
return responseCopy;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
//# sourceMappingURL=with-har.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-har.js","sourceRoot":"","sources":["../../../../src/commands/respect/har-logs/with-har.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,eAAe;AACf,2CAA2C;AAC3C,gBAAgB;AAChB,mCAAmC;AACnC,uDAAuD;AACvD,oCAAoC;AAEpC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAe,CAAC;AAM3C,MAAM,CAAC,MAAM,OAAO,GAAY,UAC9B,SAAc,EACd,WAAgB,EAAE;IAElB,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;IAClC,OAAO,KAAK,UAAU,KAAK,CAAC,KAAU,EAAE,UAAe,EAAE;QACvD,MAAM,EACJ,GAAG,GAAG,QAAQ,CAAC,GAAG,EAClB,UAAU,GAAG,QAAQ,CAAC,UAAU,EAChC,UAAU,GAAG,QAAQ,CAAC,UAAU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AAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBACzB,UAAU,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;YACH,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAM,CAAC;AACT,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CommandArgs } from '../../wrapper';
|
|
2
|
+
export type RespectArgv = {
|
|
3
|
+
files: string[];
|
|
4
|
+
input?: string;
|
|
5
|
+
server?: string;
|
|
6
|
+
workflow?: string[];
|
|
7
|
+
skip?: string[];
|
|
8
|
+
verbose?: boolean;
|
|
9
|
+
'har-output'?: string;
|
|
10
|
+
'json-output'?: string;
|
|
11
|
+
'client-cert'?: string;
|
|
12
|
+
'client-key'?: string;
|
|
13
|
+
'ca-cert'?: string;
|
|
14
|
+
'max-steps': number;
|
|
15
|
+
severity?: string;
|
|
16
|
+
config?: string;
|
|
17
|
+
'max-fetch-timeout': number;
|
|
18
|
+
'execution-timeout': number;
|
|
19
|
+
};
|
|
20
|
+
export declare function handleRespect({ argv, config, version, collectSpecData, }: CommandArgs<RespectArgv>): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/respect/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAYjD,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,eAAe,GAChB,EAAE,WAAW,CAAC,WAAW,CAAC,iBAqH1B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { HandledError, logger } from '@redocly/openapi-core';
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, basename } from 'node:path';
|
|
4
|
+
import { blue, green } from 'colorette';
|
|
5
|
+
import { composeJsonLogsFiles } from './json-logs.js';
|
|
6
|
+
import { displayFilesSummaryTable } from './display-files-summary-table.js';
|
|
7
|
+
import { readEnvVariables } from '../../utils/read-env-variables.js';
|
|
8
|
+
import { resolveMtlsCertificates } from './mtls/resolve-mtls-certificates.js';
|
|
9
|
+
import { withMtlsClientIfNeeded } from './mtls/create-mtls-client.js';
|
|
10
|
+
import { withHar } from './har-logs/index.js';
|
|
11
|
+
import { createHarLog } from './har-logs/har-logs.js';
|
|
12
|
+
export async function handleRespect({ argv, config, version, collectSpecData, }) {
|
|
13
|
+
let mtlsCerts;
|
|
14
|
+
let harLogs;
|
|
15
|
+
try {
|
|
16
|
+
const { run, maskSecrets } = await import('@redocly/respect-core');
|
|
17
|
+
const workingDir = config.configPath ? dirname(config.configPath) : process.cwd();
|
|
18
|
+
if (argv['client-cert'] || argv['client-key'] || argv['ca-cert']) {
|
|
19
|
+
mtlsCerts =
|
|
20
|
+
argv['client-cert'] || argv['client-key'] || argv['ca-cert']
|
|
21
|
+
? resolveMtlsCertificates({
|
|
22
|
+
clientCert: argv['client-cert'],
|
|
23
|
+
clientKey: argv['client-key'],
|
|
24
|
+
caCert: argv['ca-cert'],
|
|
25
|
+
}, workingDir)
|
|
26
|
+
: undefined;
|
|
27
|
+
}
|
|
28
|
+
let customFetch = withMtlsClientIfNeeded(mtlsCerts);
|
|
29
|
+
if (argv['har-output']) {
|
|
30
|
+
harLogs = createHarLog({ version });
|
|
31
|
+
customFetch = withHar(customFetch, { har: harLogs });
|
|
32
|
+
}
|
|
33
|
+
const options = {
|
|
34
|
+
files: argv.files,
|
|
35
|
+
input: argv.input,
|
|
36
|
+
server: argv.server,
|
|
37
|
+
workflow: argv.workflow,
|
|
38
|
+
skip: argv.skip,
|
|
39
|
+
verbose: argv.verbose,
|
|
40
|
+
config,
|
|
41
|
+
version,
|
|
42
|
+
collectSpecData,
|
|
43
|
+
severity: argv.severity,
|
|
44
|
+
maxSteps: argv['max-steps'],
|
|
45
|
+
maxFetchTimeout: argv['max-fetch-timeout'],
|
|
46
|
+
executionTimeout: argv['execution-timeout'],
|
|
47
|
+
requestFileLoader: {
|
|
48
|
+
getFileBody: async (filePath) => {
|
|
49
|
+
if (!existsSync(filePath)) {
|
|
50
|
+
throw new Error(`File ${filePath} doesn't exist or isn't readable.`);
|
|
51
|
+
}
|
|
52
|
+
const buffer = readFileSync(filePath);
|
|
53
|
+
return new File([buffer], basename(filePath));
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
envVariables: readEnvVariables(workingDir) || {},
|
|
57
|
+
logger,
|
|
58
|
+
fetch: customFetch,
|
|
59
|
+
};
|
|
60
|
+
if (options.skip && options.workflow) {
|
|
61
|
+
throw new Error(`Cannot use both --skip and --workflow flags at the same time.`);
|
|
62
|
+
}
|
|
63
|
+
if (argv['har-output'] && !argv['har-output'].endsWith('.har')) {
|
|
64
|
+
throw new Error('File for HAR logs should be in .har format');
|
|
65
|
+
}
|
|
66
|
+
if (argv['json-output'] && !argv['json-output'].endsWith('.json')) {
|
|
67
|
+
throw new Error('File for JSON logs should be in .json format');
|
|
68
|
+
}
|
|
69
|
+
if (options.files.length > 1 && argv['har-output']) {
|
|
70
|
+
// TODO: implement multiple run files HAR output
|
|
71
|
+
throw new Error('Currently only a single file can be run with --har-output. Please run a single file at a time.');
|
|
72
|
+
}
|
|
73
|
+
const startedAt = performance.now();
|
|
74
|
+
const runAllFilesResult = await run(options);
|
|
75
|
+
logger.printNewLine();
|
|
76
|
+
displayFilesSummaryTable(runAllFilesResult, logger);
|
|
77
|
+
logger.printNewLine();
|
|
78
|
+
const hasProblems = runAllFilesResult.some((result) => result.hasProblems);
|
|
79
|
+
const hasWarnings = runAllFilesResult.some((result) => result.hasWarnings);
|
|
80
|
+
if (argv['json-output']) {
|
|
81
|
+
const jsonOutputData = {
|
|
82
|
+
files: composeJsonLogsFiles(runAllFilesResult),
|
|
83
|
+
status: hasProblems ? 'error' : hasWarnings ? 'warn' : 'success',
|
|
84
|
+
totalTime: performance.now() - startedAt,
|
|
85
|
+
};
|
|
86
|
+
writeFileSync(argv['json-output'], JSON.stringify(jsonOutputData, null, 2), 'utf-8');
|
|
87
|
+
logger.output(blue(logger.indent(`JSON logs saved in ${green(argv['json-output'])}`, 2)));
|
|
88
|
+
logger.printNewLine();
|
|
89
|
+
logger.printNewLine();
|
|
90
|
+
}
|
|
91
|
+
if (argv['har-output']) {
|
|
92
|
+
// TODO: implement multiple run files HAR output
|
|
93
|
+
for (const result of runAllFilesResult) {
|
|
94
|
+
const parsedHarLogs = maskSecrets(harLogs, result.ctx.secretFields || new Set());
|
|
95
|
+
writeFileSync(argv['har-output'], JSON.stringify(parsedHarLogs, null, 2), 'utf-8');
|
|
96
|
+
logger.output(blue(`Har logs saved in ${green(argv['har-output'])}`));
|
|
97
|
+
logger.printNewLine();
|
|
98
|
+
logger.printNewLine();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (hasProblems) {
|
|
102
|
+
throw new Error(' Tests exited with error ');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw new HandledError(error?.message ?? error);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/respect/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAqBtD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,eAAe,GACU;IACzB,IAAI,SAAS,CAAC;IACd,IAAI,OAAO,CAAC;IAEZ,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;QACnE,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,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C,YAAY,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC;gBACjF,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;gBACnF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACtE,MAAM,CAAC,YAAY,EAAE,CAAC;gBACtB,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,CAAC;QACH,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,YAAY,CAAE,KAAe,EAAE,OAAO,IAAI,KAAK,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TestContext, JsonLogs, WorkflowExecutionResult } from '@redocly/respect-core';
|
|
2
|
+
export declare function composeJsonLogsFiles(filesResult: {
|
|
3
|
+
file: string;
|
|
4
|
+
totalRequests: number;
|
|
5
|
+
totalTimeMs: number;
|
|
6
|
+
executedWorkflows: WorkflowExecutionResult[];
|
|
7
|
+
ctx: TestContext;
|
|
8
|
+
globalTimeoutError: boolean;
|
|
9
|
+
}[]): JsonLogs['files'];
|
|
10
|
+
//# sourceMappingURL=json-logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-logs.d.ts","sourceRoot":"","sources":["../../../src/commands/respect/json-logs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,uBAAuB,EAKxB,MAAM,uBAAuB,CAAC;AAE/B,wBAAgB,oBAAoB,CAClC,WAAW,EAAE;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,uBAAuB,EAAE,CAAC;IAC7C,GAAG,EAAE,WAAW,CAAC;IACjB,kBAAkB,EAAE,OAAO,CAAC;CAC7B,EAAE,GACF,QAAQ,CAAC,OAAO,CAAC,CAmBnB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { maskSecrets, calculateTotals } from '@redocly/respect-core';
|
|
2
|
+
export function composeJsonLogsFiles(filesResult) {
|
|
3
|
+
const files = {};
|
|
4
|
+
for (const fileResult of filesResult) {
|
|
5
|
+
const { executedWorkflows, globalTimeoutError: fileGlobalTimeoutError } = fileResult;
|
|
6
|
+
const { secretFields } = fileResult.ctx;
|
|
7
|
+
files[fileResult.file] = maskSecrets({
|
|
8
|
+
totalRequests: fileResult.totalRequests,
|
|
9
|
+
executedWorkflows: executedWorkflows.map((workflow) => mapJsonWorkflow(workflow)),
|
|
10
|
+
totalTimeMs: fileResult.totalTimeMs,
|
|
11
|
+
globalTimeoutError: fileGlobalTimeoutError,
|
|
12
|
+
}, secretFields || new Set());
|
|
13
|
+
}
|
|
14
|
+
return files;
|
|
15
|
+
}
|
|
16
|
+
function mapJsonWorkflow(workflow) {
|
|
17
|
+
const { ctx, ...rest } = workflow;
|
|
18
|
+
const steps = workflow.executedSteps.map((step) => mapJsonStep(step, workflow.workflowId, ctx));
|
|
19
|
+
const totals = calculateTotals([workflow]);
|
|
20
|
+
const result = {
|
|
21
|
+
...rest,
|
|
22
|
+
executedSteps: steps,
|
|
23
|
+
status: totals.steps.failed > 0 ? 'error' : totals.steps.warnings > 0 ? 'warn' : 'success',
|
|
24
|
+
totalRequests: totals.totalRequests,
|
|
25
|
+
totalTimeMs: workflow.totalTimeMs,
|
|
26
|
+
};
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
function mapJsonStep(step, workflowId, ctx) {
|
|
30
|
+
if ('executedSteps' in step) {
|
|
31
|
+
return mapJsonWorkflow(step);
|
|
32
|
+
}
|
|
33
|
+
const publicStep = ctx.$workflows[workflowId].steps[step.stepId];
|
|
34
|
+
return {
|
|
35
|
+
type: 'step',
|
|
36
|
+
stepId: step.stepId,
|
|
37
|
+
workflowId,
|
|
38
|
+
request: {
|
|
39
|
+
method: publicStep.request?.method || '',
|
|
40
|
+
url: step.response?.requestUrl || '',
|
|
41
|
+
headers: publicStep.request?.header || {},
|
|
42
|
+
body: publicStep.request?.body,
|
|
43
|
+
},
|
|
44
|
+
response: {
|
|
45
|
+
statusCode: step.response?.statusCode || 0,
|
|
46
|
+
body: publicStep.response?.body,
|
|
47
|
+
headers: step.response?.header || {},
|
|
48
|
+
time: step.response?.time || 0,
|
|
49
|
+
},
|
|
50
|
+
checks: step.checks.map((check) => ({
|
|
51
|
+
...check,
|
|
52
|
+
status: calculateCheckStatus(check),
|
|
53
|
+
})),
|
|
54
|
+
totalTimeMs: publicStep.response?.time || 0,
|
|
55
|
+
retriesLeft: step.retriesLeft,
|
|
56
|
+
status: calculateStepStatus(step.checks),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function calculateCheckStatus(check) {
|
|
60
|
+
if (check.passed) {
|
|
61
|
+
return 'success';
|
|
62
|
+
}
|
|
63
|
+
if (check.severity === 'error') {
|
|
64
|
+
return 'error';
|
|
65
|
+
}
|
|
66
|
+
return 'warn';
|
|
67
|
+
}
|
|
68
|
+
function calculateStepStatus(checks) {
|
|
69
|
+
let hasWarning = false;
|
|
70
|
+
for (const check of checks) {
|
|
71
|
+
if (!check.passed && check.severity === 'error') {
|
|
72
|
+
return 'error';
|
|
73
|
+
}
|
|
74
|
+
if (!check.passed && check.severity === 'warn') {
|
|
75
|
+
hasWarning = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return hasWarning ? 'warn' : 'success';
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=json-logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|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YACR,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC;SACpC,CAAC,CAAC;QACH,WAAW,EAAE,UAAU,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC;QAC3C,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,MAAM,EAAE,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC;KACzC,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAY;IACxC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAe;IAC1C,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YAChD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;YAC/C,UAAU,GAAG,IAAI,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Client, fetch } from 'undici';
|
|
2
|
+
export type MtlsCerts = {
|
|
3
|
+
clientCert?: string;
|
|
4
|
+
clientKey?: string;
|
|
5
|
+
caCert?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function createMtlsClient(parsedPathToFetch: string, mtlsCerts?: MtlsCerts): Client | undefined;
|
|
8
|
+
export declare function withMtlsClientIfNeeded(mtlsCerts?: MtlsCerts): typeof fetch;
|
|
9
|
+
//# sourceMappingURL=create-mtls-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-mtls-client.d.ts","sourceRoot":"","sources":["../../../../src/commands/respect/mtls/create-mtls-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsC,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE3E,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,iBAAiB,EAAE,MAAM,EAAE,SAAS,GAAE,SAAc,sBAiBpF;AAED,wBAAgB,sBAAsB,CAAC,SAAS,GAAE,SAAc,gBAa/D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Client, fetch } from 'undici';
|
|
2
|
+
export function createMtlsClient(parsedPathToFetch, mtlsCerts = {}) {
|
|
3
|
+
const { clientCert, clientKey, caCert } = mtlsCerts;
|
|
4
|
+
const baseUrl = new URL(parsedPathToFetch).origin;
|
|
5
|
+
if (clientCert && clientKey) {
|
|
6
|
+
return new Client(baseUrl, {
|
|
7
|
+
connect: {
|
|
8
|
+
key: Buffer.from(clientKey),
|
|
9
|
+
cert: Buffer.from(clientCert),
|
|
10
|
+
...(caCert && { ca: Buffer.from(caCert) }),
|
|
11
|
+
// Keeping this `false` to have the ability to call different servers in one Arazzo file
|
|
12
|
+
// some of them might not require mTLS.
|
|
13
|
+
rejectUnauthorized: false,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
export function withMtlsClientIfNeeded(mtlsCerts = {}) {
|
|
20
|
+
if (!mtlsCerts) {
|
|
21
|
+
return fetch;
|
|
22
|
+
}
|
|
23
|
+
return function fetchWithMtls(input, init) {
|
|
24
|
+
const url = typeof input === 'string' ? input : 'url' in input ? input.url : input.toString();
|
|
25
|
+
const client = createMtlsClient(url, mtlsCerts);
|
|
26
|
+
return fetch(input, {
|
|
27
|
+
...init,
|
|
28
|
+
dispatcher: client,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=create-mtls-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-mtls-client.js","sourceRoot":"","sources":["../../../../src/commands/respect/mtls/create-mtls-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsC,KAAK,EAAE,MAAM,QAAQ,CAAC;AAQ3E,MAAM,UAAU,gBAAgB,CAAC,iBAAyB,EAAE,YAAuB,EAAE;IACnF,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACpD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC;IAElD,IAAI,UAAU,IAAI,SAAS,EAAE,CAAC;QAC5B,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE;YACzB,OAAO,EAAE;gBACP,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;gBAC3B,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;gBAC7B,GAAG,CAAC,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC1C,wFAAwF;gBACxF,uCAAuC;gBACvC,kBAAkB,EAAE,KAAK;aAC1B;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,YAAuB,EAAE;IAC9D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,SAAS,aAAa,CAAC,KAAiC,EAAE,IAAkB;QACjF,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC9F,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAChD,OAAO,KAAK,CAAC,KAAK,EAAE;YAClB,GAAG,IAAI;YACP,UAAU,EAAE,MAAM;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MtlsCerts } from './create-mtls-client.js';
|
|
2
|
+
export declare function resolveMtlsCertificates(mtlsCertificates: Partial<MtlsCerts> | undefined, workingDir: string): {
|
|
3
|
+
clientCert: string | undefined;
|
|
4
|
+
clientKey: string | undefined;
|
|
5
|
+
caCert: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=resolve-mtls-certificates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-mtls-certificates.d.ts","sourceRoot":"","sources":["../../../../src/commands/respect/mtls/resolve-mtls-certificates.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,wBAAgB,uBAAuB,CACrC,gBAAgB,EAAE,OAAO,CAAC,SAAS,CAAC,YAAK,EACzC,UAAU,EAAE,MAAM;;;;EASnB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
export function resolveMtlsCertificates(mtlsCertificates = {}, workingDir) {
|
|
4
|
+
const { clientCert, clientKey, caCert } = mtlsCertificates;
|
|
5
|
+
return {
|
|
6
|
+
clientCert: resolveCertificate(clientCert, workingDir),
|
|
7
|
+
clientKey: resolveCertificate(clientKey, workingDir),
|
|
8
|
+
caCert: resolveCertificate(caCert, workingDir),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function resolveCertificate(cert, workingDir) {
|
|
12
|
+
if (!cert)
|
|
13
|
+
return undefined;
|
|
14
|
+
try {
|
|
15
|
+
// Check if the string looks like a certificate content
|
|
16
|
+
const isCertContent = cert.includes('-----BEGIN') && cert.includes('-----END');
|
|
17
|
+
if (!isCertContent) {
|
|
18
|
+
const certPath = path.resolve(workingDir, cert);
|
|
19
|
+
// If not a certificate content, treat as file path
|
|
20
|
+
fs.accessSync(certPath, fs.constants.R_OK);
|
|
21
|
+
return fs.readFileSync(certPath, 'utf-8');
|
|
22
|
+
}
|
|
23
|
+
// Return the certificate content as-is
|
|
24
|
+
return formatCertificate(cert);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw new Error(`Failed to read certificate: ${error.message}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function formatCertificate(cert) {
|
|
31
|
+
// Split the content into header, body, and footer
|
|
32
|
+
const matches = cert.match(/^(-----BEGIN[^-]+-----)\r?\n([A-Za-z0-9+/=\r\n\t ]+)\r?\n(-----END[^-]+-----)/);
|
|
33
|
+
if (!matches) {
|
|
34
|
+
throw new Error('Invalid certificate format');
|
|
35
|
+
}
|
|
36
|
+
const [, header, body, footer] = matches;
|
|
37
|
+
// Format the body with proper line breaks (64 characters per line)
|
|
38
|
+
const formattedBody = body
|
|
39
|
+
.replace(/\s+/g, '') // Remove all whitespace
|
|
40
|
+
.match(/.{1,64}/g) // Split into 64-character chunks
|
|
41
|
+
?.join('\n') || ''; // Join with newlines
|
|
42
|
+
// Reconstruct the properly formatted certificate
|
|
43
|
+
return `${header}\n${formattedBody}\n${footer}`;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=resolve-mtls-certificates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-mtls-certificates.js","sour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SAAS,iBAAiB,CAAC,IAAY;IACrC,kDAAkD;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CACxB,+EAA+E,CAChF,CAAC;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC;IAEzC,mEAAmE;IACnE,MAAM,aAAa,GACjB,IAAI;SACD,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,wBAAwB;SAC5C,KAAK,CAAC,UAAU,CAAC,CAAC,iCAAiC;QACpD,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,qBAAqB;IAE7C,iDAAiD;IACjD,OAAO,GAAG,MAAM,KAAK,aAAa,KAAK,MAAM,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Oas3PathItem, Referenced } from '@redocly/openapi-core';
|
|
2
2
|
import type { CommandArgs } from '../../wrapper.js';
|
|
3
3
|
import type { VerifyConfigOptions } from '../../types.js';
|
|
4
|
-
export type
|
|
4
|
+
export type SplitArgv = {
|
|
5
5
|
api: string;
|
|
6
6
|
outDir: string;
|
|
7
7
|
separator: string;
|
|
8
8
|
} & VerifyConfigOptions;
|
|
9
|
-
export declare function handleSplit({ argv, collectSpecData }: CommandArgs<
|
|
9
|
+
export declare function handleSplit({ argv, collectSpecData }: CommandArgs<SplitArgv>): Promise<void>;
|
|
10
10
|
export declare function startsWithComponents(node: string): boolean;
|
|
11
11
|
export declare function crawl(object: unknown, visitor: (node: Record<string, unknown>) => void): void;
|
|
12
12
|
declare function iteratePathItems(pathItems: Record<string, Referenced<Oas3PathItem>> | undefined, openapiDir: string, outDir: string, componentsFiles: object, pathSeparator: string, codeSamplesPathPrefix: string | undefined, ext: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/split/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/split/index.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EASV,YAAY,EAEZ,UAAU,EACX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,mBAAmB,CAAC;AAExB,wBAAsB,WAAW,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,WAAW,CAAC,SAAS,CAAC,iBAalF;AAsCD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,WAEhD;AAkDD,wBAAgB,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,QAWtF;AA6HD,iBAAS,gBAAgB,CACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC,GAAG,SAAS,EAC/D,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,qBAAqB,EAAE,MAAM,YAAK,EAClC,GAAG,EAAE,MAAM,QA2CZ;AA8DD,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|