@stackwright-pro/openapi 0.1.1 → 0.2.1
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/dist/index.js +59 -36
- package/dist/index.mjs +59 -36
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -5817,8 +5817,9 @@ var OpenAPIParser = class {
|
|
|
5817
5817
|
* Detect OpenAPI version from document
|
|
5818
5818
|
*/
|
|
5819
5819
|
detectVersion(document) {
|
|
5820
|
-
|
|
5821
|
-
|
|
5820
|
+
const openapiVersion = "openapi" in document ? document.openapi : void 0;
|
|
5821
|
+
if (openapiVersion !== void 0) {
|
|
5822
|
+
return openapiVersion;
|
|
5822
5823
|
}
|
|
5823
5824
|
throw new Error("Invalid OpenAPI document: missing openapi version field");
|
|
5824
5825
|
}
|
|
@@ -5829,7 +5830,9 @@ var OpenAPIParser = class {
|
|
|
5829
5830
|
if (error instanceof Error) {
|
|
5830
5831
|
const message = `Failed to parse OpenAPI spec from "${specPath}": ${error.message}`;
|
|
5831
5832
|
const enhancedError = new Error(message);
|
|
5832
|
-
|
|
5833
|
+
if (error.stack !== void 0) {
|
|
5834
|
+
enhancedError.stack = error.stack;
|
|
5835
|
+
}
|
|
5833
5836
|
return enhancedError;
|
|
5834
5837
|
}
|
|
5835
5838
|
return new Error(`Failed to parse OpenAPI spec from "${specPath}": ${String(error)}`);
|
|
@@ -5902,9 +5905,9 @@ var SchemaResolver = class {
|
|
|
5902
5905
|
endpoints.push({
|
|
5903
5906
|
path: path3,
|
|
5904
5907
|
method,
|
|
5905
|
-
operationId: operation.operationId,
|
|
5906
|
-
summary: operation.summary,
|
|
5907
|
-
description: operation.description
|
|
5908
|
+
...operation.operationId !== void 0 && { operationId: operation.operationId },
|
|
5909
|
+
...operation.summary !== void 0 && { summary: operation.summary },
|
|
5910
|
+
...operation.description !== void 0 && { description: operation.description }
|
|
5908
5911
|
});
|
|
5909
5912
|
}
|
|
5910
5913
|
}
|
|
@@ -6249,18 +6252,21 @@ var CollectionProviderGenerator = class {
|
|
|
6249
6252
|
}
|
|
6250
6253
|
const isArray = schema.type === "array";
|
|
6251
6254
|
const schemaName = `${this.capitalize(collectionName)}Schema`;
|
|
6252
|
-
|
|
6255
|
+
const params = {
|
|
6253
6256
|
providerName,
|
|
6254
6257
|
collectionName,
|
|
6255
6258
|
endpoint,
|
|
6256
6259
|
slugField,
|
|
6257
6260
|
method,
|
|
6258
6261
|
baseUrl,
|
|
6259
|
-
auth,
|
|
6260
6262
|
schemaName,
|
|
6261
6263
|
isArray,
|
|
6262
6264
|
bare
|
|
6263
|
-
}
|
|
6265
|
+
};
|
|
6266
|
+
if (auth !== void 0) {
|
|
6267
|
+
params.auth = auth;
|
|
6268
|
+
}
|
|
6269
|
+
return this.generateProviderCode(params);
|
|
6264
6270
|
}
|
|
6265
6271
|
/**
|
|
6266
6272
|
* Generate the complete provider code
|
|
@@ -6282,12 +6288,12 @@ var CollectionProviderGenerator = class {
|
|
|
6282
6288
|
const arraySchemaName = `${schemaName.replace(/Schema$/, "")}ArraySchema`;
|
|
6283
6289
|
const validationSchema = isArray ? arraySchemaName : schemaName;
|
|
6284
6290
|
const imports = bare ? "" : `import type { CollectionProvider, CollectionItem } from '@stackwright/collections';
|
|
6285
|
-
import { ${isArray ? arraySchemaName : schemaName} } from './schemas';
|
|
6291
|
+
import { ${isArray ? arraySchemaName : schemaName}} } from './schemas';
|
|
6286
6292
|
|
|
6287
6293
|
`;
|
|
6288
6294
|
return `${imports}/**
|
|
6289
6295
|
* CollectionProvider for ${collectionName}
|
|
6290
|
-
*
|
|
6296
|
+
*
|
|
6291
6297
|
* Generated from OpenAPI endpoint: ${method.toUpperCase()} ${endpoint}
|
|
6292
6298
|
*/
|
|
6293
6299
|
export class ${providerName} implements CollectionProvider {
|
|
@@ -6433,7 +6439,10 @@ export class ${providerName} implements CollectionProvider {
|
|
|
6433
6439
|
*/
|
|
6434
6440
|
getBaseUrl() {
|
|
6435
6441
|
if ("servers" in this.document && this.document.servers && this.document.servers.length > 0) {
|
|
6436
|
-
|
|
6442
|
+
const firstServer = this.document.servers[0];
|
|
6443
|
+
if (firstServer !== void 0) {
|
|
6444
|
+
return firstServer.url;
|
|
6445
|
+
}
|
|
6437
6446
|
}
|
|
6438
6447
|
return "http://localhost:3000";
|
|
6439
6448
|
}
|
|
@@ -6461,7 +6470,8 @@ export class ${providerName} implements CollectionProvider {
|
|
|
6461
6470
|
*/
|
|
6462
6471
|
guessTitle(slugField) {
|
|
6463
6472
|
const titleFields = ["title", "name", "label", "displayName"];
|
|
6464
|
-
|
|
6473
|
+
const firstField = titleFields[0];
|
|
6474
|
+
return firstField !== void 0 ? firstField : `item.${slugField}`;
|
|
6465
6475
|
}
|
|
6466
6476
|
};
|
|
6467
6477
|
|
|
@@ -6471,7 +6481,9 @@ var ClientGenerator = class {
|
|
|
6471
6481
|
constructor(document, schemaMapping) {
|
|
6472
6482
|
this.document = document;
|
|
6473
6483
|
this.resolver = new SchemaResolver(document);
|
|
6474
|
-
|
|
6484
|
+
if (schemaMapping !== void 0) {
|
|
6485
|
+
this.schemaMapping = schemaMapping;
|
|
6486
|
+
}
|
|
6475
6487
|
this.requiredSchemas = /* @__PURE__ */ new Set();
|
|
6476
6488
|
this.generatedRequestSchemas = /* @__PURE__ */ new Set();
|
|
6477
6489
|
}
|
|
@@ -6829,7 +6841,8 @@ ${paramSchemas.join(",\n")}
|
|
|
6829
6841
|
*/
|
|
6830
6842
|
extractComponentName(ref) {
|
|
6831
6843
|
const parts = ref.split("/");
|
|
6832
|
-
|
|
6844
|
+
const lastPart = parts[parts.length - 1];
|
|
6845
|
+
return lastPart ?? ref;
|
|
6833
6846
|
}
|
|
6834
6847
|
/**
|
|
6835
6848
|
* Escape string for use in Zod .describe()
|
|
@@ -7576,9 +7589,9 @@ ${paramSchemas.join(",\n")}
|
|
|
7576
7589
|
endpoints.push({
|
|
7577
7590
|
path: path3,
|
|
7578
7591
|
method,
|
|
7579
|
-
operationId: operation.operationId,
|
|
7580
|
-
summary: operation.summary,
|
|
7581
|
-
description: operation.description,
|
|
7592
|
+
...operation.operationId !== void 0 && { operationId: operation.operationId },
|
|
7593
|
+
...operation.summary !== void 0 && { summary: operation.summary },
|
|
7594
|
+
...operation.description !== void 0 && { description: operation.description },
|
|
7582
7595
|
operation
|
|
7583
7596
|
});
|
|
7584
7597
|
}
|
|
@@ -7666,7 +7679,8 @@ ${paramSchemas.join(",\n")}
|
|
|
7666
7679
|
*/
|
|
7667
7680
|
getDefaultBaseUrl() {
|
|
7668
7681
|
if ("servers" in this.document && this.document.servers && this.document.servers.length > 0) {
|
|
7669
|
-
|
|
7682
|
+
const firstServer = this.document.servers[0];
|
|
7683
|
+
return firstServer ? firstServer.url : "http://localhost:3000";
|
|
7670
7684
|
}
|
|
7671
7685
|
return "http://localhost:3000";
|
|
7672
7686
|
}
|
|
@@ -7761,13 +7775,18 @@ var EndpointFilter = class {
|
|
|
7761
7775
|
let matches = true;
|
|
7762
7776
|
for (let i = 0; i < patternSegments.length; i++) {
|
|
7763
7777
|
const pSeg = patternSegments[i];
|
|
7778
|
+
if (pSeg === void 0) {
|
|
7779
|
+
matches = false;
|
|
7780
|
+
break;
|
|
7781
|
+
}
|
|
7764
7782
|
if (pSeg === "*" || pSeg === "**") {
|
|
7765
7783
|
continue;
|
|
7766
7784
|
}
|
|
7767
7785
|
if (pSeg.startsWith("{") && pSeg.endsWith("}")) {
|
|
7768
7786
|
continue;
|
|
7769
7787
|
}
|
|
7770
|
-
|
|
7788
|
+
const pathSeg = pathSegments[i];
|
|
7789
|
+
if (pSeg !== pathSeg) {
|
|
7771
7790
|
matches = false;
|
|
7772
7791
|
break;
|
|
7773
7792
|
}
|
|
@@ -7925,19 +7944,20 @@ var ApprovedSpecsValidator = class {
|
|
|
7925
7944
|
}
|
|
7926
7945
|
}
|
|
7927
7946
|
const ipv4Match = redirectUrl.hostname.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
7928
|
-
if (ipv4Match) {
|
|
7947
|
+
if (ipv4Match && ipv4Match.length >= 5) {
|
|
7929
7948
|
const octets = ipv4Match.slice(1, 5).map(Number);
|
|
7930
|
-
const
|
|
7931
|
-
|
|
7949
|
+
const first = octets[0];
|
|
7950
|
+
const second = octets[1];
|
|
7951
|
+
if (first !== void 0 && first === 10) {
|
|
7932
7952
|
return false;
|
|
7933
7953
|
}
|
|
7934
|
-
if (first === 172 && second >= 16 && second <= 31) {
|
|
7954
|
+
if (first !== void 0 && second !== void 0 && first === 172 && second >= 16 && second <= 31) {
|
|
7935
7955
|
return false;
|
|
7936
7956
|
}
|
|
7937
|
-
if (first === 192 && second === 168) {
|
|
7957
|
+
if (first !== void 0 && second !== void 0 && first === 192 && second === 168) {
|
|
7938
7958
|
return false;
|
|
7939
7959
|
}
|
|
7940
|
-
if (first === 127) {
|
|
7960
|
+
if (first !== void 0 && first === 127) {
|
|
7941
7961
|
return false;
|
|
7942
7962
|
}
|
|
7943
7963
|
}
|
|
@@ -8501,12 +8521,12 @@ import type * as schemas from './schemas';
|
|
|
8501
8521
|
slugField: collection.slug_field,
|
|
8502
8522
|
filters: collection.filters
|
|
8503
8523
|
};
|
|
8504
|
-
|
|
8524
|
+
const providerOptions = { bare: true };
|
|
8505
8525
|
if (auth) {
|
|
8506
8526
|
if (auth.type === "bearer" || auth.type === "apiKey") {
|
|
8507
8527
|
providerOptions.auth = {
|
|
8508
8528
|
type: auth.type,
|
|
8509
|
-
|
|
8529
|
+
...auth.type === "apiKey" && { headerName: "X-API-Key" }
|
|
8510
8530
|
};
|
|
8511
8531
|
} else if (auth.type === "oauth2") {
|
|
8512
8532
|
console.warn(
|
|
@@ -8567,7 +8587,8 @@ import { ${Array.from(schemaImports).join(", ")} } from './schemas';
|
|
|
8567
8587
|
}
|
|
8568
8588
|
extractComponentName(ref) {
|
|
8569
8589
|
const parts = ref.split("/");
|
|
8570
|
-
|
|
8590
|
+
const lastPart = parts[parts.length - 1];
|
|
8591
|
+
return lastPart ?? ref;
|
|
8571
8592
|
}
|
|
8572
8593
|
getOperationTypeName(operationId) {
|
|
8573
8594
|
return operationId.charAt(0).toUpperCase() + operationId.slice(1);
|
|
@@ -8645,22 +8666,24 @@ function validateFetchUrl(baseUrl) {
|
|
|
8645
8666
|
const ip = url.hostname;
|
|
8646
8667
|
if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(ip)) {
|
|
8647
8668
|
const octets = ip.split(".").map(Number);
|
|
8648
|
-
|
|
8669
|
+
const first = octets[0];
|
|
8670
|
+
const second = octets[1];
|
|
8671
|
+
if (first !== void 0 && first === 127) {
|
|
8649
8672
|
throw new Error("SSRF Prevention: Blocked loopback address: " + ip);
|
|
8650
8673
|
}
|
|
8651
|
-
if (
|
|
8674
|
+
if (first !== void 0 && first === 10) {
|
|
8652
8675
|
throw new Error("SSRF Prevention: Blocked private address: " + ip);
|
|
8653
8676
|
}
|
|
8654
|
-
if (
|
|
8677
|
+
if (first !== void 0 && second !== void 0 && first === 172 && second >= 16 && second <= 31) {
|
|
8655
8678
|
throw new Error("SSRF Prevention: Blocked private address: " + ip);
|
|
8656
8679
|
}
|
|
8657
|
-
if (
|
|
8680
|
+
if (first !== void 0 && second !== void 0 && first === 192 && second === 168) {
|
|
8658
8681
|
throw new Error("SSRF Prevention: Blocked private address: " + ip);
|
|
8659
8682
|
}
|
|
8660
|
-
if (
|
|
8683
|
+
if (first !== void 0 && second !== void 0 && first === 169 && second === 254) {
|
|
8661
8684
|
throw new Error("SSRF Prevention: Blocked link-local address: " + ip);
|
|
8662
8685
|
}
|
|
8663
|
-
if (
|
|
8686
|
+
if (first !== void 0 && first === 0) {
|
|
8664
8687
|
throw new Error("SSRF Prevention: Blocked current network address: " + ip);
|
|
8665
8688
|
}
|
|
8666
8689
|
}
|
|
@@ -8701,7 +8724,7 @@ function createOpenAPIFetcher(config) {
|
|
|
8701
8724
|
const response = await fetch(url.toString(), {
|
|
8702
8725
|
method: method.toUpperCase(),
|
|
8703
8726
|
headers: requestHeaders,
|
|
8704
|
-
body: supportsBody && body ? JSON.stringify(body) :
|
|
8727
|
+
body: supportsBody && body ? JSON.stringify(body) : null
|
|
8705
8728
|
});
|
|
8706
8729
|
if (!response.ok) {
|
|
8707
8730
|
const safeStatus = response.status;
|
package/dist/index.mjs
CHANGED
|
@@ -5793,8 +5793,9 @@ var OpenAPIParser = class {
|
|
|
5793
5793
|
* Detect OpenAPI version from document
|
|
5794
5794
|
*/
|
|
5795
5795
|
detectVersion(document) {
|
|
5796
|
-
|
|
5797
|
-
|
|
5796
|
+
const openapiVersion = "openapi" in document ? document.openapi : void 0;
|
|
5797
|
+
if (openapiVersion !== void 0) {
|
|
5798
|
+
return openapiVersion;
|
|
5798
5799
|
}
|
|
5799
5800
|
throw new Error("Invalid OpenAPI document: missing openapi version field");
|
|
5800
5801
|
}
|
|
@@ -5805,7 +5806,9 @@ var OpenAPIParser = class {
|
|
|
5805
5806
|
if (error instanceof Error) {
|
|
5806
5807
|
const message = `Failed to parse OpenAPI spec from "${specPath}": ${error.message}`;
|
|
5807
5808
|
const enhancedError = new Error(message);
|
|
5808
|
-
|
|
5809
|
+
if (error.stack !== void 0) {
|
|
5810
|
+
enhancedError.stack = error.stack;
|
|
5811
|
+
}
|
|
5809
5812
|
return enhancedError;
|
|
5810
5813
|
}
|
|
5811
5814
|
return new Error(`Failed to parse OpenAPI spec from "${specPath}": ${String(error)}`);
|
|
@@ -5878,9 +5881,9 @@ var SchemaResolver = class {
|
|
|
5878
5881
|
endpoints.push({
|
|
5879
5882
|
path: path3,
|
|
5880
5883
|
method,
|
|
5881
|
-
operationId: operation.operationId,
|
|
5882
|
-
summary: operation.summary,
|
|
5883
|
-
description: operation.description
|
|
5884
|
+
...operation.operationId !== void 0 && { operationId: operation.operationId },
|
|
5885
|
+
...operation.summary !== void 0 && { summary: operation.summary },
|
|
5886
|
+
...operation.description !== void 0 && { description: operation.description }
|
|
5884
5887
|
});
|
|
5885
5888
|
}
|
|
5886
5889
|
}
|
|
@@ -6225,18 +6228,21 @@ var CollectionProviderGenerator = class {
|
|
|
6225
6228
|
}
|
|
6226
6229
|
const isArray = schema.type === "array";
|
|
6227
6230
|
const schemaName = `${this.capitalize(collectionName)}Schema`;
|
|
6228
|
-
|
|
6231
|
+
const params = {
|
|
6229
6232
|
providerName,
|
|
6230
6233
|
collectionName,
|
|
6231
6234
|
endpoint,
|
|
6232
6235
|
slugField,
|
|
6233
6236
|
method,
|
|
6234
6237
|
baseUrl,
|
|
6235
|
-
auth,
|
|
6236
6238
|
schemaName,
|
|
6237
6239
|
isArray,
|
|
6238
6240
|
bare
|
|
6239
|
-
}
|
|
6241
|
+
};
|
|
6242
|
+
if (auth !== void 0) {
|
|
6243
|
+
params.auth = auth;
|
|
6244
|
+
}
|
|
6245
|
+
return this.generateProviderCode(params);
|
|
6240
6246
|
}
|
|
6241
6247
|
/**
|
|
6242
6248
|
* Generate the complete provider code
|
|
@@ -6258,12 +6264,12 @@ var CollectionProviderGenerator = class {
|
|
|
6258
6264
|
const arraySchemaName = `${schemaName.replace(/Schema$/, "")}ArraySchema`;
|
|
6259
6265
|
const validationSchema = isArray ? arraySchemaName : schemaName;
|
|
6260
6266
|
const imports = bare ? "" : `import type { CollectionProvider, CollectionItem } from '@stackwright/collections';
|
|
6261
|
-
import { ${isArray ? arraySchemaName : schemaName} } from './schemas';
|
|
6267
|
+
import { ${isArray ? arraySchemaName : schemaName}} } from './schemas';
|
|
6262
6268
|
|
|
6263
6269
|
`;
|
|
6264
6270
|
return `${imports}/**
|
|
6265
6271
|
* CollectionProvider for ${collectionName}
|
|
6266
|
-
*
|
|
6272
|
+
*
|
|
6267
6273
|
* Generated from OpenAPI endpoint: ${method.toUpperCase()} ${endpoint}
|
|
6268
6274
|
*/
|
|
6269
6275
|
export class ${providerName} implements CollectionProvider {
|
|
@@ -6409,7 +6415,10 @@ export class ${providerName} implements CollectionProvider {
|
|
|
6409
6415
|
*/
|
|
6410
6416
|
getBaseUrl() {
|
|
6411
6417
|
if ("servers" in this.document && this.document.servers && this.document.servers.length > 0) {
|
|
6412
|
-
|
|
6418
|
+
const firstServer = this.document.servers[0];
|
|
6419
|
+
if (firstServer !== void 0) {
|
|
6420
|
+
return firstServer.url;
|
|
6421
|
+
}
|
|
6413
6422
|
}
|
|
6414
6423
|
return "http://localhost:3000";
|
|
6415
6424
|
}
|
|
@@ -6437,7 +6446,8 @@ export class ${providerName} implements CollectionProvider {
|
|
|
6437
6446
|
*/
|
|
6438
6447
|
guessTitle(slugField) {
|
|
6439
6448
|
const titleFields = ["title", "name", "label", "displayName"];
|
|
6440
|
-
|
|
6449
|
+
const firstField = titleFields[0];
|
|
6450
|
+
return firstField !== void 0 ? firstField : `item.${slugField}`;
|
|
6441
6451
|
}
|
|
6442
6452
|
};
|
|
6443
6453
|
|
|
@@ -6447,7 +6457,9 @@ var ClientGenerator = class {
|
|
|
6447
6457
|
constructor(document, schemaMapping) {
|
|
6448
6458
|
this.document = document;
|
|
6449
6459
|
this.resolver = new SchemaResolver(document);
|
|
6450
|
-
|
|
6460
|
+
if (schemaMapping !== void 0) {
|
|
6461
|
+
this.schemaMapping = schemaMapping;
|
|
6462
|
+
}
|
|
6451
6463
|
this.requiredSchemas = /* @__PURE__ */ new Set();
|
|
6452
6464
|
this.generatedRequestSchemas = /* @__PURE__ */ new Set();
|
|
6453
6465
|
}
|
|
@@ -6805,7 +6817,8 @@ ${paramSchemas.join(",\n")}
|
|
|
6805
6817
|
*/
|
|
6806
6818
|
extractComponentName(ref) {
|
|
6807
6819
|
const parts = ref.split("/");
|
|
6808
|
-
|
|
6820
|
+
const lastPart = parts[parts.length - 1];
|
|
6821
|
+
return lastPart ?? ref;
|
|
6809
6822
|
}
|
|
6810
6823
|
/**
|
|
6811
6824
|
* Escape string for use in Zod .describe()
|
|
@@ -7552,9 +7565,9 @@ ${paramSchemas.join(",\n")}
|
|
|
7552
7565
|
endpoints.push({
|
|
7553
7566
|
path: path3,
|
|
7554
7567
|
method,
|
|
7555
|
-
operationId: operation.operationId,
|
|
7556
|
-
summary: operation.summary,
|
|
7557
|
-
description: operation.description,
|
|
7568
|
+
...operation.operationId !== void 0 && { operationId: operation.operationId },
|
|
7569
|
+
...operation.summary !== void 0 && { summary: operation.summary },
|
|
7570
|
+
...operation.description !== void 0 && { description: operation.description },
|
|
7558
7571
|
operation
|
|
7559
7572
|
});
|
|
7560
7573
|
}
|
|
@@ -7642,7 +7655,8 @@ ${paramSchemas.join(",\n")}
|
|
|
7642
7655
|
*/
|
|
7643
7656
|
getDefaultBaseUrl() {
|
|
7644
7657
|
if ("servers" in this.document && this.document.servers && this.document.servers.length > 0) {
|
|
7645
|
-
|
|
7658
|
+
const firstServer = this.document.servers[0];
|
|
7659
|
+
return firstServer ? firstServer.url : "http://localhost:3000";
|
|
7646
7660
|
}
|
|
7647
7661
|
return "http://localhost:3000";
|
|
7648
7662
|
}
|
|
@@ -7737,13 +7751,18 @@ var EndpointFilter = class {
|
|
|
7737
7751
|
let matches = true;
|
|
7738
7752
|
for (let i = 0; i < patternSegments.length; i++) {
|
|
7739
7753
|
const pSeg = patternSegments[i];
|
|
7754
|
+
if (pSeg === void 0) {
|
|
7755
|
+
matches = false;
|
|
7756
|
+
break;
|
|
7757
|
+
}
|
|
7740
7758
|
if (pSeg === "*" || pSeg === "**") {
|
|
7741
7759
|
continue;
|
|
7742
7760
|
}
|
|
7743
7761
|
if (pSeg.startsWith("{") && pSeg.endsWith("}")) {
|
|
7744
7762
|
continue;
|
|
7745
7763
|
}
|
|
7746
|
-
|
|
7764
|
+
const pathSeg = pathSegments[i];
|
|
7765
|
+
if (pSeg !== pathSeg) {
|
|
7747
7766
|
matches = false;
|
|
7748
7767
|
break;
|
|
7749
7768
|
}
|
|
@@ -7901,19 +7920,20 @@ var ApprovedSpecsValidator = class {
|
|
|
7901
7920
|
}
|
|
7902
7921
|
}
|
|
7903
7922
|
const ipv4Match = redirectUrl.hostname.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
7904
|
-
if (ipv4Match) {
|
|
7923
|
+
if (ipv4Match && ipv4Match.length >= 5) {
|
|
7905
7924
|
const octets = ipv4Match.slice(1, 5).map(Number);
|
|
7906
|
-
const
|
|
7907
|
-
|
|
7925
|
+
const first = octets[0];
|
|
7926
|
+
const second = octets[1];
|
|
7927
|
+
if (first !== void 0 && first === 10) {
|
|
7908
7928
|
return false;
|
|
7909
7929
|
}
|
|
7910
|
-
if (first === 172 && second >= 16 && second <= 31) {
|
|
7930
|
+
if (first !== void 0 && second !== void 0 && first === 172 && second >= 16 && second <= 31) {
|
|
7911
7931
|
return false;
|
|
7912
7932
|
}
|
|
7913
|
-
if (first === 192 && second === 168) {
|
|
7933
|
+
if (first !== void 0 && second !== void 0 && first === 192 && second === 168) {
|
|
7914
7934
|
return false;
|
|
7915
7935
|
}
|
|
7916
|
-
if (first === 127) {
|
|
7936
|
+
if (first !== void 0 && first === 127) {
|
|
7917
7937
|
return false;
|
|
7918
7938
|
}
|
|
7919
7939
|
}
|
|
@@ -8477,12 +8497,12 @@ import type * as schemas from './schemas';
|
|
|
8477
8497
|
slugField: collection.slug_field,
|
|
8478
8498
|
filters: collection.filters
|
|
8479
8499
|
};
|
|
8480
|
-
|
|
8500
|
+
const providerOptions = { bare: true };
|
|
8481
8501
|
if (auth) {
|
|
8482
8502
|
if (auth.type === "bearer" || auth.type === "apiKey") {
|
|
8483
8503
|
providerOptions.auth = {
|
|
8484
8504
|
type: auth.type,
|
|
8485
|
-
|
|
8505
|
+
...auth.type === "apiKey" && { headerName: "X-API-Key" }
|
|
8486
8506
|
};
|
|
8487
8507
|
} else if (auth.type === "oauth2") {
|
|
8488
8508
|
console.warn(
|
|
@@ -8543,7 +8563,8 @@ import { ${Array.from(schemaImports).join(", ")} } from './schemas';
|
|
|
8543
8563
|
}
|
|
8544
8564
|
extractComponentName(ref) {
|
|
8545
8565
|
const parts = ref.split("/");
|
|
8546
|
-
|
|
8566
|
+
const lastPart = parts[parts.length - 1];
|
|
8567
|
+
return lastPart ?? ref;
|
|
8547
8568
|
}
|
|
8548
8569
|
getOperationTypeName(operationId) {
|
|
8549
8570
|
return operationId.charAt(0).toUpperCase() + operationId.slice(1);
|
|
@@ -8621,22 +8642,24 @@ function validateFetchUrl(baseUrl) {
|
|
|
8621
8642
|
const ip = url.hostname;
|
|
8622
8643
|
if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(ip)) {
|
|
8623
8644
|
const octets = ip.split(".").map(Number);
|
|
8624
|
-
|
|
8645
|
+
const first = octets[0];
|
|
8646
|
+
const second = octets[1];
|
|
8647
|
+
if (first !== void 0 && first === 127) {
|
|
8625
8648
|
throw new Error("SSRF Prevention: Blocked loopback address: " + ip);
|
|
8626
8649
|
}
|
|
8627
|
-
if (
|
|
8650
|
+
if (first !== void 0 && first === 10) {
|
|
8628
8651
|
throw new Error("SSRF Prevention: Blocked private address: " + ip);
|
|
8629
8652
|
}
|
|
8630
|
-
if (
|
|
8653
|
+
if (first !== void 0 && second !== void 0 && first === 172 && second >= 16 && second <= 31) {
|
|
8631
8654
|
throw new Error("SSRF Prevention: Blocked private address: " + ip);
|
|
8632
8655
|
}
|
|
8633
|
-
if (
|
|
8656
|
+
if (first !== void 0 && second !== void 0 && first === 192 && second === 168) {
|
|
8634
8657
|
throw new Error("SSRF Prevention: Blocked private address: " + ip);
|
|
8635
8658
|
}
|
|
8636
|
-
if (
|
|
8659
|
+
if (first !== void 0 && second !== void 0 && first === 169 && second === 254) {
|
|
8637
8660
|
throw new Error("SSRF Prevention: Blocked link-local address: " + ip);
|
|
8638
8661
|
}
|
|
8639
|
-
if (
|
|
8662
|
+
if (first !== void 0 && first === 0) {
|
|
8640
8663
|
throw new Error("SSRF Prevention: Blocked current network address: " + ip);
|
|
8641
8664
|
}
|
|
8642
8665
|
}
|
|
@@ -8677,7 +8700,7 @@ function createOpenAPIFetcher(config) {
|
|
|
8677
8700
|
const response = await fetch(url.toString(), {
|
|
8678
8701
|
method: method.toUpperCase(),
|
|
8679
8702
|
headers: requestHeaders,
|
|
8680
|
-
body: supportsBody && body ? JSON.stringify(body) :
|
|
8703
|
+
body: supportsBody && body ? JSON.stringify(body) : null
|
|
8681
8704
|
});
|
|
8682
8705
|
if (!response.ok) {
|
|
8683
8706
|
const safeStatus = response.status;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackwright-pro/openapi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "OpenAPI spec to typed Stackwright application compiler",
|
|
5
5
|
"license": "PROPRIETARY",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
36
36
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
37
|
-
"test": "vitest"
|
|
37
|
+
"test": "vitest",
|
|
38
|
+
"test:coverage": "vitest run --coverage"
|
|
38
39
|
}
|
|
39
40
|
}
|