Guide build-plugin on pre-request auth scripts#93
Conversation
WebAPI base plugin 1.8.0 (squaredup-plugin-repository PR #1966, SAAS-8337) adds datasource-level pre-request scripting so plugins can handle custom auth flows no authMode expresses — token-exchange steps and per-request HMAC signing. The matching saas change lets a declarative plugin's base.config reference the script as a file under dataStreams/scripts/preRequest/, inlined at deploy time. The build-plugin skill had no coverage of this, so an agent building a plugin for such an API had no supported path. Add a reference section beside the auth patterns in metadata.md covering when to reach for a script (and to prefer built-in authModes first), the wiring including scriptingVariables and the reserved scriptState property, the script's variable scope, and a token-exchange example with state-cached expiry drawn from the PR's real N-Able script. Phase 1's auth step and the post-request-scripts section point at it, keeping the full material in one place per the skill-writing guidance. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe build-plugin documentation now describes custom authentication pre-request scripts, their configuration and runtime behavior, execution timing, token caching example, and optional scaffolding. The skill version and authentication planning guidance were updated accordingly. ChangesCustom authentication documentation
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
🧩 Plugin PR Summaryℹ️ No plugins were modified in this PR. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/skills/build-plugin/references/metadata.md:
- Around line 245-251: Add timeout or cancellation handling to the auth fetch in
the pre-request hook, using an AbortSignal or the platform’s documented fetch
timeout mechanism. Ensure hung auth requests terminate within a defined limit so
plugin streams and imports cannot stall indefinitely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1f6180fa-4098-414a-b307-ea301e879c1c
📒 Files selected for processing (3)
.claude/skills/build-plugin/SKILL.md.claude/skills/build-plugin/references/data-streams.md.claude/skills/build-plugin/references/metadata.md
| const resp = await fetch(authUrl, { | ||
| method: "post", | ||
| headers: { | ||
| Accept: "application/json", | ||
| Authorization: `Bearer ${secrets.signedJwt}`, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map the target file and inspect relevant surrounding lines.
wc -l .claude/skills/build-plugin/references/metadata.md
sed -n '220,280p' .claude/skills/build-plugin/references/metadata.md
# Search for related mentions of auth fetch, timeout, cancellation, and WebAPI 1.8.0.
rg -n "authUrl|signedJwt|fetch\\(|timeout|cancell|WebAPI 1\\.8\\.0|plugin request|before every plugin request" .claude/skills/build-plugin -SRepository: squaredup/plugins
Length of output: 6217
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect any adjacent docs that define the auth flow or runtime constraints.
fd -a "metadata.md" .claude/skills/build-plugin
fd -a "README.md" .claude/skills/build-plugin
fd -a "*.md" .claude/skills/build-plugin | sed -n '1,120p'Repository: squaredup/plugins
Length of output: 509
Bound the auth fetch. This pre-request hook runs before every plugin request, so a hung auth endpoint can stall streams and imports. Add a timeout/cancellation path, or document the platform timeout for fetch in WebAPI 1.8.0.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.claude/skills/build-plugin/references/metadata.md around lines 245 - 251,
Add timeout or cancellation handling to the auth fetch in the pre-request hook,
using an AbortSignal or the platform’s documented fetch timeout mechanism.
Ensure hung auth requests terminate within a defined limit so plugin streams and
imports cannot stall indefinitely.
📋 Summary
Adds guidance to the
build-pluginskill for the newpreRequestScriptcapability arriving with WebAPI base plugin 1.8.0 (squaredup/squaredup-plugin-repository#1966, SAAS-8337) and its saas-side deploy support, so an agent building a plugin for an API with a custom auth flow (token exchange, per-request HMAC signing) has a supported path.references/metadata.md, co-located with the auth patterns: when to reach for a script (prefer built-inauthModes first), wiring viascriptingVariablesand thedataStreams/scripts/preRequest/<plugin>.jsfile reference, the reservedscriptStateproperty, the script's variable scope, and a token-exchange example withstate-cached expiry drawn from the real N-Able script in the upstream PR.SKILL.md, the scaffold file tree, and the post-request-scripts section ofreferences/data-streams.md.Note: end-to-end this depends on both upstream PRs shipping — WebAPI 1.8.0 and the saas file-reference inlining.
🔍 Scope of change
📚 Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit