diff --git a/apps/web/contents/addons/v2-supply-chain.mdx b/apps/web/contents/addons/v2-supply-chain.mdx
index 4b96467..06e8a76 100644
--- a/apps/web/contents/addons/v2-supply-chain.mdx
+++ b/apps/web/contents/addons/v2-supply-chain.mdx
@@ -5,7 +5,7 @@ description: The signed executable release protocol, byte-level verifier and pri
# Reviewed executable v2 packages
-NextGuide supports **read-only verification** of independently reviewed v2 executable archives. This does not enable production execution. The private ngapi server currently approves content-only v1 releases; v2 requires a separate registry deployment.
+NextGuide supports **read-only verification and private Account Mode staging** of independently reviewed v2 executable archives, with owner permission-consent records. This does not enable production execution. The private ngapi server currently approves content-only v1 releases; v2 requires a separate registry deployment.
## Source to trusted bytes
@@ -38,6 +38,26 @@ The registry backend must verify independent review, reproducible build provenan
**The private ngapi service has not been upgraded by this milestone.** Before server deployment, prepare and test a private patch against the actual VPS backend, with a backup and rollback procedure.
+## Account Mode private v2 staging
+
+The Account Mode **Add-ons** page now has a separate **Executable extensions** review panel below the existing, working v1 Markdown marketplace. Once your privately hosted ngapi implements the signed v2 endpoint and its public key is pinned to the host, the panel can browse reviewed v2 releases, show independent reviewer identity, version, compatibility, exact archive digest and requested capabilities.
+
+The server-side staging journal lives outside the Next.js project and stores only immutable, reviewed package bytes, bounded state history and version-specific permission approvals. It uses cross-process locking, atomic journal revisions and exact SHA-256 checks. Staged executable add-ons are always **blocked from execution**; no enabled flag or host-process module loader exists.
+
+Owner actions:
+
+- **Stage reviewed release:** Download the signed GitHub artifact, verify every byte, check compatibility and latest active signed status again, and save it privately with no grants.
+- **Review and approve capabilities:** Require owner session, same-origin request, explicit consent and exact pinned version/digest/permission list. Permission approval is a record only, never an execution grant.
+- **Update and rollback:** Only to signed active versions. Clear *all* prior grants and require fresh review. If the registry is expired, unreachable or revoked, the action fails closed.
+- **Revoke permissions and uninstall:** Work offline to let the owner disable previously granted privileges or remove the staged add-on from the journal even when the signed registry is unavailable.
+- **History:** The last 100 successful actions are stored privately. No executable code or credentials are exposed through the API response.
+
+Trusted Account Mode server configuration uses **NEXTGUIDE_ADDON_V2_REGISTRY_URL** set to the trusted HTTPS `/v2/registry` endpoint and **NEXTGUIDE_ADDON_V2_PUBLIC_KEY_B64** containing the base64-encoded pinned PEM public key. Never place a private signing key or public registry URL in browser-provided request data.
+
+The generated studio API uses existing site-owner session validation and origin protection for all changes. **Existing Account Mode installations must preview and explicitly apply a generated-route refresh** using the `nextguide upgrade --refresh-generated --dry-run` command and then `--refresh-generated`; NextGuide does not silently overwrite previously installed routes.
+
+No private ngapi v2 server upgrade has happened. Until the registry service is implemented, the panel shows configuration/unavailable status and retains safe offline access to existing staged state. The released `0.0.1-alpha.2` package also does not meet manifests requiring `>=1.0.0`, intentionally preventing premature alpha staging.
+
## Remaining execution gates
The experimental Linux Bubblewrap runner still needs cgroup memory/process limits and independent sandbox testing. Windows has no approved secure backend yet. Browser UI execution requires separate origin/frame isolation. The private v2 installer must transactionally pin approved versions, obtain explicit site-owner grants and recheck revocations before each activation.
diff --git a/packages/nextguide/lib/account-studio-template.mjs b/packages/nextguide/lib/account-studio-template.mjs
index 22970e4..8349be2 100644
--- a/packages/nextguide/lib/account-studio-template.mjs
+++ b/packages/nextguide/lib/account-studio-template.mjs
@@ -4,6 +4,7 @@ const STUDIO_API = `// Generated by NextGuide CLI. Edit freely; NextGuide never
import { ACCOUNT_COOKIE, AccountError, verifySession, sameOrigin } from "nextguide/account/server"
import { listStudioPages, readStudioPage, saveStudioPage, deleteStudioPage, getStudioNavigation, setStudioNavigation, getStudioSettings, saveStudioSettings, listStudioMedia, uploadStudioMedia, deleteStudioMedia } from "nextguide/account/cms"
import { createAccountAddonManager } from "nextguide/extensions/site-manager"
+import { createAccountV2AddonManager } from "nextguide/extensions/v2-site-manager"
function response(data__DATA_TYPE__, status = 200) {
@@ -70,6 +71,9 @@ export async function GET(request__REQUEST_TYPE__, { params }__PARAM_TYPE__) {
if (action === "addons") {
return response(await createAccountAddonManager({ project: process.cwd() }).catalog())
}
+ if (action === "addons-v2") {
+ return response(await createAccountV2AddonManager({ project: process.cwd() }).catalog())
+ }
if (action === "page") return response(readStudioPage(process.cwd(), url.searchParams.get("slug") ?? ""))
if (action === "navigation") return response(getStudioNavigation(process.cwd(), url.searchParams.get("folder") ?? ""))
if (action === "settings") return response(getStudioSettings(process.cwd()))
@@ -82,9 +86,20 @@ export async function POST(request__REQUEST_TYPE__, { params }__PARAM_TYPE__) {
if (!authorized(request)) return response({ error: "Sign in to access the editor." }, 401)
if (!sameOrigin(request)) return response({ error: "Invalid origin." }, 403)
const action = (await params).action
- if (!["save-page","delete-page","save-settings","save-navigation","upload-media","delete-media","addon-install","addon-toggle","addon-rollback","addon-uninstall"].includes(action))
+ if (!["save-page","delete-page","save-settings","save-navigation","upload-media","delete-media","addon-install","addon-toggle","addon-rollback","addon-uninstall","addon-v2-stage","addon-v2-grant","addon-v2-revoke","addon-v2-rollback","addon-v2-uninstall"].includes(action))
return response({ error: "Not found" }, 404)
const input = await body(request, action === "upload-media" ? 3_000_000 : 450_000)
+ if (action.startsWith("addon-v2-")) {
+ // Owner session, same-origin and JSON size checked above. Never accept
+ // filesystem paths, module source, signing keys, or a caller-defined URL.
+ const manager = createAccountV2AddonManager({ project: process.cwd() })
+ if (action === "addon-v2-stage") return response(await manager.stage(input))
+ if (action === "addon-v2-grant") return response(await manager.grant(input))
+ if (action === "addon-v2-revoke") return response(manager.revoke(input))
+ if (action === "addon-v2-rollback") return response(await manager.rollback(input))
+ if (action === "addon-v2-uninstall") return response(manager.uninstall(input))
+ return response({ error: "Not found" }, 404)
+ }
if (action.startsWith("addon-")) {
const addons = createAccountAddonManager({ project: process.cwd() })
if (action === "addon-install") return response(await addons.install(input))
diff --git a/packages/nextguide/lib/extension-v2-site-manager.d.mts b/packages/nextguide/lib/extension-v2-site-manager.d.mts
new file mode 100644
index 0000000..45f1c0f
--- /dev/null
+++ b/packages/nextguide/lib/extension-v2-site-manager.d.mts
@@ -0,0 +1,60 @@
+import type {
+ V2Capability,ReviewedV2Release
+} from "./extension-v2-catalog.mjs"
+export interface StagedV2Addon {
+ id:string
+ name:string
+ version:string
+ digest:string
+ requestedPermissions:V2Capability[]
+ grantedPermissions:V2Capability[]
+ availableVersions:string[]
+ reviewer:string
+ reviewedAt:string
+ execution:"blocked"
+}
+export interface V2Activity {
+ revision:number
+ at:string
+ operation:"stage"|"update"|"grant"|"revoke"|"rollback"|"uninstall"
+ id:string
+ version:string
+}
+export interface V2StagingCatalog {
+ configured:boolean
+ registryUnavailable:boolean
+ releases:Array
+ installed:{revision:number;addons:StagedV2Addon[];history:V2Activity[]}
+ nextguideVersion:string
+ executionAvailable:false
+}
+export declare function createAccountV2AddonManager(options?:{
+ project?:string
+ dataDir?:string
+ nextguideVersion?:string
+ registryUrl?:string
+ pinnedPublicKeyPem?:string
+ now?:()=>number
+ registryFetch?:typeof fetch
+ resolver?:(...args:any[])=>Promise>
+ transport?:(...args:any[])=>any
+}):{
+ catalog():Promise
+ stage(input:{
+ id:string;version:string;expectedRevision:number;consent:true
+ }):Promise<{revision:number;addon:StagedV2Addon;executionAvailable:false}>
+ grant(input:{
+ id:string;version:string;digest:string
+ permissions:V2Capability[]
+ expectedRevision:number;consent:true
+ }):Promise<{revision:number;addon:StagedV2Addon;executionAvailable:false}>
+ revoke(input:{
+ id:string;expectedRevision:number;consent:true
+ }):{revision:number;addon:StagedV2Addon;executionAvailable:false}
+ rollback(input:{
+ id:string;version:string;expectedRevision:number;consent:true
+ }):Promise<{revision:number;addon:StagedV2Addon;executionAvailable:false}>
+ uninstall(input:{
+ id:string;expectedRevision:number;consent:true
+ }):{revision:number;removed:string;privateDataPreserved:true;executionAvailable:false}
+}
diff --git a/packages/nextguide/lib/extension-v2-site-manager.mjs b/packages/nextguide/lib/extension-v2-site-manager.mjs
new file mode 100644
index 0000000..a4f90dd
--- /dev/null
+++ b/packages/nextguide/lib/extension-v2-site-manager.mjs
@@ -0,0 +1,401 @@
+/**
+ * Account Mode v2 review intake and private owner-consent journal.
+ *
+ * IMPORTANT: this stores verified executable packages as inert private BYTES.
+ * No runtime handles, executable entrypoints, dynamic imports, browser scripts
+ * or "enabled" state are exposed. Grants are version+digest+permission bound
+ * but still DO NOT authorize execution until the separate isolation gate ships.
+ *
+ * V1 Markdown installations remain in their own independent journal.
+ */
+import { createHash, randomBytes } from "node:crypto"
+import {
+ closeSync, existsSync, lstatSync, mkdirSync, openSync, readFileSync,
+ realpathSync, renameSync, unlinkSync, writeFileSync, linkSync,
+} from "node:fs"
+import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path"
+import { createRequire } from "node:module"
+import { accountFile } from "./account-auth.mjs"
+import { compatibleAddonRange } from "./extension-install-state.mjs"
+import {
+ createVerifiedV2RegistryClient, verifySignedV2RegistryEnvelope,
+ listReviewedV2Releases, compareV2Permissions,
+} from "./extension-v2-catalog.mjs"
+import { verifyReviewedV2Archive } from "./extension-v2-artifacts.mjs"
+import { downloadReviewedV2Release } from "./extension-download.mjs"
+
+const require=createRequire(import.meta.url)
+const FRAMEWORK_VERSION=require("../package.json").version
+const ID=/^[a-z0-9]+(?:-[a-z0-9]+)*\.[a-z0-9]+(?:-[a-z0-9]+)*$/
+const VERSION=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
+const PACKAGE_VERSION=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/
+const SHA=/^[a-f0-9]{64}$/
+const MAX_ADDONS=64, MAX_VERSIONS=4, MAX_EVENTS=100
+const MAX_FILE_SIZE=3*1024*1024
+const ACTIONS=new Set(["stage","update","grant","revoke","rollback","uninstall"])
+const clone=value=>JSON.parse(JSON.stringify(value))
+const digest=bytes=>createHash("sha256").update(bytes).digest("hex")
+function fail(code,message){
+ const error=new Error("NextGuide v2 staging: "+message)
+ error.code=code
+ throw error
+}
+function object(x){return x!==null && typeof x==="object" && !Array.isArray(x)}
+function validId(id){return typeof id==="string" && id.length<=100 && ID.test(id)}
+function validVersion(v){return typeof v==="string" && VERSION.test(v)}
+function validHash(s){return typeof s==="string" && SHA.test(s)}
+function assertRegular(path){
+ if(!existsSync(path))fail("MISSING_ARTIFACT","Required private file is missing")
+ const info=lstatSync(path)
+ if(!info.isFile() || info.isSymbolicLink())fail("UNSAFE_STORAGE","Refusing linked or nonregular file")
+ return info
+}
+function cleanDir(path){
+ if(!existsSync(path))mkdirSync(path,{recursive:true,mode:0o700})
+ if(!lstatSync(path).isDirectory() || lstatSync(path).isSymbolicLink()){
+ fail("UNSAFE_STORAGE","Private directory must not be a symlink")
+ }
+}
+function compare(a,b){
+ const aa=a.split(".").map(BigInt), bb=b.split(".").map(BigInt)
+ for(let i=0;i<3;i++)if(aa[i]!==bb[i])return aa[i]>bb[i]?1:-1
+ return 0
+}
+function safeSnapshot(value){
+ if(!object(value) || !validVersion(value.version) || !validHash(value.digest) ||
+ !Number.isSafeInteger(value.size) || value.size<32 || value.size>MAX_FILE_SIZE ||
+ typeof value.name!=="string" || value.name.length<3 || value.name.length>80 ||
+ !Array.isArray(value.permissions) || value.permissions.length>16 ||
+ !Array.isArray(value.grants) || value.grants.length>16 ||
+ typeof value.reviewer!=="string" || value.reviewer.length>100 ||
+ !Number.isFinite(Date.parse(value.reviewedAt)))return false
+ try {
+ compareV2Permissions([],value.permissions,value.grants)
+ return value.grants.every(permission=>value.permissions.includes(permission))
+ }catch{return false}
+}
+function safeState(value){
+ if(!object(value) || value.schemaVersion!==2 ||
+ !Number.isSafeInteger(value.revision) || value.revision<0 ||
+ !object(value.addons) || Object.keys(value.addons).length>MAX_ADDONS ||
+ !Array.isArray(value.history) || value.history.length>MAX_EVENTS){
+ fail("DAMAGED_STATE","Invalid v2 private installation journal")
+ }
+ for(const [id,entry] of Object.entries(value.addons)){
+ if(!validId(id) || !object(entry) || entry.id!==id ||
+ !validVersion(entry.pinnedVersion) ||
+ !Array.isArray(entry.versions) || !entry.versions.length ||
+ entry.versions.length>MAX_VERSIONS ||
+ new Set(entry.versions.map(v=>v.version)).size!==entry.versions.length ||
+ !entry.versions.every(safeSnapshot) ||
+ !entry.versions.some(v=>v.version===entry.pinnedVersion)){
+ fail("DAMAGED_STATE","Invalid v2 private release entry")
+ }
+ }
+ let last=0
+ for(const event of value.history){
+ if(!object(event) || !Number.isSafeInteger(event.revision) ||
+ event.revision<=last || event.revision>value.revision ||
+ !validId(event.id) || !validVersion(event.version) ||
+ !ACTIONS.has(event.operation) || !Number.isFinite(Date.parse(event.at))) {
+ fail("DAMAGED_STATE","Invalid v2 private activity history")
+ }
+ last=event.revision
+ }
+ return value
+}
+function initialState(){return {schemaVersion:2,revision:0,addons:{},history:[]}}
+function publicEntry(entry){
+ const selected=entry.versions.find(x=>x.version===entry.pinnedVersion)
+ return {
+ id:entry.id,name:selected.name,version:selected.version,
+ digest:selected.digest,requestedPermissions:[...selected.permissions],
+ grantedPermissions:[...selected.grants],
+ availableVersions:entry.versions.map(x=>x.version),
+ reviewer:selected.reviewer,reviewedAt:selected.reviewedAt,
+ // Deliberately never an "enabled" flag; host execution is unavailable.
+ execution:"blocked",
+ }
+}
+function publicState(s){return {
+ revision:s.revision,addons:Object.values(s.addons).map(publicEntry),
+ history:clone(s.history),
+}}
+
+/**
+ * No user-driven project paths or data roots may be passed from route input.
+ * Only the owner-authenticated server constructs the manager.
+ */
+export function createAccountV2AddonManager({
+ project=process.cwd(),dataDir,
+ nextguideVersion=FRAMEWORK_VERSION,
+ registryUrl=process.env.NEXTGUIDE_ADDON_V2_REGISTRY_URL,
+ pinnedPublicKeyPem=process.env.NEXTGUIDE_ADDON_V2_PUBLIC_KEY_B64
+ ? Buffer.from(process.env.NEXTGUIDE_ADDON_V2_PUBLIC_KEY_B64,"base64").toString("utf8"):"",
+ now=()=>Date.now(), registryFetch,resolver,transport,
+}={}){
+ if(typeof nextguideVersion!=="string" || !PACKAGE_VERSION.test(nextguideVersion) ||
+ typeof now!=="function" || !Number.isFinite(now())){
+ fail("CONFIGURATION","Invalid local framework version or trusted clock")
+ }
+ const site=resolve(project)
+ const configFile=join(site,"nextguide.config.json")
+ assertRegular(configFile)
+ let config
+ try{config=JSON.parse(readFileSync(configFile,"utf8"))}
+ catch{fail("INVALID_CONFIG","Invalid site configuration")}
+ if(config?.mode!=="account" || config?.contentDir!=="content/docs"){
+ fail("MODE_DENIED","Executable staging is exclusive to Account Mode")
+ }
+ const privateFile=accountFile(site,dataDir)
+ assertRegular(privateFile)
+ const privateRoot=dirname(privateFile)
+ if(lstatSync(privateRoot).isSymbolicLink()){
+ fail("UNSAFE_STORAGE","Private root cannot be a symlink")
+ }
+ const actualSite=realpathSync(site), actualPrivate=realpathSync(privateRoot)
+ const rel=relative(actualSite,actualPrivate)
+ if(rel==="" || (rel!==".." && !rel.startsWith(".."+sep) && !isAbsolute(rel))){
+ fail("UNSAFE_STORAGE","Owner data must remain outside the served project")
+ }
+ const root=join(privateRoot,"addons-v2")
+ const blobs=join(root,"blobs")
+ cleanDir(root);cleanDir(blobs)
+ const index=join(root,"staged.json")
+ const lock=join(root,".lock")
+ const configured=typeof registryUrl==="string" && registryUrl.length>0 &&
+ typeof pinnedPublicKeyPem==="string" && pinnedPublicKeyPem.length>0
+ const registry=configured?createVerifiedV2RegistryClient({
+ registryUrl,pinnedPublicKeyPem,
+ ...(registryFetch?{fetchImpl:registryFetch}:{}),now,
+ }):null
+
+ function state(){
+ if(!existsSync(index))return initialState()
+ const stat=assertRegular(index)
+ if(stat.size>128*1024)fail("DAMAGED_STATE","Private v2 journal exceeds size quota")
+ try{return safeState(JSON.parse(readFileSync(index,"utf8")))}
+ catch{fail("DAMAGED_STATE","Private v2 journal is damaged")}
+ }
+ function blobFile(hash){
+ if(!validHash(hash))fail("INVALID_DIGEST","Invalid artifact SHA-256")
+ return join(blobs,hash+".tgz")
+ }
+ function checkedBlob(snapshot){
+ const file=blobFile(snapshot.digest)
+ const stat=assertRegular(file)
+ if(stat.size!==snapshot.size)fail("CORRUPT_ARTIFACT","Stored executable archive size changed")
+ const bytes=readFileSync(file)
+ if(digest(bytes)!==snapshot.digest)fail("CORRUPT_ARTIFACT","Stored executable SHA-256 changed")
+ return bytes
+ }
+ function immutableBlob(release,bytes){
+ const path=blobFile(release.digest)
+ if(existsSync(path)){
+ checkedBlob(release)
+ return
+ }
+ const temp=join(blobs,"."+randomBytes(16).toString("hex")+".tmp")
+ try{
+ writeFileSync(temp,bytes,{flag:"wx",mode:0o600})
+ // Hard-link publication is exclusive. Never replace an existing
+ // content-addressed blob in another site's concurrent write.
+ try{linkSync(temp,path)}catch(err){if(err.code!=="EEXIST")throw err}
+ }finally{if(existsSync(temp))unlinkSync(temp)}
+ checkedBlob(release)
+ }
+ async function signed(){
+ if(!registry)fail("NO_REGISTRY","Signed executable v2 registry is not configured")
+ const envelope=await registry.fetchSignedEnvelope()
+ const catalog=verifySignedV2RegistryEnvelope(envelope,pinnedPublicKeyPem,{now:now()})
+ return {envelope,catalog}
+ }
+ function activeRelease(catalog,id,version,digestValue){
+ if(!validId(id) || !validVersion(version))fail("INVALID_REQUEST","Invalid add-on identity")
+ const release=catalog.releases.find(x=>
+ x.manifest.id===id && x.manifest.version===version)
+ if(!release || release.status!=="active" ||
+ (digestValue && release.digest!==digestValue) ||
+ !compatibleAddonRange(release.manifest.compatibility.nextguide,nextguideVersion)){
+ fail("NOT_APPROVED","V2 release revoked, missing or incompatible with installed NextGuide")
+ }
+ return release
+ }
+ function approvalInput({id,expectedRevision,consent}){
+ if(!validId(id) || !Number.isSafeInteger(expectedRevision) ||
+ expectedRevision<0)fail("INVALID_REQUEST","An add-on ID and exact state revision are required")
+ if(consent!==true)fail("CONSENT_REQUIRED","Explicit owner consent is required")
+ }
+ function mutate(expectedRevision,operation,id,action){
+ if(!Number.isSafeInteger(expectedRevision) || expectedRevision<0){
+ fail("INVALID_REQUEST","Expected state revision required")
+ }
+ let fd
+ try{fd=openSync(lock,"wx",0o600)}
+ catch{fail("BUSY","Another add-on operation is active")}
+ try{
+ const previous=state()
+ if(previous.revision!==expectedRevision){
+ fail("CONFLICT","Add-on journal changed; refresh and retry")
+ }
+ const next=clone(previous)
+ const result=action(next)
+ next.revision=previous.revision+1
+ const record=next.addons[id]
+ const version=record?.pinnedVersion??previous.addons[id]?.pinnedVersion
+ next.history=[...previous.history,{
+ revision:next.revision,at:new Date(now()).toISOString(),
+ operation,id,version,
+ }].slice(-MAX_EVENTS)
+ safeState(next)
+ const temp=join(root,"."+randomBytes(16).toString("hex")+".tmp")
+ try{
+ writeFileSync(temp,JSON.stringify(next)+"\n",{flag:"wx",mode:0o600})
+ renameSync(temp,index)
+ }finally{if(existsSync(temp))unlinkSync(temp)}
+ return {revision:next.revision,...result}
+ }finally{
+ closeSync(fd)
+ unlinkSync(lock)
+ }
+ }
+ return {
+ async catalog(){
+ const installed=publicState(state())
+ if(!registry)return {
+ configured:false,registryUnavailable:true,releases:[],
+ installed,nextguideVersion,executionAvailable:false,
+ }
+ try{
+ const {catalog}=await signed()
+ return {
+ configured:true,registryUnavailable:false,
+ releases:listReviewedV2Releases(catalog,{now:now()}).map(release=>({
+ ...release,
+ compatible:compatibleAddonRange(release.manifest.compatibility.nextguide,nextguideVersion),
+ })),
+ installed,nextguideVersion,executionAvailable:false,
+ }
+ }catch{
+ return {configured:true,registryUnavailable:true,
+ releases:[],installed,nextguideVersion,executionAvailable:false}
+ }
+ },
+ /**
+ * Download/verify and STAGE a reviewed, signed v2 release. No execution or
+ * automatic permission grant, including on updates.
+ */
+ async stage({id,version,expectedRevision,consent}={}){
+ approvalInput({id,expectedRevision,consent})
+ if(!validVersion(version))fail("INVALID_REQUEST","Invalid reviewed release version")
+ const {envelope,catalog}=await signed()
+ const release=activeRelease(catalog,id,version)
+ const {archive,verified}=await downloadReviewedV2Release({
+ envelope,pinnedPublicKeyPem,id,version,
+ now,...(resolver?{resolver}:{}),...(transport?{transport}:{}),
+ })
+ if(digest(archive)!==release.digest ||
+ verified.compiled.sha256!==release.review.serverSha256){
+ fail("CORRUPT_ARTIFACT","Downloaded v2 bundle changed")
+ }
+ // Latest signed revocation check at mutation time (not only before HTTPS).
+ const fresh=await signed()
+ activeRelease(fresh.catalog,id,version,release.digest)
+ return mutate(expectedRevision,"stage",id,next=>{
+ const prior=next.addons[id]
+ if(!prior && Object.keys(next.addons).length>=MAX_ADDONS){
+ fail("CAPACITY","Maximum staged executable add-on count reached")
+ }
+ if(prior && compare(version,prior.pinnedVersion)<=0){
+ fail("DOWNGRADE","Use explicit rollback to restore a previous reviewed version")
+ }
+ const snapshot={
+ version,digest:release.digest,size:release.size,
+ name:release.manifest.name,
+ permissions:[...release.manifest.permissions],
+ grants:[],reviewer:release.review.reviewer,
+ reviewedAt:release.review.approvedAt,
+ }
+ immutableBlob(release,archive)
+ // Never carry over approvals from ANY previous executable version.
+ // A rollback will require fresh consent for that exact digest.
+ const versions=prior?
+ [...prior.versions.filter(x=>x.version!==version).map(x=>({
+ ...x,grants:[],
+ })),snapshot].slice(-MAX_VERSIONS):
+ [snapshot]
+ next.addons[id]={id,pinnedVersion:version,versions}
+ return {addon:publicEntry(next.addons[id]),executionAvailable:false}
+ })
+ },
+ /**
+ * Consent must match the exact pinned release digest and all requested
+ * capabilities. Even a granted record NEVER makes code runnable.
+ */
+ async grant({id,version,digest:expectedDigest,permissions,
+ expectedRevision,consent}={}){
+ approvalInput({id,expectedRevision,consent})
+ if(!validVersion(version) || !validHash(expectedDigest) ||
+ !Array.isArray(permissions)){
+ fail("INVALID_REQUEST","Version, exact artifact digest and permissions are required")
+ }
+ const {envelope,catalog}=await signed()
+ activeRelease(catalog,id,version,expectedDigest)
+ return mutate(expectedRevision,"grant",id,next=>{
+ const entry=next.addons[id]
+ if(!entry || entry.pinnedVersion!==version)fail("NOT_INSTALLED","Pinned release changed")
+ const snapshot=entry.versions.find(x=>x.version===version)
+ if(!snapshot || snapshot.digest!==expectedDigest){
+ fail("CONFLICT","Release hash changed; review permissions again")
+ }
+ const diff=compareV2Permissions([],snapshot.permissions,permissions)
+ if(diff.ungranted.length || permissions.length!==snapshot.permissions.length){
+ fail("PERMISSION_DENIED","Approval must match every requested capability")
+ }
+ verifyReviewedV2Archive({
+ envelope,pinnedPublicKeyPem,id,version,
+ archive:checkedBlob(snapshot),now:now(),
+ })
+ snapshot.grants=[...snapshot.permissions]
+ return {addon:publicEntry(entry),executionAvailable:false}
+ })
+ },
+ /** Revoke all grants OFFLINE, even when the registry has disappeared. */
+ revoke({id,expectedRevision,consent}={}){
+ approvalInput({id,expectedRevision,consent})
+ return mutate(expectedRevision,"revoke",id,next=>{
+ const entry=next.addons[id]
+ if(!entry)fail("NOT_INSTALLED","No staged release")
+ entry.versions.find(x=>x.version===entry.pinnedVersion).grants=[]
+ return {addon:publicEntry(entry),executionAvailable:false}
+ })
+ },
+ async rollback({id,version,expectedRevision,consent}={}){
+ approvalInput({id,expectedRevision,consent})
+ if(!validVersion(version))fail("INVALID_REQUEST","Invalid rollback version")
+ const {envelope,catalog}=await signed()
+ return mutate(expectedRevision,"rollback",id,next=>{
+ const entry=next.addons[id]
+ if(!entry)fail("NOT_INSTALLED","No staged executable add-on")
+ const snapshot=entry.versions.find(x=>x.version===version)
+ if(!snapshot || entry.pinnedVersion===version){
+ fail("NOT_INSTALLED","Requested reviewed rollback version is unavailable")
+ }
+ activeRelease(catalog,id,version,snapshot.digest)
+ verifyReviewedV2Archive({envelope,pinnedPublicKeyPem,id,version,
+ archive:checkedBlob(snapshot),now:now()})
+ entry.pinnedVersion=version
+ for(const prior of entry.versions)prior.grants=[]
+ return {addon:publicEntry(entry),executionAvailable:false}
+ })
+ },
+ uninstall({id,expectedRevision,consent}={}){
+ approvalInput({id,expectedRevision,consent})
+ return mutate(expectedRevision,"uninstall",id,next=>{
+ if(!next.addons[id])fail("NOT_INSTALLED","No staged executable add-on")
+ delete next.addons[id]
+ return {removed:id,privateDataPreserved:true,executionAvailable:false}
+ })
+ },
+ }
+}
diff --git a/packages/nextguide/package.json b/packages/nextguide/package.json
index b54818f..95021df 100644
--- a/packages/nextguide/package.json
+++ b/packages/nextguide/package.json
@@ -16,9 +16,9 @@
],
"scripts": {
"build": "node scripts/build.mjs",
- "test": "node scripts/build.mjs && node --test test/cli-ui.test.mjs test/account-ui-isolation.test.mjs test/account-semantics-icons.test.mjs test/doctor.test.mjs test/init.test.mjs test/distribution.test.mjs test/page.test.mjs test/page-cli.test.mjs test/version.test.mjs test/upgrade.test.mjs test/account-auth.test.mjs test/account-init.test.mjs test/account-cms.test.mjs test/extensions.test.mjs test/extension-runtime.test.mjs test/extension-storage.test.mjs test/extension-catalog.test.mjs test/extension-network.test.mjs test/extension-isolation.test.mjs test/extension-artifacts.test.mjs test/extension-install-state.test.mjs test/extension-download.test.mjs test/extension-v2.test.mjs test/extension-site-manager.test.mjs test/addon-page.test.mjs test/docs-chatgpt.test.mjs",
+ "test": "node scripts/build.mjs && node --test test/cli-ui.test.mjs test/account-ui-isolation.test.mjs test/account-semantics-icons.test.mjs test/doctor.test.mjs test/init.test.mjs test/distribution.test.mjs test/page.test.mjs test/page-cli.test.mjs test/version.test.mjs test/upgrade.test.mjs test/account-auth.test.mjs test/account-init.test.mjs test/account-cms.test.mjs test/extensions.test.mjs test/extension-runtime.test.mjs test/extension-storage.test.mjs test/extension-catalog.test.mjs test/extension-network.test.mjs test/extension-isolation.test.mjs test/extension-artifacts.test.mjs test/extension-install-state.test.mjs test/extension-download.test.mjs test/extension-v2.test.mjs test/extension-site-manager.test.mjs test/addon-page.test.mjs test/docs-chatgpt.test.mjs test/extension-v2-site-manager.test.mjs",
"test:dist": "node --test test/distribution.test.mjs",
- "prepack": "node scripts/build.mjs && node --test test/cli-ui.test.mjs test/account-ui-isolation.test.mjs test/account-semantics-icons.test.mjs test/doctor.test.mjs test/init.test.mjs test/distribution.test.mjs test/page.test.mjs test/page-cli.test.mjs test/version.test.mjs test/upgrade.test.mjs test/account-auth.test.mjs test/account-init.test.mjs test/account-cms.test.mjs test/extensions.test.mjs test/extension-runtime.test.mjs test/extension-storage.test.mjs test/extension-catalog.test.mjs test/extension-network.test.mjs test/extension-isolation.test.mjs test/extension-artifacts.test.mjs test/extension-install-state.test.mjs test/extension-download.test.mjs test/extension-v2.test.mjs test/extension-site-manager.test.mjs test/addon-page.test.mjs test/docs-chatgpt.test.mjs",
+ "prepack": "node scripts/build.mjs && node --test test/cli-ui.test.mjs test/account-ui-isolation.test.mjs test/account-semantics-icons.test.mjs test/doctor.test.mjs test/init.test.mjs test/distribution.test.mjs test/page.test.mjs test/page-cli.test.mjs test/version.test.mjs test/upgrade.test.mjs test/account-auth.test.mjs test/account-init.test.mjs test/account-cms.test.mjs test/extensions.test.mjs test/extension-runtime.test.mjs test/extension-storage.test.mjs test/extension-catalog.test.mjs test/extension-network.test.mjs test/extension-isolation.test.mjs test/extension-artifacts.test.mjs test/extension-install-state.test.mjs test/extension-download.test.mjs test/extension-v2.test.mjs test/extension-site-manager.test.mjs test/addon-page.test.mjs test/docs-chatgpt.test.mjs test/extension-v2-site-manager.test.mjs",
"test:unit": "bunx vitest run",
"check-types": "node scripts/build.mjs"
},
@@ -209,6 +209,11 @@
"types": "./lib/extension-v2-artifacts.d.mts",
"node": "./lib/extension-v2-artifacts.mjs",
"default": "./lib/extension-v2-artifacts.mjs"
+ },
+ "./extensions/v2-site-manager": {
+ "types": "./lib/extension-v2-site-manager.d.mts",
+ "node": "./lib/extension-v2-site-manager.mjs",
+ "default": "./lib/extension-v2-site-manager.mjs"
}
},
"imports": {
diff --git a/packages/nextguide/src/account/addon-marketplace.tsx b/packages/nextguide/src/account/addon-marketplace.tsx
index 0fe0097..83779c9 100644
--- a/packages/nextguide/src/account/addon-marketplace.tsx
+++ b/packages/nextguide/src/account/addon-marketplace.tsx
@@ -108,7 +108,7 @@ function ReleaseDetails({ release, back, installed, onAction, busy, catalogFresh
Source repository
This preview accepts reviewed plain Markdown content only.
- Installed add-on pages are not yet automatically mounted into the public documentation.
+ Enabled, verified Markdown pages are available in Account Mode documentation navigation and search.
Release information
@@ -147,7 +147,7 @@ function ReleaseDetails({ release, back, installed, onAction, busy, catalogFresh
This release is incompatible with your installed NextGuide version or requests unsupported capabilities.
}
No JavaScript is executed. Enabling stores content state;
- public page mounting remains a separate milestone.
+ signed Markdown content is rendered in dedicated, non-executable documentation routes.
Download and privately stage independently reviewed
+ executable add-on {action.id} v{action.version}? The exact archive and every source hash will be
+ verified. It will stay blocked from execution and request no automatic grants.
+ if (action.kind==="grant") return
+
Record explicit owner consent for {action.id} v{action.version} and
+ the exact reviewed SHA-256 {action.digest.slice(0,16)}…?
Review independently signed JavaScript/TypeScript
+ packages, their publisher, exact SHA-256 and requested capabilities. Stage releases
+ privately and record explicit owner permission approval. Nothing can run here
+ until the separately audited sandbox and v2 registry are production-ready.
}
+ {data && !data.configured &&
+ The private v2 signed registry is not connected. This preview becomes available
+ only when the independently reviewed /v2/registry service and pinned public
+ key are configured. Existing v1 Markdown add-ons are unaffected.}
+ {data?.configured && data.registryUnavailable &&
+ The signed executable registry is unavailable or cannot be verified.
+ No new staging, grants or rollback is allowed; offline permission revocation
+ and uninstall remain available.}
+ {installed.length>0 &&