Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7358b67
Add vault-crypto/mime utilities and remove heavyweight third-party im…
jackkav May 30, 2026
ff8cdd1
Fix impure Date.now() key on CodeEditor; use setValue via ref instead
jackkav May 31, 2026
3d7345f
fix: address Copilot review comments on PR #9992
jackkav Jun 1, 2026
8bd134e
fix: sort imports in send route
jackkav Jun 1, 2026
9d52cda
feat: disable nodeIntegration in renderer mainWindow, remove import c…
jackkav Jun 1, 2026
906cce7
fix: sort imports, use static TestResults type, remove unused analyti…
jackkav Jun 1, 2026
87ed759
remove mime stuff
jackkav Jun 1, 2026
1c602ee
remove ci step
jackkav Jun 1, 2026
929ec2a
update plan
jackkav Jun 1, 2026
51b9ba9
insomnia testing adapter
jackkav Jun 1, 2026
7938df8
use export method
jackkav Jun 1, 2026
799b310
trick react router ssr
jackkav Jun 1, 2026
26659eb
add renderer errors
jackkav Jun 1, 2026
7d243fd
globalThis
jackkav Jun 1, 2026
907aaa5
improve error
jackkav Jun 1, 2026
1e4251a
move plugin types
jackkav Jun 1, 2026
198517d
ipc validate proto
jackkav Jun 1, 2026
2c59904
fix import
jackkav Jun 1, 2026
9f7c7b5
plugin types
jackkav Jun 1, 2026
8b30634
polyfill events for jshint
jackkav Jun 1, 2026
e6f1c57
restore node require plugin
jackkav Jun 1, 2026
4ec3b4e
vault adapter
jackkav Jun 1, 2026
ed4dea8
add crypto bridges
jackkav Jun 1, 2026
71e9030
tough-cookie ipc
jackkav Jun 1, 2026
bcbf1fc
util stub
jackkav Jun 1, 2026
ed77673
split cookie into network adapter
jackkav Jun 1, 2026
799e2bc
assert
jackkav Jun 1, 2026
3fb1174
fix plugin index import
jackkav Jun 2, 2026
3b2ef88
serialise cookie
jackkav Jun 2, 2026
58ef319
decouple renderer from scripting
jackkav Jun 2, 2026
475c8b6
Fix rebase conflicts and import path issues
jackkav Jun 2, 2026
bf2299c
lint
jackkav Jun 2, 2026
e1f38ce
fix tests
jackkav Jun 2, 2026
f4e0f0c
fix: use dynamic import for crypt in session.ts for main process comp…
jackkav Jun 2, 2026
bf30241
fix: add aria-label to template tag preview and browser-safe encoding…
jackkav Jun 2, 2026
9d432b9
fix: add explicit waits for element stability in environment test
jackkav Jun 3, 2026
e435015
remove unused
jackkav Jun 3, 2026
024e012
add autocomplete generate test step
jackkav Jun 3, 2026
3d8c9cc
fix lint
jackkav Jun 3, 2026
373a320
put analytics back in
jackkav Jun 3, 2026
af95e62
combine vault and crypto adapter
jackkav Jun 3, 2026
9750add
remove unused export split
jackkav Jun 3, 2026
d5fbc46
remove insomnia-testing cruft, addressing feedback
jackkav Jun 3, 2026
9d447de
fix: use direct imports in insomnia-inso after insomnia-testing index…
jackkav Jun 3, 2026
7ecae8e
fix circular reference
jackkav Jun 3, 2026
4f7cd72
fix: move createElectronNotifier to main process to fix SSR error
jackkav Jun 3, 2026
6b3adaf
export har ipc bridge
jackkav Jun 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,20 @@ jobs:
- name: Lint
run: npm run lint

- name: Check renderer Node import baseline
run: npm run check:renderer-node-imports

- name: Type checks
run: npm run type-check

- name: Unit Tests
run: npm test

- name: Check autocomplete snippets are up to date
run: |
npm run generate:autocomplete -w insomnia-scripting-environment
if ! git diff --exit-code packages/insomnia-scripting-environment/src/autocomplete-snippets.json; then
echo "::error::autocomplete-snippets.json is out of date. Run 'npm run generate:autocomplete -w insomnia-scripting-environment' and commit the result."
exit 1
fi

- name: Checkout base branch (cycle comparison)
if: github.event_name == 'pull_request' && always()
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand Down
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"scripts": {
"dev": "npm start -w insomnia",
"dev:autoRestart": "npm run start:autoRestart -w insomnia",
"check:renderer-node-imports": "npm run check:renderer-node-imports -w insomnia",
"lint": "npm run lint --workspaces --if-present",
Comment thread
jackkav marked this conversation as resolved.
"type-check": "npm run type-check --workspaces --if-present",
"test": "npm run test --workspaces --if-present",
Expand Down
14 changes: 13 additions & 1 deletion packages/insomnia-inso/esbuild.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import fs from 'node:fs';
import path from 'node:path';

import { analyzeMetafile, build, type BuildOptions, context } from 'esbuild';
import { analyzeMetafile, build, type BuildOptions, context, type Plugin } from 'esbuild';

const isProd = Boolean(process.env.NODE_ENV === 'production');
const watch = Boolean(process.env.ESBUILD_WATCH);
const isDebug = Boolean(process.env.DEBUG);
const version = process.env.VERSION || 'dev';
// Redirects *.renderer imports to their *.node equivalents for node/CLI builds.
const rendererToNodePlugin: Plugin = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit hacky. Should this be handled by the bundler by process.type in the adapter? Why do we need this plugin?

Copy link
Copy Markdown
Contributor Author

@jackkav jackkav Jun 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because that approach is equally hacky, and doesn't help vite determine what not to bundle, because vite only sets type to renderer in prod not dev, theres an explanation in the comment. a better approach might be window !== undefined, you are welcome to experiment with this branch to your satisfaction.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no preference for the solution. But it should be consistent and won't introduce misunderstandings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked into it, inso is hacky, hacks on hacks isn't new.

name: 'renderer-to-node',
setup(build) {
build.onResolve({ filter: /\.renderer$/ }, args => ({
path: path.resolve(args.resolveDir, args.path.replace('.renderer', '.node') + '.ts'),
}));
},
};

const config: BuildOptions = {
outfile: './dist/index.js',
bundle: true,
Expand All @@ -20,6 +31,7 @@ const config: BuildOptions = {
electron: '../insomnia/send-request/electron',
},
plugins: [
rendererToNodePlugin,
// taken from https://github.com/tjx666/awesome-vscode-extension-boilerplate/blob/main/scripts/esbuild.ts
{
name: 'umd2esm',
Expand Down
3 changes: 2 additions & 1 deletion packages/insomnia-inso/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import type {
import { initServices, models } from 'insomnia-data';
import { deserializeNDJSON } from 'insomnia-data/common';
import { servicesNodeImpl } from 'insomnia-data/node';
import { generate, runTestsCli } from 'insomnia-testing';
import { generate } from 'insomnia-testing/src/generate/generate';
import { runTestsCli } from 'insomnia-testing/src/run/run';
import orderedJSON from 'json-order';
import { parseArgsStringToArgv } from 'string-argv';
import { v4 as uuidv4 } from 'uuid';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { vi } from 'vitest';

export const generate = vi.fn();
export const generateToFile = vi.fn();
export const runTests = vi.fn();
export const runTestsCli = vi.fn();
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
esbuild: {
external: ['@getinsomnia/node-libcurl', 'electron'],
},
};
3 changes: 2 additions & 1 deletion packages/insomnia-scripting-environment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"scripts": {
"lint": "eslint . --ext .js,.ts,.tsx --cache",
"test": "vitest run",
"type-check": "tsc --project tsconfig.json"
"type-check": "tsc --project tsconfig.json",
"generate:autocomplete": "esr scripts/generate-autocomplete.ts"
},
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Regenerate src/autocomplete-snippets.json from the live scripting API.
// Run from the package root: npm run generate:autocomplete
//
// This script instantiates the scripting classes in Node.js (where tough-cookie is fine)
// and walks the object graph to derive autocomplete snippets. The output is committed as a
// static JSON file so the renderer never has to import the scripting classes.
//
// Re-run this script whenever the public scripting API surface changes.

import { writeFileSync } from 'node:fs';
import path from 'node:path';

// Import directly from source files to avoid pulling in send-request.ts (which
// transitively imports the Electron-only libcurl native addon via the main package).
const { CookieObject } = require('../src/objects/cookies.ts');
const { Environment, Variables, Vault } = require('../src/objects/environments.ts');
const { Execution } = require('../src/objects/execution.ts');
const { InsomniaObject } = require('../src/objects/insomnia.ts');
const { Request: ScriptRequest } = require('../src/objects/request.ts');
const { RequestInfo } = require('../src/objects/request-info.ts');
const { Response: ScriptResponse } = require('../src/objects/response.ts');
const { Url } = require('../src/objects/urls.ts');
const { ParentFolders } = require('../src/objects/folders.ts');

interface Snippet {
displayValue: string;
name: string;
value: string;
}

function walk(obj: object, path: string): Snippet[] {
let snippets: Snippet[] = [];
const refs = new Set<unknown>();
const record = obj as Record<string, unknown>;

for (const key in obj) {
if (key.startsWith('_')) {
continue;
}

const value = record[key];

if (typeof value === 'object' && value !== null) {
if (refs.has(value)) {
continue;
}
refs.add(value);
}

if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
snippets.push({ displayValue: `${path}.${value}`, name: `${path}.${key}`, value: `${path}.${key}` });
} else if (typeof value === 'function') {
snippets.push({ displayValue: `${path}.${key}()`, name: `${path}.${key}()`, value: `${path}.${key}()` });
} else if (Array.isArray(value)) {
for (const item of value) {
snippets = snippets.concat(walk(item, `${path}.${key}`));
}
} else if (value !== null && typeof value === 'object') {
snippets = snippets.concat(walk(value as object, `${path}.${key}`));
}
}

return snippets;
}

const settings: any = { enableVaultInScripts: true };
const req = new ScriptRequest({ url: new Url('http://placeholder.com') });

const insomnia = new InsomniaObject({
globals: new Environment('globals', {}),
baseGlobals: new Environment('baseGlobals', {}),
iterationData: new Environment('iterationData', {}),
environment: new Environment('environment', {}),
baseEnvironment: new Environment('baseEnvironment', {}),
variables: new Variables({
baseGlobalVars: new Environment('baseGlobals', {}),
globalVars: new Environment('globals', {}),
environmentVars: new Environment('environment', {}),
collectionVars: new Environment('collection', {}),
iterationDataVars: new Environment('data', {}),
folderLevelVars: [],
localVars: new Environment('data', {}),
}),
vault: new Vault('vault', {}, true),
request: req,
response: new ScriptResponse({
code: 200,
reason: 'OK',
header: [
{ key: 'header1', value: 'val1' },
{ key: 'header2', value: 'val2' },
],
cookie: [
{ key: 'header1', value: 'val1' },
{ key: 'header2', value: 'val2' },
],
body: '{"key": 888}',
stream: undefined,
responseTime: 100,
originalRequest: req,
}),
settings,
clientCertificates: [],
cookies: new CookieObject({
_id: '',
type: 'CookieJar',
parentId: '',
modified: 0,
created: 0,
isPrivate: false,
name: '',
cookies: [],
}),
requestInfo: new RequestInfo({
eventName: 'prerequest',
iteration: 1,
iterationCount: 1,
requestName: '',
requestId: '',
}),
execution: new Execution({ location: ['path'] }),
parentFolders: new ParentFolders([]),
});

const snippets = walk(insomnia, 'insomnia');

const outputPath = path.join(__dirname, '../src/autocomplete-snippets.json');
writeFileSync(outputPath, JSON.stringify(snippets, null, 2) + '\n');
console.log(`Wrote ${snippets.length} snippets to src/autocomplete-snippets.json`);
Loading
Loading