cloud
permdock cloud push publishes the catalog, the code policy and the Supabase manifest to a PermDock Cloud project; permdock cloud pull writes the published catalog and manifest back, byte for byte.
permdock cloud push builds the same catalog as collect, with the policy's hostable flags, each permission's code approvals, and each role's on and assignable, and posts it with the code policy and permdock.manifest.json to a PermDock Cloud project. The Cloud reads it to offer only declared roles and plans, to hand out only assignable roles, to let an admin author hosted grants only on hostable permissions, and to serve the hosted AuthZEN endpoint for the published policy (PermDock Cloud).
permdock cloud pull reads what the last push sent and writes permissions.catalog.json and permdock.manifest.json as collect and supabase inspect --out write them, so authorizationProvider({ manifest, catalog }) and every other reader of those files see the same bytes.
A project is one Cloud environment and has the same id, so --project names both.
Usage
permdock cloud push # PERMDOCK_CLOUD_KEY, or a login from permdock login --scope catalog:write
permdock cloud push --project preview # overrides PERMDOCK_CLOUD_ENV, then the key's environment
permdock cloud push --manifest supabase/permdock.manifest.json
permdock cloud push --dry-run --json # print the fingerprint and summary; no network
permdock cloud pull --project prj_123 # with a login from permdock login
permdock cloud pull # in CI with PERMDOCK_CLOUD_TOKEN: the token's one project
printf '%s' "$KEY" | permdock cloud push --key-stdin # the key from a secret store, not the environment| Flag | Meaning |
|---|---|
--url | Base URL of the Cloud API; defaults to PERMDOCK_CLOUD_URL, then https://permdock.com/api |
--project | The project id, the same id as its environment. push defaults to PERMDOCK_CLOUD_ENV, then the environment GET /v1/environment names for the credential (a dry run prints "the key's environment"); pull needs it unless PERMDOCK_CLOUD_TOKEN names one project |
--key-stdin | push: read PERMDOCK_CLOUD_KEY from stdin |
--token-stdin | pull: read PERMDOCK_CLOUD_TOKEN from stdin |
--manifest | push: the manifest to send (default permdock.manifest.json, sent when present); pull: where to write it |
--dry-run | push: build the catalog and print its fingerprint without posting it |
--json | data in the result. push: { fingerprint, permissions, hostable, roles, plans, grants, manifest, environment, status }; pull: { project, version, fingerprint, permdockVersion, catalog, manifest } |
Push
The request is POST /v1/environments/:env/catalog with the body { fingerprint, catalog, policy?, manifest?, permdockVersion }. The bearer is PERMDOCK_CLOUD_KEY when it is set, otherwise the stored login, which must hold catalog:write (login).
fingerprintiscatalogFingerprint(catalog)frompermdockand equals the catalog's ownfingerprintfield (wire formats). The clock, the CLI version and call sites never change it, so two runs over the same contract produce the same value. The Cloud recomputes it and rejects a mismatch.policyis present whenpermdock.config.tsnames one. It is a PushedPolicy,{ v: 1, fingerprint, scopes?, grants }(wire formats):fingerprintis the code policy's,scopesits declared scope keys, and each grant has the snapshot grant shape pluslimit,validityand the grant's metadata. A grant whose condition is a closure travels asclosure: truewithout its function, and the hosted endpoint denies it, so a permission that depends on a closure should be decided in the application.manifestispermdock.manifest.jsonor the--manifestfile, checked withparseSupabaseManifestbefore anything is sent. An explicit--manifestthat does not exist is a usage error.permdockVersionis the version of the CLI that pushed.cloud pullwarns when it differs from its own.
A hosted policy document names the catalog it was authored against in its catalog field (wire formats).
Before it sends anything, push checks the built catalog against the validation rules, with or without --dry-run. A broken catalog prints every issue with its path and exits 1:
permdock cloud push: the catalog has 2 issues
roles.0.on: role 'admin' is on 'workspace', which is neither a declared scope nor resource
grants.0.permission: grant 'post.delete' is not a declared permission keyWith --json, the error document's reason is invalid_input and data.issues holds the same path: message lines. cloud push --dry-run --json in CI therefore fails on the same catalog the Cloud would refuse.
Pull
cloud pull calls GET /v1/projects/:id/policy (projects API) and then:
- Checks the catalog with
parseCatalogand the manifest withparseSupabaseManifest. - Writes the catalog to the path
collectuses:collect.out, thencatalog.out, thenpermissions.catalog.json. - Writes the manifest to
--manifestorpermdock.manifest.json. A push without a manifest leaves the file alone and prints a warning. - Reads the catalog file back and requires
catalogFingerprintof it to equal the responsefingerprintand the catalog's ownfingerprint. On a mismatch it restores both files to their previous bytes and exits1.
The bearer is PERMDOCK_CLOUD_TOKEN when it is set, otherwise the stored login. With the token and no --project, cloud pull reads GET /v1/projects and uses its one project. A project with nothing pushed answers 404 with the https://permdock.com/problems/policy-not-published problem, and cloud pull exits 1.
Exit codes follow the shared contract: 0 pushed, pulled or --dry-run; 1 the catalog broke a validation rule (invalid_input), the Cloud was unreachable (network_error), answered with a non-2xx status, or sent bytes that failed the fingerprint check; 2 no key, token or login, an unreadable definition module or manifest, or the Cloud rejected the credential with 401 or 403 (auth_required, with permdock login in next). In agent mode, cloud push without --dry-run first asks for the person's confirmation (cloud:write).
In CI
- run: pnpm exec permdock collect --check
- run: pnpm exec permdock cloud push
env:
PERMDOCK_CLOUD_KEY: ${{ secrets.PERMDOCK_CLOUD_KEY }}Push after the deploy that ships the code, so hosted grants authored against the new catalog never reach an instance that runs the old policy.
A job that only reads, such as a repository that consumes another team's published policy, pulls with a read-only token:
- run: pnpm exec permdock cloud pull
env:
PERMDOCK_CLOUD_TOKEN: ${{ secrets.PERMDOCK_CLOUD_TOKEN }}
- run: pnpm exec permdock rls generate --project production --check
env:
PERMDOCK_CLOUD_TOKEN: ${{ secrets.PERMDOCK_CLOUD_TOKEN }}Side effects
What each command may change; side effects explains each one.
| Command | Side effects |
|---|---|
permdock cloud push | network, cloud:write |
permdock cloud pull | network, files |
Why
Publishing is a CLI command, not a build hook. createPermDockPlugin and createPermDockUnplugin stay collect-only because a build that needs a secret and the network fails on forks, in preview builds without credentials and in offline CI, and a catalog published mid-build can describe code that never deploys. A command in the deploy step runs once, with the key the deploy already holds.
Keys and tokens are read only from PERMDOCK_CLOUD_KEY and PERMDOCK_CLOUD_TOKEN, never from a flag, so they do not end up in shell history or CI logs. A push sends the catalog, the code grants and the manifest: no subject and no decision. A leaked push key can change what the Cloud publishes for its environment, but it cannot authenticate anyone or decide anything inside the application. PERMDOCK_CLOUD_TOKEN is read-only and pinned to one environment, so a leaked CI token reads one project's policy and nothing else.
cloud pull writes with the same functions as the offline commands instead of copying the response text, and checks the fingerprint after writing, so a file on disk is either the published catalog or the file that was there before.
Last updated on
login
permdock login, logout and whoami sign a person in to the PermDock Cloud platform issuer with the OAuth device flow or a loopback redirect, store the credentials outside the repository, and revoke them on logout.
supabase
permdock supabase hook generate compiles the app's tableMembershipSource and junctionMembershipSource membership sources into a Supabase Custom Access Token Hook migration.