{"_id":"@cognitiveproof/cawg-trqp-plugin-postgres","_rev":"2-a319bf3256f7db3aff130ccc362621d9","name":"@cognitiveproof/cawg-trqp-plugin-postgres","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@cognitiveproof/cawg-trqp-plugin-postgres","version":"0.1.0","license":"MIT","_id":"@cognitiveproof/cawg-trqp-plugin-postgres@0.1.0","maintainers":[{"name":"mrappard","email":"mrappard@gmail.com"}],"dist":{"shasum":"122d29ddcf2c32379687a8d52ac590d06b8d215f","tarball":"https://registry.npmjs.org/@cognitiveproof/cawg-trqp-plugin-postgres/-/cawg-trqp-plugin-postgres-0.1.0.tgz","fileCount":6,"integrity":"sha512-hG6KCXBs07Ny5Wc93rE87I4Ag/XMuy09dzZcqWgZ91rEM8xI0LXT/E37OANOFSfFRoPeMBgpRWykyFRbGwfRaw==","signatures":[{"sig":"MEYCIQCo4TcdFeObyVa2fRJ/yzv/l1TxlH+1QFlFc463SDL/xgIhAMH4GSb06GVySJIz0Y4otCi8l/lWeV1Xjtp1O2PdtwYt","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11176},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","gitHead":"8826f04d0b5ed79855bbc2b34f138cbaf3a6d2ae","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.typecheck.json"},"_npmUser":{"name":"mrappard","email":"mrappard@gmail.com"},"_npmVersion":"11.12.1","description":"Postgres-backed PolicyService for cawg-trqp-refimpl","directories":{},"_nodeVersion":"25.9.0","dependencies":{"pg":"^8.13.1","@cognitiveproof/cawg-trqp-plugin-types":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.10","@types/pg":"^8.11.10","typescript":"^5.7.2"},"_npmOperationalInternal":{"tmp":"tmp/cawg-trqp-plugin-postgres_0.1.0_1787689392459_0.9562152947148002","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@cognitiveproof/cawg-trqp-plugin-postgres","version":"0.1.1","description":"Postgres-backed PolicyService for cawg-trqp-refimpl","license":"MIT","repository":{"type":"git","url":"git+https://github.com/Cognitive-Proof/cawg-trqp-verifer.git","directory":"plugins/postgres"},"type":"module","main":"dist/index.js","types":"dist/index.d.ts","publishConfig":{"access":"public"},"scripts":{"build":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.typecheck.json","test":"vitest run"},"dependencies":{"@cognitiveproof/cawg-trqp-plugin-types":"^0.1.1","pg":"^8.13.1"},"devDependencies":{"@types/pg":"^8.11.10","typescript":"^5.7.2","vitest":"^4.1.10"},"gitHead":"81d124cf20ef41ece5113506669f6a36acf8dc75","_id":"@cognitiveproof/cawg-trqp-plugin-postgres@0.1.1","bugs":{"url":"https://github.com/Cognitive-Proof/cawg-trqp-verifer/issues"},"homepage":"https://github.com/Cognitive-Proof/cawg-trqp-verifer#readme","_nodeVersion":"20.20.2","_npmVersion":"11.19.1","dist":{"integrity":"sha512-16lNDyH6haAmvL27i4yxV6R3voxrjhyftd3bhQMdAY98CoQJzYRFVrODPLZ6ibXvKh/ey1Od05BXCUzetBpy8w==","shasum":"bfebb8f11f187280fc2eacccb6a7c4b3ea616838","tarball":"https://registry.npmjs.org/@cognitiveproof/cawg-trqp-plugin-postgres/-/cawg-trqp-plugin-postgres-0.1.1.tgz","fileCount":6,"unpackedSize":11481,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@cognitiveproof%2fcawg-trqp-plugin-postgres@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICaAHczQgAr0E03e/wpTYfBbnAadP+Tcu94wFCzHjLt4AiEA1icAQTw4DMen4fQFOV57LSm4EwErG4Gnwtj4q5QyzAc="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:d7cd13d7-e079-4ed0-a921-93c8f11300b0"}},"directories":{},"maintainers":[{"name":"mrappard","email":"mrappard@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cawg-trqp-plugin-postgres_0.1.1_1787876078887_0.8408349386073768"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-25T20:23:12.259Z","modified":"2026-08-28T00:14:39.376Z","0.1.0":"2026-08-25T20:23:12.598Z","0.1.1":"2026-08-28T00:14:39.023Z"},"license":"MIT","description":"Postgres-backed PolicyService for cawg-trqp-refimpl","maintainers":[{"name":"mrappard","email":"mrappard@gmail.com"}],"readme":"# @cognitiveproof/cawg-trqp-plugin-postgres\n\nPostgres-backed `PolicyService` for [`cawg-trqp-refimpl`](../../README.md), using [`pg`](https://www.npmjs.com/package/pg).\n\n## Install\n\n```bash\nnpm install @cognitiveproof/cawg-trqp-plugin-postgres\n```\n\n## Usage\n\n```ts\nimport { Verifier } from \"cawg-trqp-refimpl\";\nimport { PostgresPolicyService } from \"@cognitiveproof/cawg-trqp-plugin-postgres\";\n\nconst verifier = new Verifier({\n  service: new PostgresPolicyService({ uri: process.env.POSTGRES_URI }),\n});\n```\n\n## Schema\n\n```sql\nCREATE TABLE authorizations (\n  id SERIAL PRIMARY KEY,\n  entity_id TEXT NOT NULL,\n  authority_id TEXT NOT NULL,\n  action TEXT NOT NULL,\n  resource TEXT NOT NULL,\n  context JSONB,\n  authorized BOOLEAN NOT NULL,\n  expires TEXT,\n  policy_epoch TEXT,\n  evidence JSONB,\n  reason TEXT,\n  policy_requirements JSONB\n);\nCREATE INDEX ON authorizations (entity_id, authority_id, action, resource);\n\nCREATE TABLE recognitions (\n  id SERIAL PRIMARY KEY,\n  entity_id TEXT NOT NULL,\n  authority_id TEXT NOT NULL,\n  action TEXT NOT NULL,\n  resource TEXT NOT NULL,\n  context JSONB,\n  recognized BOOLEAN NOT NULL,\n  expires TEXT,\n  policy_epoch TEXT,\n  evidence JSONB,\n  reason TEXT\n);\nCREATE INDEX ON recognitions (entity_id, authority_id, action, resource);\n\n-- Single-row table: this reference scaffold reads the first row it finds.\nCREATE TABLE revocations (\n  id SERIAL PRIMARY KEY,\n  revoked_entities JSONB NOT NULL,\n  policy_epoch TEXT,\n  issued_at TEXT,\n  channel TEXT\n);\n```\n\nTable names are configurable via `authorizationsTable` / `recognitionsTable` / `revocationsTable` options.\n\n**Context matching**: candidate rows are fetched by an exact `WHERE` match on `entity_id`/`authority_id`/`action`/`resource` (both tables use this shape — TRQP v2's Recognition Query is scoped the same way Authorization Query is), then filtered in application code so every key in the stored `context` JSONB must match the request's context - the request may carry additional context keys. This intentionally mirrors `MockTRQPService`'s matching semantics rather than a jsonb containment (`@>`) predicate, which would reject a match whenever the request supplies extra context keys the stored row has no opinion on.\n\n## Not implemented in this reference scaffold\n\n- Signed feed-descriptor evidence for the policy/revocation feeds (`feedDescriptorEvidence()` returns `{}`).\n- Connection pool tuning beyond `pg`'s defaults.\n\n## Configuration\n\n```ts\nnew PostgresPolicyService({ uri: \"postgres://user:pass@host:5432/trqp\" }); // default: POSTGRES_URI env var, else postgres://localhost:5432/trqp\n```\n","readmeFilename":"README.md","homepage":"https://github.com/Cognitive-Proof/cawg-trqp-verifer#readme","repository":{"type":"git","url":"git+https://github.com/Cognitive-Proof/cawg-trqp-verifer.git","directory":"plugins/postgres"},"bugs":{"url":"https://github.com/Cognitive-Proof/cawg-trqp-verifer/issues"}}