Skip to content

Remove heavyweight third-party imports: mime-types, tough-cookie, @grpc/grpc-js, node-forge#9992

Open
jackkav wants to merge 4 commits into
developfrom
pr/safe-utilities-cleanup
Open

Remove heavyweight third-party imports: mime-types, tough-cookie, @grpc/grpc-js, node-forge#9992
jackkav wants to merge 4 commits into
developfrom
pr/safe-utilities-cleanup

Conversation

@jackkav
Copy link
Copy Markdown
Contributor

@jackkav jackkav commented May 30, 2026

Summary

Removes several third-party package imports from the renderer by replacing them with lightweight alternatives or inline implementations. No behavioral changes — pure substitutions.

  • vault-crypto.ts — new AES-GCM encrypt/decrypt utility (with tests) to replace node-forge usage in vault flows; uses the Web Crypto API directly
  • common/mime.ts — replaces the `mime-types` npm package with a small inline lookup table; removes the package boundary for a simple extension↔MIME mapping
  • response-cookies-viewer — removes `tough-cookie` import; replaces with a 10-line inline `Set-Cookie` header parser (only `name=value` extraction was needed)
  • grpc-status-tag — removes `@grpc/grpc-js` import just to read `status.OK = 0`; replaced with an inline constant
  • auth.clear-vault-key — replaces `electron.ipcRenderer.emit('show-toast')` with the typed `showToast()` helper
  • window-utils — removes an unused `trackAnalyticsEvent` call from the app menu handler
  • window.env / contextBridge — env vars are not available in the renderer by default when `nodeIntegration` is disabled. The preload now explicitly whitelists the env vars the renderer needs and exposes them as `window.env` via `contextBridge`. `constants.ts` reads from `window.env` in the renderer and falls back to `process.env` for the inso CLI and main process.

Test plan

  • Vault encrypt/decrypt round-trips (unit tests in `vault-crypto.test.ts`)
  • MIME lookup still resolves extensions correctly in body editor and response pane download
  • Cookie viewer still displays cookies from response headers
  • gRPC status tag still shows green/red for OK/non-OK status codes
  • Vault key reset flow still shows the toast notification
  • All env-driven features still work: GitLab OAuth, E2E fixtures, service URL overrides, Windows portable detection

…ports

- Add AES-GCM vault-crypto utility with tests (replaces node-forge usage)
- Add common/mime.ts to replace mime-types package dependency
- Replace tough-cookie import in response-cookies-viewer with inline parser
- Replace @grpc/grpc-js status import in grpc-status-tag with inline constant
- Replace electron.ipcRenderer in auth.clear-vault-key with showToast()
- Remove unused analytics call from window-utils
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 30, 2026

✅ Circular References Report

Generated at: 2026-05-30T19:42:49.816Z
Status: ✅ NO CHANGE

Summary

Metric Base (develop) PR Change
Total Circular References 12 12 0 (0.00%)
Click to view all circular references in PR (12)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/insomnia.ts -> insomnia-scripting-environment/src/objects/interfaces.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts -> insomnia/src/templating/index.ts -> insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/store.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/misc.ts
insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx
Click to view all circular references in base branch (12)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/insomnia.ts -> insomnia-scripting-environment/src/objects/interfaces.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts -> insomnia/src/templating/index.ts -> insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/store.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/misc.ts
insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx

Analysis

No Change: This PR does not introduce or remove any circular references.


This report was generated automatically by comparing against the develop branch.

@jackkav jackkav requested review from a team, ZxBing0066 and kwburns-kong May 30, 2026 04:01
In the renderer process with nodeIntegration disabled, process.env is not
available. The preload script now explicitly whitelists the env vars the
renderer needs and exposes them as window.env via contextBridge.
constants.ts reads from window.env in the renderer and falls back to
process.env for the inso CLI and main process.
jackkav added a commit that referenced this pull request May 30, 2026
jackkav added 2 commits May 30, 2026 21:11
- key-value-editor and templating/utils now import encryptSecretValue/
  decryptSecretValue from vault-crypto instead of vault, so the new
  implementation is actually exercised
- Replace window.crypto with globalThis.crypto so vault-crypto works in
  Web Workers (self.crypto) and Node.js/inso (globalThis.crypto)
Removes the dynamic import of httpsnippet from the renderer so it is
no longer bundled there. Prepares for nodeIntegration: false, as
httpsnippet's core requires Node built-ins (querystring, url) that
won't be available in the renderer without nodeIntegration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants