mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-19 23:41:18 +02:00
Websockets for plugin runtime communication (#156)
This commit is contained in:
91
src-tauri/vendored/plugins/auth-jwt/build/index.js
generated
91
src-tauri/vendored/plugins/auth-jwt/build/index.js
generated
@@ -34,34 +34,34 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
var require_safe_buffer = __commonJS({
|
||||
"../../node_modules/safe-buffer/index.js"(exports2, module2) {
|
||||
var buffer = require("buffer");
|
||||
var Buffer2 = buffer.Buffer;
|
||||
var Buffer3 = buffer.Buffer;
|
||||
function copyProps(src, dst) {
|
||||
for (var key in src) {
|
||||
dst[key] = src[key];
|
||||
}
|
||||
}
|
||||
if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
|
||||
if (Buffer3.from && Buffer3.alloc && Buffer3.allocUnsafe && Buffer3.allocUnsafeSlow) {
|
||||
module2.exports = buffer;
|
||||
} else {
|
||||
copyProps(buffer, exports2);
|
||||
exports2.Buffer = SafeBuffer;
|
||||
}
|
||||
function SafeBuffer(arg, encodingOrOffset, length) {
|
||||
return Buffer2(arg, encodingOrOffset, length);
|
||||
return Buffer3(arg, encodingOrOffset, length);
|
||||
}
|
||||
SafeBuffer.prototype = Object.create(Buffer2.prototype);
|
||||
copyProps(Buffer2, SafeBuffer);
|
||||
SafeBuffer.prototype = Object.create(Buffer3.prototype);
|
||||
copyProps(Buffer3, SafeBuffer);
|
||||
SafeBuffer.from = function(arg, encodingOrOffset, length) {
|
||||
if (typeof arg === "number") {
|
||||
throw new TypeError("Argument must not be a number");
|
||||
}
|
||||
return Buffer2(arg, encodingOrOffset, length);
|
||||
return Buffer3(arg, encodingOrOffset, length);
|
||||
};
|
||||
SafeBuffer.alloc = function(size, fill, encoding) {
|
||||
if (typeof size !== "number") {
|
||||
throw new TypeError("Argument must be a number");
|
||||
}
|
||||
var buf = Buffer2(size);
|
||||
var buf = Buffer3(size);
|
||||
if (fill !== void 0) {
|
||||
if (typeof encoding === "string") {
|
||||
buf.fill(fill, encoding);
|
||||
@@ -77,7 +77,7 @@ var require_safe_buffer = __commonJS({
|
||||
if (typeof size !== "number") {
|
||||
throw new TypeError("Argument must be a number");
|
||||
}
|
||||
return Buffer2(size);
|
||||
return Buffer3(size);
|
||||
};
|
||||
SafeBuffer.allocUnsafeSlow = function(size) {
|
||||
if (typeof size !== "number") {
|
||||
@@ -91,7 +91,7 @@ var require_safe_buffer = __commonJS({
|
||||
// ../../node_modules/jws/lib/data-stream.js
|
||||
var require_data_stream = __commonJS({
|
||||
"../../node_modules/jws/lib/data-stream.js"(exports2, module2) {
|
||||
var Buffer2 = require_safe_buffer().Buffer;
|
||||
var Buffer3 = require_safe_buffer().Buffer;
|
||||
var Stream = require("stream");
|
||||
var util = require("util");
|
||||
function DataStream(data) {
|
||||
@@ -99,11 +99,11 @@ var require_data_stream = __commonJS({
|
||||
this.writable = true;
|
||||
this.readable = true;
|
||||
if (!data) {
|
||||
this.buffer = Buffer2.alloc(0);
|
||||
this.buffer = Buffer3.alloc(0);
|
||||
return this;
|
||||
}
|
||||
if (typeof data.pipe === "function") {
|
||||
this.buffer = Buffer2.alloc(0);
|
||||
this.buffer = Buffer3.alloc(0);
|
||||
data.pipe(this);
|
||||
return this;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ var require_data_stream = __commonJS({
|
||||
}
|
||||
util.inherits(DataStream, Stream);
|
||||
DataStream.prototype.write = function write(data) {
|
||||
this.buffer = Buffer2.concat([this.buffer, Buffer2.from(data)]);
|
||||
this.buffer = Buffer3.concat([this.buffer, Buffer3.from(data)]);
|
||||
this.emit("data", data);
|
||||
};
|
||||
DataStream.prototype.end = function end(data) {
|
||||
@@ -140,11 +140,11 @@ var require_data_stream = __commonJS({
|
||||
var require_buffer_equal_constant_time = __commonJS({
|
||||
"../../node_modules/buffer-equal-constant-time/index.js"(exports2, module2) {
|
||||
"use strict";
|
||||
var Buffer2 = require("buffer").Buffer;
|
||||
var Buffer3 = require("buffer").Buffer;
|
||||
var SlowBuffer = require("buffer").SlowBuffer;
|
||||
module2.exports = bufferEq;
|
||||
function bufferEq(a, b) {
|
||||
if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) {
|
||||
if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
|
||||
return false;
|
||||
}
|
||||
if (a.length !== b.length) {
|
||||
@@ -157,14 +157,14 @@ var require_buffer_equal_constant_time = __commonJS({
|
||||
return c === 0;
|
||||
}
|
||||
bufferEq.install = function() {
|
||||
Buffer2.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
|
||||
Buffer3.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
|
||||
return bufferEq(this, that);
|
||||
};
|
||||
};
|
||||
var origBufEqual = Buffer2.prototype.equal;
|
||||
var origBufEqual = Buffer3.prototype.equal;
|
||||
var origSlowBufEqual = SlowBuffer.prototype.equal;
|
||||
bufferEq.restore = function() {
|
||||
Buffer2.prototype.equal = origBufEqual;
|
||||
Buffer3.prototype.equal = origBufEqual;
|
||||
SlowBuffer.prototype.equal = origSlowBufEqual;
|
||||
};
|
||||
}
|
||||
@@ -198,7 +198,7 @@ var require_param_bytes_for_alg = __commonJS({
|
||||
var require_ecdsa_sig_formatter = __commonJS({
|
||||
"../../node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js"(exports2, module2) {
|
||||
"use strict";
|
||||
var Buffer2 = require_safe_buffer().Buffer;
|
||||
var Buffer3 = require_safe_buffer().Buffer;
|
||||
var getParamBytesForAlg = require_param_bytes_for_alg();
|
||||
var MAX_OCTET = 128;
|
||||
var CLASS_UNIVERSAL = 0;
|
||||
@@ -211,10 +211,10 @@ var require_ecdsa_sig_formatter = __commonJS({
|
||||
return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
||||
}
|
||||
function signatureAsBuffer(signature) {
|
||||
if (Buffer2.isBuffer(signature)) {
|
||||
if (Buffer3.isBuffer(signature)) {
|
||||
return signature;
|
||||
} else if ("string" === typeof signature) {
|
||||
return Buffer2.from(signature, "base64");
|
||||
return Buffer3.from(signature, "base64");
|
||||
}
|
||||
throw new TypeError("ECDSA signature must be a Base64 string or a Buffer");
|
||||
}
|
||||
@@ -262,7 +262,7 @@ var require_ecdsa_sig_formatter = __commonJS({
|
||||
throw new Error('Expected to consume entire buffer, but "' + (inputLength - offset) + '" bytes remain');
|
||||
}
|
||||
var rPadding = paramBytes - rLength, sPadding = paramBytes - sLength;
|
||||
var dst = Buffer2.allocUnsafe(rPadding + rLength + sPadding + sLength);
|
||||
var dst = Buffer3.allocUnsafe(rPadding + rLength + sPadding + sLength);
|
||||
for (offset = 0; offset < rPadding; ++offset) {
|
||||
dst[offset] = 0;
|
||||
}
|
||||
@@ -300,7 +300,7 @@ var require_ecdsa_sig_formatter = __commonJS({
|
||||
var sLength = paramBytes - sPadding;
|
||||
var rsBytes = 1 + 1 + rLength + 1 + 1 + sLength;
|
||||
var shortLength = rsBytes < MAX_OCTET;
|
||||
var dst = Buffer2.allocUnsafe((shortLength ? 2 : 3) + rsBytes);
|
||||
var dst = Buffer3.allocUnsafe((shortLength ? 2 : 3) + rsBytes);
|
||||
var offset = 0;
|
||||
dst[offset++] = ENCODED_TAG_SEQ;
|
||||
if (shortLength) {
|
||||
@@ -338,7 +338,7 @@ var require_ecdsa_sig_formatter = __commonJS({
|
||||
var require_jwa = __commonJS({
|
||||
"../../node_modules/jwa/index.js"(exports2, module2) {
|
||||
var bufferEqual = require_buffer_equal_constant_time();
|
||||
var Buffer2 = require_safe_buffer().Buffer;
|
||||
var Buffer3 = require_safe_buffer().Buffer;
|
||||
var crypto = require("crypto");
|
||||
var formatEcdsa = require_ecdsa_sig_formatter();
|
||||
var util = require("util");
|
||||
@@ -352,7 +352,7 @@ var require_jwa = __commonJS({
|
||||
MSG_INVALID_SECRET += "or a KeyObject";
|
||||
}
|
||||
function checkIsPublicKey(key) {
|
||||
if (Buffer2.isBuffer(key)) {
|
||||
if (Buffer3.isBuffer(key)) {
|
||||
return;
|
||||
}
|
||||
if (typeof key === "string") {
|
||||
@@ -375,7 +375,7 @@ var require_jwa = __commonJS({
|
||||
}
|
||||
}
|
||||
function checkIsPrivateKey(key) {
|
||||
if (Buffer2.isBuffer(key)) {
|
||||
if (Buffer3.isBuffer(key)) {
|
||||
return;
|
||||
}
|
||||
if (typeof key === "string") {
|
||||
@@ -387,7 +387,7 @@ var require_jwa = __commonJS({
|
||||
throw typeError(MSG_INVALID_SIGNER_KEY);
|
||||
}
|
||||
function checkIsSecretKey(key) {
|
||||
if (Buffer2.isBuffer(key)) {
|
||||
if (Buffer3.isBuffer(key)) {
|
||||
return;
|
||||
}
|
||||
if (typeof key === "string") {
|
||||
@@ -425,7 +425,7 @@ var require_jwa = __commonJS({
|
||||
return new TypeError(errMsg);
|
||||
}
|
||||
function bufferOrString(obj) {
|
||||
return Buffer2.isBuffer(obj) || typeof obj === "string";
|
||||
return Buffer3.isBuffer(obj) || typeof obj === "string";
|
||||
}
|
||||
function normalizeInput(thing) {
|
||||
if (!bufferOrString(thing))
|
||||
@@ -444,7 +444,7 @@ var require_jwa = __commonJS({
|
||||
function createHmacVerifier(bits) {
|
||||
return function verify(thing, signature, secret) {
|
||||
var computedSig = createHmacSigner(bits)(thing, secret);
|
||||
return bufferEqual(Buffer2.from(signature), Buffer2.from(computedSig));
|
||||
return bufferEqual(Buffer3.from(signature), Buffer3.from(computedSig));
|
||||
};
|
||||
}
|
||||
function createKeySigner(bits) {
|
||||
@@ -550,11 +550,11 @@ var require_jwa = __commonJS({
|
||||
// ../../node_modules/jws/lib/tostring.js
|
||||
var require_tostring = __commonJS({
|
||||
"../../node_modules/jws/lib/tostring.js"(exports2, module2) {
|
||||
var Buffer2 = require("buffer").Buffer;
|
||||
var Buffer3 = require("buffer").Buffer;
|
||||
module2.exports = function toString(obj) {
|
||||
if (typeof obj === "string")
|
||||
return obj;
|
||||
if (typeof obj === "number" || Buffer2.isBuffer(obj))
|
||||
if (typeof obj === "number" || Buffer3.isBuffer(obj))
|
||||
return obj.toString();
|
||||
return JSON.stringify(obj);
|
||||
};
|
||||
@@ -564,14 +564,14 @@ var require_tostring = __commonJS({
|
||||
// ../../node_modules/jws/lib/sign-stream.js
|
||||
var require_sign_stream = __commonJS({
|
||||
"../../node_modules/jws/lib/sign-stream.js"(exports2, module2) {
|
||||
var Buffer2 = require_safe_buffer().Buffer;
|
||||
var Buffer3 = require_safe_buffer().Buffer;
|
||||
var DataStream = require_data_stream();
|
||||
var jwa = require_jwa();
|
||||
var Stream = require("stream");
|
||||
var toString = require_tostring();
|
||||
var util = require("util");
|
||||
function base64url(string, encoding) {
|
||||
return Buffer2.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
||||
return Buffer3.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
||||
}
|
||||
function jwsSecuredInput(header, payload, encoding) {
|
||||
encoding = encoding || "utf8";
|
||||
@@ -634,7 +634,7 @@ var require_sign_stream = __commonJS({
|
||||
// ../../node_modules/jws/lib/verify-stream.js
|
||||
var require_verify_stream = __commonJS({
|
||||
"../../node_modules/jws/lib/verify-stream.js"(exports2, module2) {
|
||||
var Buffer2 = require_safe_buffer().Buffer;
|
||||
var Buffer3 = require_safe_buffer().Buffer;
|
||||
var DataStream = require_data_stream();
|
||||
var jwa = require_jwa();
|
||||
var Stream = require("stream");
|
||||
@@ -655,7 +655,7 @@ var require_verify_stream = __commonJS({
|
||||
}
|
||||
function headerFromJWS(jwsSig) {
|
||||
var encodedHeader = jwsSig.split(".", 1)[0];
|
||||
return safeJsonParse(Buffer2.from(encodedHeader, "base64").toString("binary"));
|
||||
return safeJsonParse(Buffer3.from(encodedHeader, "base64").toString("binary"));
|
||||
}
|
||||
function securedInputFromJWS(jwsSig) {
|
||||
return jwsSig.split(".", 2).join(".");
|
||||
@@ -666,7 +666,7 @@ var require_verify_stream = __commonJS({
|
||||
function payloadFromJWS(jwsSig, encoding) {
|
||||
encoding = encoding || "utf8";
|
||||
var payload = jwsSig.split(".")[1];
|
||||
return Buffer2.from(payload, "base64").toString(encoding);
|
||||
return Buffer3.from(payload, "base64").toString(encoding);
|
||||
}
|
||||
function isValidJws(string) {
|
||||
return JWS_REGEX.test(string) && !!headerFromJWS(string);
|
||||
@@ -3793,6 +3793,7 @@ __export(src_exports, {
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var import_jsonwebtoken = __toESM(require_jsonwebtoken());
|
||||
var import_node_buffer = __toESM(require("node:buffer"));
|
||||
var algorithms = [
|
||||
"HS256",
|
||||
"HS384",
|
||||
@@ -3805,7 +3806,8 @@ var algorithms = [
|
||||
"PS512",
|
||||
"ES256",
|
||||
"ES384",
|
||||
"ES512"
|
||||
"ES512",
|
||||
"none"
|
||||
];
|
||||
var defaultAlgorithm = algorithms[0];
|
||||
var plugin = {
|
||||
@@ -3818,31 +3820,34 @@ var plugin = {
|
||||
type: "select",
|
||||
name: "algorithm",
|
||||
label: "Algorithm",
|
||||
hideLabel: true,
|
||||
defaultValue: defaultAlgorithm,
|
||||
options: algorithms.map((value) => ({ name: value, value }))
|
||||
options: algorithms.map((value) => ({ name: value === "none" ? "None" : value, value }))
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
type: "editor",
|
||||
name: "secret",
|
||||
label: "Secret",
|
||||
optional: true
|
||||
label: "Secret or Private Key",
|
||||
optional: true,
|
||||
hideGutter: true
|
||||
},
|
||||
{
|
||||
type: "checkbox",
|
||||
name: "secretBase64",
|
||||
label: "Secret Base64 Encoded"
|
||||
label: "Secret is base64 encoded"
|
||||
},
|
||||
{
|
||||
type: "editor",
|
||||
name: "payload",
|
||||
label: "Payload",
|
||||
language: "json",
|
||||
optional: true
|
||||
defaultValue: '{\n "foo": "bar"\n}',
|
||||
placeholder: "{ }"
|
||||
}
|
||||
],
|
||||
async onApply(_ctx, args) {
|
||||
const { algorithm, secret: _secret, secretBase64, payload } = args.config;
|
||||
const secret = secretBase64 ? Buffer.from(`${_secret}`, "base64") : `${_secret}`;
|
||||
const secret = secretBase64 ? import_node_buffer.default.from(`${_secret}`, "base64") : `${_secret}`;
|
||||
const token = import_jsonwebtoken.default.sign(`${payload}`, secret, { algorithm });
|
||||
const value = `Bearer ${token}`;
|
||||
return { setHeaders: [{ name: "Authorization", value }] };
|
||||
|
||||
@@ -20,8 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
plugin: () => plugin,
|
||||
pluginHookExport: () => pluginHookExport
|
||||
convertToCurl: () => convertToCurl,
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var NEWLINE = "\\\n ";
|
||||
@@ -32,13 +32,13 @@ var plugin = {
|
||||
icon: "copy",
|
||||
async onSelect(ctx, args) {
|
||||
const rendered_request = await ctx.httpRequest.render({ httpRequest: args.httpRequest, purpose: "preview" });
|
||||
const data = await pluginHookExport(ctx, rendered_request);
|
||||
const data = await convertToCurl(rendered_request);
|
||||
ctx.clipboard.copyText(data);
|
||||
ctx.toast.show({ message: "Curl copied to clipboard", icon: "copy" });
|
||||
}
|
||||
}]
|
||||
};
|
||||
async function pluginHookExport(_ctx, request) {
|
||||
async function convertToCurl(request) {
|
||||
const xs = ["curl"];
|
||||
if (request.method) xs.push("-X", request.method);
|
||||
if (request.url) xs.push(quote(request.url));
|
||||
@@ -104,6 +104,6 @@ function maybeParseJSON(v, fallback) {
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
plugin,
|
||||
pluginHookExport
|
||||
convertToCurl,
|
||||
plugin
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
pluginHookResponseFilter: () => pluginHookResponseFilter
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
@@ -499,12 +499,18 @@ JSONPath.prototype.safeVm = import_vm.default;
|
||||
var SafeScript = import_vm.default.Script;
|
||||
|
||||
// src/index.ts
|
||||
function pluginHookResponseFilter(_ctx, args) {
|
||||
const parsed = JSON.parse(args.body);
|
||||
const filtered = JSONPath({ path: args.filter, json: parsed });
|
||||
return JSON.stringify(filtered, null, 2);
|
||||
}
|
||||
var plugin = {
|
||||
filter: {
|
||||
name: "JSONPath",
|
||||
description: "Filter JSONPath",
|
||||
onFilter(_ctx, args) {
|
||||
const parsed = JSON.parse(args.payload);
|
||||
const filtered = JSONPath({ path: args.filter, json: parsed });
|
||||
return { filtered: JSON.stringify(filtered, null, 2) };
|
||||
}
|
||||
}
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
pluginHookResponseFilter
|
||||
plugin
|
||||
});
|
||||
|
||||
@@ -8346,21 +8346,27 @@ var require_xpath = __commonJS({
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
pluginHookResponseFilter: () => pluginHookResponseFilter
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var import_xmldom = __toESM(require_lib());
|
||||
var import_xpath = __toESM(require_xpath());
|
||||
function pluginHookResponseFilter(_ctx, { filter, body }) {
|
||||
const doc = new import_xmldom.DOMParser().parseFromString(body, "text/xml");
|
||||
const result = import_xpath.default.select(filter, doc, false);
|
||||
if (Array.isArray(result)) {
|
||||
return result.map((r) => String(r)).join("\n");
|
||||
} else {
|
||||
return String(result);
|
||||
var plugin = {
|
||||
filter: {
|
||||
name: "XPath",
|
||||
description: "Filter XPath",
|
||||
onFilter(_ctx, args) {
|
||||
const doc = new import_xmldom.DOMParser().parseFromString(args.payload, "text/xml");
|
||||
const result = import_xpath.default.select(args.filter, doc, false);
|
||||
if (Array.isArray(result)) {
|
||||
return { filtered: result.map((r) => String(r)).join("\n") };
|
||||
} else {
|
||||
return { filtered: String(result) };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
pluginHookResponseFilter
|
||||
plugin
|
||||
});
|
||||
|
||||
@@ -260,7 +260,8 @@ var require_shell_quote = __commonJS({
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
pluginHookImport: () => pluginHookImport
|
||||
convertCurl: () => convertCurl,
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var import_shell_quote = __toESM(require_shell_quote());
|
||||
@@ -290,7 +291,16 @@ var SUPPORTED_FLAGS = [
|
||||
DATA_FLAGS
|
||||
].flatMap((v) => v);
|
||||
var BOOLEAN_FLAGS = ["G", "get", "digest"];
|
||||
function pluginHookImport(_ctx, rawData) {
|
||||
var plugin = {
|
||||
importer: {
|
||||
name: "cURL",
|
||||
description: "Import cURL commands",
|
||||
onImport(_ctx, args) {
|
||||
return convertCurl(args.text);
|
||||
}
|
||||
}
|
||||
};
|
||||
function convertCurl(rawData) {
|
||||
if (!rawData.match(/^\s*curl /)) {
|
||||
return null;
|
||||
}
|
||||
@@ -570,5 +580,6 @@ function generateId(model) {
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
pluginHookImport
|
||||
convertCurl,
|
||||
plugin
|
||||
});
|
||||
|
||||
@@ -7208,11 +7208,21 @@ var require_dist = __commonJS({
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
pluginHookImport: () => pluginHookImport
|
||||
convertInsomnia: () => convertInsomnia,
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var import_yaml = __toESM(require_dist());
|
||||
function pluginHookImport(ctx, contents) {
|
||||
var plugin = {
|
||||
importer: {
|
||||
name: "Insomnia",
|
||||
description: "Import Insomnia workspaces",
|
||||
onImport(_ctx, args) {
|
||||
return convertInsomnia(args.text);
|
||||
}
|
||||
}
|
||||
};
|
||||
function convertInsomnia(contents) {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(contents);
|
||||
@@ -7439,5 +7449,6 @@ function deleteUndefinedAttrs(obj) {
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
pluginHookImport
|
||||
convertInsomnia,
|
||||
plugin
|
||||
});
|
||||
|
||||
@@ -113483,30 +113483,30 @@ var require_json_schema_faker = __commonJS({
|
||||
});
|
||||
};
|
||||
exports5.filter = function(plugins, method, file) {
|
||||
return plugins.filter(function(plugin) {
|
||||
return !!getResult(plugin, method, file);
|
||||
return plugins.filter(function(plugin2) {
|
||||
return !!getResult(plugin2, method, file);
|
||||
});
|
||||
};
|
||||
exports5.sort = function(plugins) {
|
||||
plugins.forEach(function(plugin) {
|
||||
plugin.order = plugin.order || Number.MAX_SAFE_INTEGER;
|
||||
plugins.forEach(function(plugin2) {
|
||||
plugin2.order = plugin2.order || Number.MAX_SAFE_INTEGER;
|
||||
});
|
||||
return plugins.sort(function(a, b) {
|
||||
return a.order - b.order;
|
||||
});
|
||||
};
|
||||
exports5.run = function(plugins, method, file) {
|
||||
var plugin, lastError, index = 0;
|
||||
var plugin2, lastError, index = 0;
|
||||
return new Promise(function(resolve2, reject) {
|
||||
runNextPlugin();
|
||||
function runNextPlugin() {
|
||||
plugin = plugins[index++];
|
||||
if (!plugin) {
|
||||
plugin2 = plugins[index++];
|
||||
if (!plugin2) {
|
||||
return reject(lastError);
|
||||
}
|
||||
try {
|
||||
debug(" %s", plugin.name);
|
||||
var result = getResult(plugin, method, file, callback);
|
||||
debug(" %s", plugin2.name);
|
||||
var result = getResult(plugin2, method, file, callback);
|
||||
if (result && typeof result.then === "function") {
|
||||
result.then(onSuccess, onError);
|
||||
} else if (result !== void 0) {
|
||||
@@ -113526,7 +113526,7 @@ var require_json_schema_faker = __commonJS({
|
||||
function onSuccess(result) {
|
||||
debug(" success");
|
||||
resolve2({
|
||||
plugin,
|
||||
plugin: plugin2,
|
||||
result
|
||||
});
|
||||
}
|
||||
@@ -145850,7 +145850,8 @@ var require_openapi_to_postmanv2 = __commonJS({
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
pluginHookImport: () => pluginHookImport2
|
||||
convertOpenApi: () => convertOpenApi,
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var import_openapi_to_postmanv2 = __toESM(require_openapi_to_postmanv2());
|
||||
@@ -145859,7 +145860,7 @@ var import_openapi_to_postmanv2 = __toESM(require_openapi_to_postmanv2());
|
||||
var POSTMAN_2_1_0_SCHEMA = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json";
|
||||
var POSTMAN_2_0_0_SCHEMA = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json";
|
||||
var VALID_SCHEMAS = [POSTMAN_2_0_0_SCHEMA, POSTMAN_2_1_0_SCHEMA];
|
||||
function pluginHookImport(_ctx, contents) {
|
||||
function convertPostman(contents) {
|
||||
const root = parseJSONToRecord(contents);
|
||||
if (root == null) return;
|
||||
const info = toRecord(root.info);
|
||||
@@ -146150,7 +146151,16 @@ function generateId(model) {
|
||||
}
|
||||
|
||||
// src/index.ts
|
||||
async function pluginHookImport2(ctx, contents) {
|
||||
var plugin = {
|
||||
importer: {
|
||||
name: "OpenAPI",
|
||||
description: "Import OpenAPI collections",
|
||||
onImport(_ctx, args) {
|
||||
return convertOpenApi(args.text);
|
||||
}
|
||||
}
|
||||
};
|
||||
async function convertOpenApi(contents) {
|
||||
let postmanCollection;
|
||||
try {
|
||||
postmanCollection = await new Promise((resolve, reject) => {
|
||||
@@ -146164,11 +146174,12 @@ async function pluginHookImport2(ctx, contents) {
|
||||
} catch (err) {
|
||||
return void 0;
|
||||
}
|
||||
return pluginHookImport(ctx, JSON.stringify(postmanCollection));
|
||||
return convertPostman(JSON.stringify(postmanCollection));
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
pluginHookImport
|
||||
convertOpenApi,
|
||||
plugin
|
||||
});
|
||||
/*! Bundled license information:
|
||||
|
||||
|
||||
@@ -20,13 +20,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
pluginHookImport: () => pluginHookImport
|
||||
convertPostman: () => convertPostman,
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var POSTMAN_2_1_0_SCHEMA = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json";
|
||||
var POSTMAN_2_0_0_SCHEMA = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json";
|
||||
var VALID_SCHEMAS = [POSTMAN_2_0_0_SCHEMA, POSTMAN_2_1_0_SCHEMA];
|
||||
function pluginHookImport(_ctx, contents) {
|
||||
var plugin = {
|
||||
importer: {
|
||||
name: "Postman",
|
||||
description: "Import postman collections",
|
||||
onImport(_ctx, args) {
|
||||
return convertPostman(args.text);
|
||||
}
|
||||
}
|
||||
};
|
||||
function convertPostman(contents) {
|
||||
const root = parseJSONToRecord(contents);
|
||||
if (root == null) return;
|
||||
const info = toRecord(root.info);
|
||||
@@ -317,5 +327,6 @@ function generateId(model) {
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
pluginHookImport
|
||||
convertPostman,
|
||||
plugin
|
||||
});
|
||||
|
||||
@@ -20,10 +20,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
pluginHookImport: () => pluginHookImport
|
||||
migrateImport: () => migrateImport,
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
function pluginHookImport(_ctx, contents) {
|
||||
var plugin = {
|
||||
importer: {
|
||||
name: "Yaak",
|
||||
description: "Yaak official format",
|
||||
onImport(_ctx, args) {
|
||||
return migrateImport(args.text);
|
||||
}
|
||||
}
|
||||
};
|
||||
function migrateImport(contents) {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(contents);
|
||||
@@ -66,5 +76,6 @@ function isJSObject(obj) {
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
pluginHookImport
|
||||
migrateImport,
|
||||
plugin
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user