solid-auth-core
Use when maintaining legacy @jeswr/solid-auth-core integrations. Deprecated; use @jeswr/pod-auth and its package skill for new suite authentication.
- License 许可
- MIT
- 所属仓库
- jeswr/solid-sdk
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- solid-auth-core
- description
- Use when maintaining legacy @jeswr/solid-auth-core integrations. Deprecated; use @jeswr/pod-auth and its package skill for new suite authentication.
02 资源文件 32
- 参考文档etc/proactive-fetch.api.md1.3 KB
- 许可证LICENSE1.0 KB
- 参考文档package.json2.3 KB
- 参考文档README.md8.6 KB
- 脚本scripts/assert-declarations.d.mts91 B
- 脚本scripts/assert-declarations.mjs926 B
- 脚本scripts/build-dist.mjs4.0 KB
- 脚本src/controller.ts176.0 KB
- 脚本src/credentialed-redirects.ts6.1 KB
- 脚本src/index.ts2.9 KB
- 脚本src/pristine.ts4.9 KB
- 脚本src/proactive-fetch.ts34.7 KB
- 其他src/react/index.tsx8.3 KB
- 脚本src/redirect.ts16.9 KB
- 脚本src/request.ts2.2 KB
- 脚本src/session-store.ts2.8 KB
- 脚本src/types.ts20.1 KB
- 脚本test/assert-declarations.test.ts2.3 KB
- 脚本test/controller.test.ts239.5 KB
- 脚本test/fetch-redirects.test.ts56.3 KB
- 脚本test/login-stall.test.ts14.8 KB
- 脚本test/origin-boundary.test.ts6.7 KB
- 脚本test/pristine.test.ts2.4 KB
- 脚本test/proactive-fetch.test.ts41.4 KB
- 脚本test/profile-fetch.test.ts5.3 KB
- 其他test/react.test.tsx8.6 KB
- 脚本test/redirect.test.ts40.1 KB
- 脚本test/request-fixtures.ts2.5 KB
- 脚本test/token-provider.test.ts16.5 KB
- 参考文档tsconfig.build.json210 B
- 参考文档tsconfig.json582 B
- 脚本vitest.config.ts442 B
03 SKILL.md 正文
<!-- AUTHORED-BY Codex GPT-5 --> <!-- AUTHORED-BY Codex GPT-6.1-Sol --> <!-- AUTHORED-BY Codex GPT-6 -->
Work with @jeswr/solid-auth-core
<!-- AUTHORED-BY Codex GPT-6.1-Sol -->
Deprecated — use
@jeswr/pod-auth. Read the pod-auth skill for migration, the current API and security policy. The guidance below maintains existing consumers; it does not describe pod-auth or authorize deleting legacy exports.
Use createSolidAuth() instead of copying token-provider, login UX, restore, or React session code into an app.
import { createSolidAuth } from "@jeswr/solid-auth-core";
const auth = createSolidAuth({
callbackUri,
clientId,
authFlow: { getCode },
patchGlobalFetch: true,
});
await auth.restore();
await auth.login(webId);
await auth.authenticatedFetch(resourceUrl);
await auth.publicFetch(foreignUrl);
React consumers use SessionProvider and useSolidSession() from @jeswr/solid-auth-core/react.
Preserve the credential boundary
- Keep pristine fetch capture first and pin every OIDC discovery, registration, token, and refresh request to it. Never route auth bootstrap traffic through a token-attaching global wrapper.
- Use
authenticatedFetchonly for allowed Solid resource origins andpublicFetchfor foreign/public origins. - Keep the allowed-origin set fail-closed: HTTPS resource origins only, with explicit loopback HTTP opt-in for development. Do not add the issuer merely because it issued the token.
- Send every SDK-credentialed request with
redirect: "manual", overriding caller policy. The controller and proactive fetch wrapper check each visible redirect with the same live credential gate and mint a fresh URL/method/token-bound DPoP proof per hop; never use native redirect following for credentials. - Use the shared Request-derivation helper for initial copies, buffering, manual passthrough/fallback, credential attachment, and followed hops. Preserve all caller-controlled Request settings (including referrer, referrerPolicy, mode, credentials, cache, integrity, keepalive, signal, and priority where supported) except the designed URL, redirect, credential-header, and method/body/content-header changes. Map inherited
mode: "navigate"to"same-origin"when deriving with a non-empty init, per Fetch's constructor rule. - Never attach or refresh SDK tokens for
mode: "no-cors"requests, including directupgrade()calls. Decide whether to force manual redirects from credential headers that survive Request construction, reading the constructed Request's headers. If browser header filtering removes all credentials, keep the caller's redirect policy. - Force manual mode on every passthrough or fallback carrying caller-owned
Authorization,DPoP, orProxy-Authorization, from either init headers or a Request. Return every such redirect unfollowed, even on the same origin; the SDK cannot re-mint caller proofs. Credential-free passthrough and fallbacks keep the caller's originalfollow,error, ormanualpolicy, including superseded upgrades and retries. Keep that policy on source requests and clones; derive manual requests only when attaching credentials. Let the transport handle credential-free redirects under the caller's policy. - On SDK-authenticated hops that change origin, strip
Cookie,Cookie2,Proxy-Authorization,Authorization, and callerDPoPbefore re-adding fresh SDK credentials. Same-origin hops preserve them before the SDK replaces its authorization and proof. - Return foreign redirects and browser
opaqueredirectresponses unchanged. Browsers hide Location in manual mode, so credentialed redirects surface to their callers. Directupgrade()users also receive manual Requests when credentials attach and must handle redirects themselves. - Follow at most 20 hops. Apply Fetch's POST-to-GET 301/302 and non-GET/HEAD-to-GET 303 rewrites, dropping body/content headers including Content-Length. Buffer only non-stream
init.bodyvalues before sending; check the abort signal before buffering, race reads against abort, cancel the reader on abort, and reject with the signal's reason (AbortError by default) without waiting for source cancellation. Treat Request bodies as streams and return redirects that require replaying a stream unfollowed. - Cache resource-server nonces only under the checked hop's origin; a nonce retry must sign that hop's URL. Refuse a response nonce when its reported URL belongs to a different origin.
deriveProactiveAllowedOriginsexcludes the issuer origin by default; onlyincludeIssuerOrigin: trueopts in. A pod hosted on the issuer origin remains allowed throughpodRoot. UseincludeWebIdOrigin: falseif the WebID document is not served by the pod. The separatecomputeAllowedOriginsdefault still includes the issuer.- When storage origins become known after restore, call
reArmAllowedOrigins(origins, { expectedWebId })with the identity captured before the asynchronous profile read. A missing session, WebID mismatch, or any inadmissible origin returnsfalsewithout changing the boundary; success admits the entire list. OmittingexpectedWebIdtargets the session live at call time. HTTPS is required, except HTTP loopback under the explicit development opt-in. - Keep generation fences and per-session ownership checks around login, restore, refresh, logout, and persistence. Re-check after every awaited boundary before mutating live state.
- In request upgrades, re-check live session object identity and the allowed origin after both refresh and DPoP proof signing, before attaching credentials. Snapshot the access token and DPoP key once before signing and use that pair for both the proof and Authorization header; re-check both values after signing. A superseded session, revoked origin, or concurrent refresh that changes either value returns the original request without adding SDK credentials, preserving its redirect policy. Do not re-sign or force another refresh in that upgrade; later requests use the refreshed pair normally.
- The final credential check runs before
upgrade()resolves for dispatch. A logout in the microtask gap after it resolves cannot recall the already-built request, which may still be sent. - On any failure after arming a session, clear both the provider session and the authenticated-fetch boundary.
- Keep same-WebID login single-flight; reject concurrent login for a different WebID.
Lifecycle rules
- Call
restore()before showing the unauthenticated screen. - Use
dropLiveSession()for transient failures that should preserve the durable refresh credential. - Use
logout()for intentional sign-out or a definitive invalid grant; await durable cleanup before publishing logged-out state. - Persist/rotate credentials before publishing authenticated state.
- Use
rememberAccount()for display metadata instead of an app-local overlay. rememberAccount()is a no-op for WebIDs outside HTTPS (HTTP loopback requiresallowInsecureLoopback). Newly stored labels, including WebID fallbacks, are truncated to the exportedMAX_DISPLAY_NAME_LENGTH(256 Unicode code points); the full account WebID is preserved. Admit only absolute HTTP(S) avatars. Omitted metadata and rejected avatars preserve existing safe values.- Prefer a stable Client Identifier Document and WebID-first login. If a profile advertises multiple issuers or storage roots, require an explicit choice.
This package is security-critical. Keep tests adversarial and non-vacuous, including cross-account switching, delayed stale operations, login-stall regression, pristine-fetch routing, foreign-origin refusal, DPoP nonce handling, and restore/logout races. Run the full gate.
04 同仓库更多 Skills
storage-conformance
Work on @jeswr/storage-conformance, the shared storage conformance suite package in the Solid SDK workspace.
fetch-rdf-engine-tests
Maintain fetch-rdf's real Node WASM parser integration tests without introducing a reverse engine dependency in fetch-rdf.
alpha
Use when checking fixtures, including folded YAML descriptions.
widget
Use when testing package skills: YAML quoting works.
web-seo
Use when improving technical and entity SEO for a modern personal, portfolio, documentation, or marketing site, including crawlable HTML, canonical metadata, sitemap and robots, Person/ProfilePage JSON-LD, Core Web Vitals, and honest ranking expectations.
solid-wac
Use when implementing or auditing Solid server WAC authorization, ACL creation and inheritance, auxiliary-resource escalation, method-to-mode mapping, 401 versus 403 challenges, WAC-Allow, or defensive typed ACL parsing with @solid/object and @rdfjs/wrapper.