@shriyanss/js-recon 1.1.3-beta.2 → 1.1.3
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/.github/workflows/build-and-prettify.yaml +2 -2
- package/.github/workflows/publish-js-recon.yml +11 -3
- package/CHANGELOG.md +18 -0
- package/build/globalConfig.js +1 -1
- package/build/globalConfig.js.map +1 -1
- package/build/utility/openapiGenerator.js +27 -1
- package/build/utility/openapiGenerator.js.map +1 -1
- package/build/utility/replaceUrlPlaceholders.js +33 -0
- package/build/utility/replaceUrlPlaceholders.js.map +1 -0
- package/package.json +1 -1
|
@@ -58,8 +58,8 @@ jobs:
|
|
|
58
58
|
|
|
59
59
|
- name: Commit and push changes
|
|
60
60
|
run: |
|
|
61
|
-
git config user.name "
|
|
62
|
-
git config user.email "
|
|
61
|
+
git config user.name "github-actions[bot]"
|
|
62
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
63
63
|
git add .
|
|
64
64
|
git commit -m "chore: prettify code" || echo "No changes to commit"
|
|
65
65
|
git push
|
|
@@ -139,12 +139,20 @@ jobs:
|
|
|
139
139
|
- publish-docker
|
|
140
140
|
- publish-ghcr
|
|
141
141
|
runs-on: ubuntu-latest
|
|
142
|
+
permissions:
|
|
143
|
+
contents: write
|
|
142
144
|
steps:
|
|
143
145
|
- uses: actions/checkout@v4
|
|
146
|
+
with:
|
|
147
|
+
fetch-depth: 0
|
|
144
148
|
- name: Merge main and dev
|
|
145
149
|
run: |
|
|
146
|
-
|
|
150
|
+
git config --global user.name 'github-actions[bot]'
|
|
151
|
+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
|
152
|
+
git fetch origin main:main
|
|
153
|
+
git fetch origin dev:dev
|
|
147
154
|
git checkout dev
|
|
148
|
-
git merge main
|
|
155
|
+
git merge --no-ff -m "chore: merge changes after release $VERSION" main -X theirs || (git status && git diff && exit 0)
|
|
149
156
|
git push origin dev
|
|
150
|
-
|
|
157
|
+
env:
|
|
158
|
+
VERSION: ${{ github.event.release.tag_name }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 1.1.3 - 2025.07.28
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
## 1.1.3-beta.3 - 2025.07.26
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Added path and query parameter extraction to OpenAPI spec generation
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
3
21
|
## 1.1.3-beta.2 - 2025.07.25
|
|
4
22
|
|
|
5
23
|
### Added
|
package/build/globalConfig.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const githubURL = "https://github.com/shriyanss/js-recon";
|
|
2
2
|
const modulesDocs = "https://js-recon.io/docs/category/modules";
|
|
3
|
-
const version = "1.1.3
|
|
3
|
+
const version = "1.1.3";
|
|
4
4
|
const toolDesc = "JS Recon Tool";
|
|
5
5
|
const axiosNonHttpMethods = ["isAxiosError"]; // methods available in axios, which are not for making HTTP requests
|
|
6
6
|
let CONFIG = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalConfig.js","sourceRoot":"","sources":["../src/globalConfig.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,uCAAuC,CAAC;AAC1D,MAAM,WAAW,GAAG,2CAA2C,CAAC;AAChE,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"globalConfig.js","sourceRoot":"","sources":["../src/globalConfig.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,uCAAuC,CAAC;AAC1D,MAAM,WAAW,GAAG,2CAA2C,CAAC;AAChE,MAAM,OAAO,GAAG,OAAO,CAAC;AACxB,MAAM,QAAQ,GAAG,eAAe,CAAC;AACjC,MAAM,mBAAmB,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,qEAAqE;AAEnH,IAAI,MAAM,GAAG;IACT,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,WAAW;IACxB,eAAe,EAAE,qFAAqF,SAAS,kCAAkC;IACjJ,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,QAAQ;IAClB,mBAAmB,EAAE,mBAAmB;CAC3C,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as globalsUtil from "./globals.js";
|
|
2
|
+
import replacePlaceholders from "./replaceUrlPlaceholders.js";
|
|
2
3
|
/**
|
|
3
4
|
* Generates a minimal OpenAPI v3 specification document from the collected
|
|
4
5
|
* `OpenapiOutputItem` objects.
|
|
@@ -39,7 +40,8 @@ export const generateOpenapiV3Spec = (items, chunks) => {
|
|
|
39
40
|
paths: {},
|
|
40
41
|
};
|
|
41
42
|
for (const item of items) {
|
|
42
|
-
const
|
|
43
|
+
const pathKeyBeforeQuery = item.path.split("?")[0];
|
|
44
|
+
const pathKey = replacePlaceholders(pathKeyBeforeQuery.startsWith("/") ? pathKeyBeforeQuery : `/${pathKeyBeforeQuery}`);
|
|
43
45
|
const method = item.method.toLowerCase();
|
|
44
46
|
if (!spec.paths[pathKey]) {
|
|
45
47
|
spec.paths[pathKey] = {};
|
|
@@ -54,6 +56,30 @@ export const generateOpenapiV3Spec = (items, chunks) => {
|
|
|
54
56
|
required: true,
|
|
55
57
|
schema: { type: "string", example: value },
|
|
56
58
|
}));
|
|
59
|
+
// Extract path parameters
|
|
60
|
+
const pathParams = pathKey.match(/\{([^}]+)\}/g);
|
|
61
|
+
if (pathParams) {
|
|
62
|
+
for (const p of pathParams) {
|
|
63
|
+
const paramName = p.slice(1, -1);
|
|
64
|
+
parameters.push({
|
|
65
|
+
name: paramName,
|
|
66
|
+
in: "path",
|
|
67
|
+
required: true,
|
|
68
|
+
schema: { type: "string", example: "any" },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Extract query parameters
|
|
73
|
+
const url = new URL(item.path, "http://dummybase");
|
|
74
|
+
const queryParams = url.searchParams;
|
|
75
|
+
queryParams.forEach((value, name) => {
|
|
76
|
+
parameters.push({
|
|
77
|
+
name: name,
|
|
78
|
+
in: "query",
|
|
79
|
+
required: false, // Or determine based on logic
|
|
80
|
+
schema: { type: "string", example: value },
|
|
81
|
+
});
|
|
82
|
+
});
|
|
57
83
|
const operationObject = {
|
|
58
84
|
summary: `${pathKey}`,
|
|
59
85
|
responses: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapiGenerator.js","sourceRoot":"","sources":["../../src/utility/openapiGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"openapiGenerator.js","sourceRoot":"","sources":["../../src/utility/openapiGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAC5C,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;AAkB9D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAU,EAAU,EAAE;IACjD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,QAAQ,CAAC,CAAC,uDAAuD;IAC5E,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,OAAO,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,KAAK,CAAC;IAC5B,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7D,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,OAAO,QAAQ,CAAC,CAAC,2BAA2B;AAChD,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E,IAAI,CAAC,IAAI;yBACrB;qBACJ;iBACJ,CAAC;YACN,CAAC;YACD,eAAe,CAAC,WAAW,GAAG,WAAW,CAAC;QAC9C,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC;IAClD,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const replacePlaceholders = (url) => {
|
|
2
|
+
// match it against multiple regexes and replace with the right placeholder as per the openapi spec
|
|
3
|
+
// first for member expression
|
|
4
|
+
const memberExpressionRegex = /\[MemberExpression -> (.*?)\]/g;
|
|
5
|
+
const memberExpressionMatches = url.matchAll(memberExpressionRegex);
|
|
6
|
+
for (const match of memberExpressionMatches) {
|
|
7
|
+
url = url.replace(match[0], "{" + match[1] + "}");
|
|
8
|
+
}
|
|
9
|
+
// second goes `[var a]`
|
|
10
|
+
const varRegex = /\[var (.*?)\]/g;
|
|
11
|
+
const varMatches = url.matchAll(varRegex);
|
|
12
|
+
for (const match of varMatches) {
|
|
13
|
+
url = url.replace(match[0], "{" + match[1] + "}");
|
|
14
|
+
}
|
|
15
|
+
// `[unresolved member expression]` is a bit tricky, so
|
|
16
|
+
// will replace with `{unres_mem_exp_<appearance_count_like_1_and_2_in_case_found_multiple_times>}`
|
|
17
|
+
const unresolvedMemberExpressionRegex = /\[unresolved member expression\]/g;
|
|
18
|
+
const unresolvedMemberExpressionMatches = url.matchAll(unresolvedMemberExpressionRegex);
|
|
19
|
+
let appearanceCount = 1;
|
|
20
|
+
for (const match of unresolvedMemberExpressionMatches) {
|
|
21
|
+
url = url.replace(match[0], "{unres_mem_exp_" + appearanceCount + "}");
|
|
22
|
+
appearanceCount++;
|
|
23
|
+
}
|
|
24
|
+
// `[unresolved: a]` can't escape as well
|
|
25
|
+
const unresolvedRegex = /\[unresolved: (.*?)\]/g;
|
|
26
|
+
const unresolvedMatches = url.matchAll(unresolvedRegex);
|
|
27
|
+
for (const match of unresolvedMatches) {
|
|
28
|
+
url = url.replace(match[0], "{" + match[1] + "}");
|
|
29
|
+
}
|
|
30
|
+
return url;
|
|
31
|
+
};
|
|
32
|
+
export default replacePlaceholders;
|
|
33
|
+
//# sourceMappingURL=replaceUrlPlaceholders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceUrlPlaceholders.js","sourceRoot":"","sources":["../../src/utility/replaceUrlPlaceholders.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAU,EAAE;IAChD,mGAAmG;IAEnG,8BAA8B;IAC9B,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;IAC/D,MAAM,uBAAuB,GAAG,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IACpE,KAAK,MAAM,KAAK,IAAI,uBAAuB,EAAE,CAAC;QAC1C,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,wBAAwB;IACxB,MAAM,QAAQ,GAAG,gBAAgB,CAAC;IAClC,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1C,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC7B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,uDAAuD;IACvD,mGAAmG;IACnG,MAAM,+BAA+B,GAAG,mCAAmC,CAAC;IAC5E,MAAM,iCAAiC,GAAG,GAAG,CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAC;IACxF,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,KAAK,MAAM,KAAK,I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