netmind_oauth.rs

netmind_oauth.rs is a command for Claude Code from NetMindAI-Open/NarraNexus. It costs 0 tokens per session (888 once invoked), scanned A, original, Apache-2.0.

Rust code that connects NetMind's browser-based sign-in flow to a desktop webview. A webview is an embedded browser inside a desktop app; this bridge captures the sign-in result and passes it back to the app.

In plain words
What is it for?
Use it to start NetMind OAuth login in the desktop app, detect the authorization callback, securely pass its code and state to the frontend, and support a fallback callback path.
Why use it?
Browser popups and window-to-window messaging that work on websites may fail inside desktop webviews, leaving users stuck on the login screen.

Command for Claude Code

Written for Claude Code: a Claude Code command (commands/*.md).

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/netmindai-open/narranexus/netmind_oauth.rs
Clone the repo
git clone --depth 1 https://github.com/NetMindAI-Open/NarraNexus

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for netmind_oauth.rs

README.md
[![agentmods](https://agentmods.dev/badge/commands/netmindai-open/narranexus/netmind_oauth.rs.svg)](https://agentmods.dev/commands/netmindai-open/narranexus/netmind_oauth.rs)
Your own site
<a href="https://agentmods.dev/commands/netmindai-open/narranexus/netmind_oauth.rs"><img src="https://agentmods.dev/badge/commands/netmindai-open/narranexus/netmind_oauth.rs.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 888 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00888
Opus 5 $0.00000 $0.00444
Sonnet 5 $0.00000 $0.00178
Haiku 4.5 $0.00000 $0.00089

Measured 6d ago against content hash f96c2cfea47d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

netmind_oauth.rs scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.mindflow/mirror/tauri/src-tauri/src/commands/netmind_oauth.rs.md · 54 lines

What it actually says

netmind_oauth.rs — 桌面端 NetMind(Power)OAuth 桥接

Why it exists

Web 版 OAuth([[useNetmindAuth.ts]] startOAuth)靠浏览器弹窗打开 NetMind auth.html + window.opener.postMessage 回传结果。这套在打包桌面 webview (WKWebView)里不工作:弹窗被拦、无跨窗 opener 通道。本地桌面在 Power 登录落地前 从没跑过 NetMind OAuth,是新面。

捕获(两条独立路径,双保险)

Rust 建子 webview 加载 auth.html,on_navigation 里两路抓结果:

  1. URL 匹配(主,零依赖 opener):provider 认证完会把 webview 重定向回 NetMind redirect_uri,带 ?code=&state=。只有最终回调同时带这两个参(provider 授权 URL 只有 state 无 code),故要求二者都在才命中,取出后合成 {type:'auth',code,state} JSON。return false 取消该页加载——服务端换取由 前端 handleAuthCallback/user/userCallBack 完成,和 web 版等价。
  2. opener shim + 哨兵(兜底):初始化脚本合成 window.opener,其 postMessage 跳到哨兵 URL https://nmoauth.callback/#<encodeURIComponent(JSON)>,on_navigation 命中后取 fragment。

投递(不依赖事件监听)

命中后 deliver() 把 payload 存进 [[state.rs]] 的 pending_netmind_oauth 槽, 前端启动 OAuth 后轮询 take_netmind_oauth_result(invoke)取走——这条投递不 依赖 window.__TAURI__ 的实时事件(该全局在本项目未开 withGlobalTauri,listen 可能静默失效,正是首个 DMG 测试里"子窗关了但主窗还在登录页"的根因)。同时也 emit("netmind-oauth-callback") 一份作冗余,当前前端不监听。

关键决策 / 踩坑

  • payload 双格式统一:URL-match 存纯 JSON,哨兵存 URI-encoded JSON;前端 decodeURIComponent(对纯 JSON 是 no-op)+JSON.parse 两者通吃。
  • 无 capability 改动:子 webview 只导航,不 invoke、不 emit;缓存/emit 是 Rust 特权。默认 capability 仅覆盖 "main"。
  • 窗口/缓存复用:每次开窗前先关旧窗、清空旧缓存,连点不叠、不串。
  • 首个 DMG 实测结论:机制(建窗、跳转、关窗)通;Google 内嵌 webview 里 passkey/WebAuthn 用不了(需真浏览器),用"其他方式→密码"可绕过 → 由 URL 匹配路径接住 code/state。若将来要支持 passkey,只能走系统浏览器 + deep-link (需 NetMind 侧支持重定向到 narranexus://)。

未验证(编译需在有 Rust 的打包机)

on_navigation/initialization_script/WebviewUrl 写法在 tauri 2.11 已随首个 DMG 编译通过。运行时的 URL-match 能否在 provider 回调那一跳命中(取决于 NetMind redirect_uri 把 code/state 放 query 还是 fragment),需实测;放 fragment 的话把 query_pairs() 换成解析 fragment 即可。

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 54 lines · 0 tokens per session scan A f96c2cfea47d

Subscribe to this mod's changes

netmind_oauth.rs is a command published in the GitHub repository NetMindAI-Open/NarraNexus (86 stars, last pushed 3d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 888 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other commands, from other repositories

init

Initialize configurations for Supabase local development.

fcakyon/claude-codex-settings · 0 tokens

http-service

Build, review or debug a Bun HTTP service. Loads the http-service skill, then works the task through its workflow.

MadAppGang/magus · 27 tokens

start-10-1

Command "start-10-1" from minicoohei/ai-agent-camp, covering 🎓 lesson 10-1: clasp基本・gasプロジェクト管理, 📍 このセッションでやること, 🎯 準備チェック, 🚀 step 1: claspのインストールと apps script api の確認 and 🚀 step 2: google認証.

minicoohei/ai-agent-camp · 2 tokens

api-contract-review

Review an API contract (endpoints, request/response shapes, error codes, auth model) BEFORE implementation for naming consistency, versioning, pagination, idempotency, and alignment with existing endpoints. Distinct from review-hard (post-implementation risk) and repo-consistency-sweep (pattern matching on written…

Mozurok/fhorja.dev · 100 tokens

build

Discover an AI Gateway's models and MCP tools, retrieve a credential, and integrate them into your app — call a model, connect MCP tools, or scaffold a runnable agent.

Azure/ai-gateway · 35 tokens

fastapi

FastAPI application design and implementation conventions. Use this skill when building, updating, or reviewing FastAPI services, routers, dependencies, request/response schemas, streaming endpoints, or API tests. Trigger on FastAPI-specific work such as path operation design, dependency injection, response models…

mfmezger/ai_agent_dotfiles · 84 tokens