suite-native
Use when working on @jeswr/suite-native, the Solid Suite's native-app seams (system-browser Solid-OIDC code driver, share sheet in/out, refresh-token secure store, mobile Client ID Document) used by the Capacitor shells in apps/mobile.
- License 许可
- MIT
- 所属仓库
- jeswr/solid-sdk
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- suite-native
- description
- Use when working on @jeswr/suite-native, the Solid Suite's native-app seams (system-browser Solid-OIDC code driver, share sheet in/out, refresh-token secure store, mobile Client ID Document) used by the Capacitor shells in apps/mobile.
02 资源文件 26
- 参考文档package.json1.1 KB
- 参考文档README.md7.4 KB
- 脚本src/auth-session.test.ts19.2 KB
- 脚本src/auth-session.ts10.4 KB
- 脚本src/capacitor.test.ts767 B
- 脚本src/capacitor.ts1.1 KB
- 脚本src/client-id.test.ts1.8 KB
- 脚本src/client-id.ts2.9 KB
- 脚本src/errors.ts2.3 KB
- 脚本src/hardening.test.ts7.4 KB
- 脚本src/index.test.ts1.3 KB
- 脚本src/index.ts1.8 KB
- 脚本src/pdf-preview.test.ts6.1 KB
- 脚本src/pdf-preview.ts3.9 KB
- 脚本src/platform.test.ts1.2 KB
- 脚本src/platform.ts1.1 KB
- 脚本src/secure-store.test.ts15.4 KB
- 脚本src/secure-store.ts6.6 KB
- 脚本src/share-intake.test.ts12.0 KB
- 脚本src/share-intake.ts10.5 KB
- 脚本src/share-staging.test.ts8.6 KB
- 脚本src/share-staging.ts5.8 KB
- 脚本src/share.test.ts3.7 KB
- 脚本src/share.ts3.6 KB
- 参考文档tsconfig.json279 B
- 脚本vitest.config.ts522 B
03 SKILL.md 正文
<!-- AUTHORED-BY Claude Opus 5.5 -->
@jeswr/suite-native
Read solid-suite-planning/specs/mobile/DESIGN.md (D3 bridge isolation, D4 sign-in,
D5 redirect + Client ID Document, D7 share, D9 hardening) and sdk-core ADR-004-auth.md
(D2 ui.getCode, D5 keys) before changing this package.
Rules
- Security critical: 100% coverage, adversarial tests for every check. Never relax a fail-closed
check in
auth-session.tswithout a design change; never return anything but the code from the driver, and never let access tokens, PKCE verifiers or DPoP keys pass through native code. Refresh tokens may cross only theSuiteSecureStoreseam (MOB-P4 S11/S12). src/index.tsmust not import@capacitor/core(web bundles load it); native bindings live only insrc/capacitor.tsand are registered by the native plugin namesSuiteAuthSession,SuiteShareIntake,SuiteShareStaging,SuiteSecureStore,SuiteFilesandShare. Changing a plugin method means changing the Swift/Java plugin inapps/mobilein the same PR.- Everything from native code is untrusted: validate with
validateShareBatchand enforce sizes inreadFile; native code validates too. The sending app declares a shared file's type, so active types (HTML, XML, SVG, script) becomeapplication/octet-stream.sanitiseFileNamealso replaces%,?,#,:, C1 controls and bidi overrides, and caps names at 255 UTF-8 bytes. - The driver refuses authorization URLs carrying
requestorrequest_uri(JAR/PAR would bypass its checks) and drops an IdP error description outside the RFC 6749 charset. - The redirect URI is the private-use scheme
org.jeswr.suite:/oauth/callback; the Client ID Document is served from the suite origin at/.well-known/solid-client-id-mobile.jsonld.
Validate with this package's lint, build, typecheck and test scripts.
<!-- AUTHORED-BY GPT-5.6 Codex -->
Outgoing pod files (DESIGN D7)
- The caller supplies a Blob already downloaded with its authenticated fetch.
stageFileandshareFilesmust never accept tokens or perform downloads in native code. ShareStagingPluginhasbegin({name, mimeType, size}),writeChunk({stagingId, offset, data})(base64),commit({stagingId}), andabort({stagingId}). Both sides enforce at most 512 KiB decoded per chunk, contiguous offsets, and a 100 MiB file cap. JS limits may lower these caps, never increase them. Sanitise names withsanitiseFileName.- Validate native IDs and commit URIs; attempt abort on every error once an ID is available.
Empty files commit without any write.
shareFiles([{blob, name, mimeType?}], content, targets)preflights 1–20 files and at most 100 MiB combined, then invokes the existingshareseam. - Both native stores return file:// URLs accepted by the installed Capacitor Share 8.0.3.
Android Share creates its own FileProvider content URI; do not return content:// from staging.
Keep
file_paths.xmlscoped tocache/share-out/and the PDF handoff'scache/pdf-preview/alone. iOS usestmp/share-out/. - Native stores reserve active uploads' declared bytes, reject malformed arguments and incomplete
commits, and enforce 24-hour retention, 100 MiB total, and 20 files, evicting oldest committed
files.
shareFilespasses the ids it has already staged asbegin({ keep }), so a batch never evicts its own files; begin fails instead when only kept files remain. Do not delete files when the share sheet closes: the recipient may read them later. - iOS registers
SuiteSharePluginunder the nameShare, replacing @capacitor/share 8.0.3, which would hand any app-containerfile:URL to the sheet. It accepts only committed share-out files and https URLs without credentials. Keep that override registered. - Keep store logic independent of Android/Capacitor APIs, test it with JVM JUnit, and maintain mobile guard tests for registration, FileProvider scope, and Xcode App target source entries.
PDF preview handoff (MOB-P3 E5)
openPdf(filesPlugin, name, bytes, signal?)takes bytes the caller already read with a bounded reader (Drive'sreadLimited); native code never fetches. It refuses files overPDF_PREVIEW_MAX_BYTES(25 MiB) or without the%PDF-signature before anything crosses, cuts the name to 255 code points, and stops before the next native call oncesignalaborts. Callers abort when the view that started the transfer goes away.- Native code repeats every check: the cap on the declared size and on each append, the
signature on the first bytes, canonical base64 chunks, a whole non-boolean size, names up to
4096 UTF-16 units, one handle at a time (a new
pdfBegindiscards the old one), and acache/pdf-preview/directory emptied when the process starts. A call naming any other handle is refused without touching the live transfer or the file a viewer has open. - Expiry is lazy and uses the monotonic clock: an idle (60 s) transfer is dropped on its next call or when the app returns to the foreground. Android also deletes a finished file five minutes after opening it, on the next resume (the external viewer may still read it until then); iOS deletes it when QuickLook closes. Android keeps one store per process, so a recreated activity never deletes a file the viewer is reading.
- Android opens a read-only FileProvider URI after
resolveActivity; iOS presents QuickLook with editing off. KeepPdfPreviewStorefree of Capacitor and platform UI so the JVM and XCTest suites cover it, including the bridge argument checks (declaredSize,checkChunk/decodeChunk). clearPdfPreviews(filesPlugin)(nativepdfClear) drops any transfer, dismisses QuickLook on iOS and emptiescache/pdf-preview/. The suite shell calls it whenever the active account changes away from a signed-in one (sign-out, sign-out-all, switch), never on first mount, so a recreated view cannot delete a file the viewer is reading for the same account. Drive's handoff also aborts its transfer when the active account changes, and iOS clears on the plugin queue before closing QuickLook, so a transfer that was already opening is closed.- Import
@jeswr/suite-native/capacitorlazily from web code, so only native builds load it.
Refresh-token secure store (MOB-P4 S11/S12)
Read solid-suite-planning/specs/mobile/P4-SECURE-STORE.md completely before changing this seam.
createSecureStore(plugin)exposesstatus(),get(key, signal?),set(key, value, { userPresence, version }),delete(key),clear()andcancel().getreturns{ value, version };setreturns the committed{ version }. Keep that version beside the in-memory token for rotations. Nativeremoveandclearinvalidate earlier versions through tombstones and the namespace epoch.- Validate keys against
^[a-z0-9][a-z0-9:._-]{0,127}$and values against the 16 KiB UTF-8 byte cap before the bridge. Versions must be non-negative safe integers, anduserPresencemust be boolean. Validate every native response's exact fields and types; malformed results becomefailed, including a committed set version that does not increase. SecureStoreErrorextendsSuiteNativeErrorwith a typedcode:cancelled,background,lockout,unavailable,stale,full,invalidorfailed. Its message is the code alone; never expose native details or use native messages to infer a code. Unknown codes becomefailed.- An aborted
getrejects immediately withcancelled, requests nativecancel(), drops late results and removes its listener. An already-aborted signal calls neither native method.cancelled,backgroundandlockoutnever justify deleting a session. refreshTokenKey({ issuer, webId, clientId })(each a non-empty string, else TypeError) ispod-auth:refresh:plus the lowercase hex WebCrypto SHA-256 ofJSON.stringify([issuer, webId, clientId]), without URL normalisation. Store only refresh tokens. Gate them when user presence is supported and unlock is enabled.- Keep the root pure and
secureStorePluginin./capacitor. There is no web fallback; off native, keep IndexedDB. pod-auth wiring belongs to MOB-06 after T-031 lands.
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.