@theholocron/holocron-plugin-bruno 5.0.0-alpha.469 → 5.0.0-alpha.470
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.mjs +32 -0
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -31,6 +31,36 @@ const describeIssue = (issue) => {
|
|
|
31
31
|
if (issue !== null && typeof issue === "object" && "message" in issue && typeof issue.message === "string") return issue.message;
|
|
32
32
|
return JSON.stringify(issue);
|
|
33
33
|
};
|
|
34
|
+
// src/repair-signing-body.ts
|
|
35
|
+
/** What Bruno's converter writes for Postman's `pm.variables.replaceIn(pm.request.body.raw)`. */
|
|
36
|
+
const BROKEN_BODY = "bru.interpolate(req.getBody().raw)";
|
|
37
|
+
/**
|
|
38
|
+
* The body text a signing script has to sign. `req.getBody()` is the parsed object for a JSON body and has no `.raw`,
|
|
39
|
+
* so the converter's line signs nothing; a body Bruno cannot parse before its variables are filled in (an unquoted
|
|
40
|
+
* `{{number}}`) comes back as text. Both reach `bru.interpolate()` as the one string Bruno itself fills in and sends.
|
|
41
|
+
*
|
|
42
|
+
* Limit: a body that is itself a JSON string (`"hello"`) also comes back as a string, so it is signed without its
|
|
43
|
+
* quotes. A webhook payload is always an object, and every signed body in the request files is one, so it is not handled.
|
|
44
|
+
*/
|
|
45
|
+
const BODY_TEXT = "bru.interpolate(typeof req.getBody() === \"string\" ? req.getBody() : JSON.stringify(req.getBody()))";
|
|
46
|
+
/**
|
|
47
|
+
* Repairs what the converter drops in a script that signs the request body: Postman's `pm.request.body.raw` becomes
|
|
48
|
+
* `req.getBody().raw`, which is empty in Bruno, so every signature is over the wrong text and the receiver rejects the
|
|
49
|
+
* request. Walks the converted collection and rewrites each script that has the line, in place.
|
|
50
|
+
*
|
|
51
|
+
* @param converted - A collection (or any part of one) from `postmanToBruno()`.
|
|
52
|
+
*/
|
|
53
|
+
function repairSigningBody(converted) {
|
|
54
|
+
if (Array.isArray(converted)) {
|
|
55
|
+
for (const entry of converted) repairSigningBody(entry);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (typeof converted !== "object" || converted === null) return;
|
|
59
|
+
const record = converted;
|
|
60
|
+
for (const [key, value] of Object.entries(record)) if (typeof value === "string") {
|
|
61
|
+
if (value.includes(BROKEN_BODY)) record[key] = value.split(BROKEN_BODY).join(BODY_TEXT);
|
|
62
|
+
} else repairSigningBody(value);
|
|
63
|
+
}
|
|
34
64
|
// src/convert-collection.ts
|
|
35
65
|
/** The collection as Bruno's own JSON export lays it out: one file, with the environments inside it. */
|
|
36
66
|
function brunoJson(bruno) {
|
|
@@ -58,6 +88,7 @@ function brunoJson(bruno) {
|
|
|
58
88
|
async function convertCollection(collection, environments) {
|
|
59
89
|
const read = await postmanToBruno(collection, { preserveScripts: false });
|
|
60
90
|
const bruno = read.collection;
|
|
91
|
+
repairSigningBody(bruno);
|
|
61
92
|
const converted = await Promise.all(environments.map((env) => postmanToBrunoEnvironment(env)));
|
|
62
93
|
if (converted.length > 0) bruno.environments = converted;
|
|
63
94
|
return {
|
|
@@ -207,6 +238,7 @@ function writeItems(items, dir, files) {
|
|
|
207
238
|
async function collectionFiles(collection, environments) {
|
|
208
239
|
const read = await postmanToBruno(collection, { preserveScripts: false });
|
|
209
240
|
const bruno = read.collection;
|
|
241
|
+
repairSigningBody(bruno);
|
|
210
242
|
const name = bruno.name ?? "Untitled Collection";
|
|
211
243
|
const files = /* @__PURE__ */ new Map();
|
|
212
244
|
files.set("opencollection.yml", stringifyCollection(bruno.root ?? {}, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-bruno",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.470",
|
|
4
4
|
"description": "Holocron plugin for Bruno. Implements the tooling capability over files: it exports the repo's request collections as Bruno JSON files.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bruno",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"tsx": "4.23.15",
|
|
45
45
|
"typescript": "^5.9.3",
|
|
46
46
|
"vitest": "^5.1.0",
|
|
47
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
48
|
-
"@theholocron/tsconfig": "^8.9.0-alpha.
|
|
49
|
-
"@theholocron/tsdown-config": "^8.9.0-alpha.
|
|
50
|
-
"@theholocron/eslint-config": "^8.9.0-alpha.
|
|
51
|
-
"@theholocron/vitest-config": "^8.9.0-alpha.
|
|
47
|
+
"@theholocron/cli": "5.0.0-alpha.470",
|
|
48
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.20",
|
|
49
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.20",
|
|
50
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.20",
|
|
51
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.20"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
54
|
+
"@theholocron/cli": "5.0.0-alpha.470"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=22"
|