@opendatalabs/personal-server-ts-core 1.33.8 → 1.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/additions/budget.d.ts +28 -0
- package/dist/additions/budget.d.ts.map +1 -0
- package/dist/additions/budget.js +119 -0
- package/dist/additions/budget.js.map +1 -0
- package/dist/additions/durable.d.ts +64 -0
- package/dist/additions/durable.d.ts.map +1 -0
- package/dist/additions/durable.js +591 -0
- package/dist/additions/durable.js.map +1 -0
- package/dist/additions/first-added.d.ts +32 -48
- package/dist/additions/first-added.d.ts.map +1 -1
- package/dist/additions/first-added.js +68 -123
- package/dist/additions/first-added.js.map +1 -1
- package/dist/additions/index.d.ts +3 -0
- package/dist/additions/index.d.ts.map +1 -1
- package/dist/additions/index.js +3 -0
- package/dist/additions/index.js.map +1 -1
- package/dist/additions/ledger-store.js +1 -1
- package/dist/additions/record-rules.d.ts.map +1 -1
- package/dist/additions/record-rules.js +7 -0
- package/dist/additions/record-rules.js.map +1 -1
- package/dist/additions/summary.d.ts +88 -1
- package/dist/additions/summary.d.ts.map +1 -1
- package/dist/additions/summary.js +173 -8
- package/dist/additions/summary.js.map +1 -1
- package/dist/additions/version-inventory.d.ts +80 -0
- package/dist/additions/version-inventory.d.ts.map +1 -0
- package/dist/additions/version-inventory.js +232 -0
- package/dist/additions/version-inventory.js.map +1 -0
- package/dist/api/index.d.ts +70 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +506 -79
- package/dist/api/index.js.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/request.d.ts +6 -0
- package/dist/auth/request.d.ts.map +1 -1
- package/dist/auth/request.js +66 -4
- package/dist/auth/request.js.map +1 -1
- package/dist/contracts/data.d.ts +54 -8
- package/dist/contracts/data.d.ts.map +1 -1
- package/dist/contracts/data.js +178 -35
- package/dist/contracts/data.js.map +1 -1
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/derivatives/registration.d.ts +0 -5
- package/dist/derivatives/registration.d.ts.map +1 -1
- package/dist/derivatives/registration.js +2 -1
- package/dist/derivatives/registration.js.map +1 -1
- package/dist/errors/pdpp-catalog.d.ts +36 -0
- package/dist/errors/pdpp-catalog.d.ts.map +1 -0
- package/dist/errors/pdpp-catalog.js +86 -0
- package/dist/errors/pdpp-catalog.js.map +1 -0
- package/dist/grants/index.d.ts +2 -0
- package/dist/grants/index.d.ts.map +1 -1
- package/dist/grants/index.js +4 -0
- package/dist/grants/index.js.map +1 -1
- package/dist/grants/pdpp-binding-store.d.ts +89 -0
- package/dist/grants/pdpp-binding-store.d.ts.map +1 -0
- package/dist/grants/pdpp-binding-store.js +112 -0
- package/dist/grants/pdpp-binding-store.js.map +1 -0
- package/dist/grants/pdpp-binding.d.ts +169 -0
- package/dist/grants/pdpp-binding.d.ts.map +1 -0
- package/dist/grants/pdpp-binding.js +236 -0
- package/dist/grants/pdpp-binding.js.map +1 -0
- package/dist/legacy-projection/bindings.d.ts +28 -1
- package/dist/legacy-projection/bindings.d.ts.map +1 -1
- package/dist/legacy-projection/bindings.js +622 -189
- package/dist/legacy-projection/bindings.js.map +1 -1
- package/dist/legacy-projection/claude-source-record.d.ts +22 -0
- package/dist/legacy-projection/claude-source-record.d.ts.map +1 -0
- package/dist/legacy-projection/claude-source-record.js +360 -0
- package/dist/legacy-projection/claude-source-record.js.map +1 -0
- package/dist/legacy-projection/declared-text.d.ts +41 -0
- package/dist/legacy-projection/declared-text.d.ts.map +1 -0
- package/dist/legacy-projection/declared-text.js +199 -0
- package/dist/legacy-projection/declared-text.js.map +1 -0
- package/dist/legacy-projection/github-browser-bindings.d.ts.map +1 -1
- package/dist/legacy-projection/github-browser-bindings.js +89 -5
- package/dist/legacy-projection/github-browser-bindings.js.map +1 -1
- package/dist/legacy-projection/github-legacy-fields.d.ts +6 -0
- package/dist/legacy-projection/github-legacy-fields.d.ts.map +1 -0
- package/dist/legacy-projection/github-legacy-fields.js +202 -0
- package/dist/legacy-projection/github-legacy-fields.js.map +1 -0
- package/dist/legacy-projection/index.d.ts +5 -1
- package/dist/legacy-projection/index.d.ts.map +1 -1
- package/dist/legacy-projection/index.js +55 -1
- package/dist/legacy-projection/index.js.map +1 -1
- package/dist/legacy-projection/oura-browser-bindings.d.ts.map +1 -1
- package/dist/legacy-projection/oura-browser-bindings.js +43 -41
- package/dist/legacy-projection/oura-browser-bindings.js.map +1 -1
- package/dist/legacy-projection/types.d.ts +38 -2
- package/dist/legacy-projection/types.d.ts.map +1 -1
- package/dist/mcp/read-client.d.ts.map +1 -1
- package/dist/mcp/read-client.js +10 -1
- package/dist/mcp/read-client.js.map +1 -1
- package/dist/mcp/resources.d.ts.map +1 -1
- package/dist/mcp/resources.js +3 -0
- package/dist/mcp/resources.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +11 -2
- package/dist/mcp/tools.js.map +1 -1
- package/dist/pdpp/approval.d.ts +271 -0
- package/dist/pdpp/approval.d.ts.map +1 -0
- package/dist/pdpp/approval.js +467 -0
- package/dist/pdpp/approval.js.map +1 -0
- package/dist/pdpp/client-identity.d.ts +88 -0
- package/dist/pdpp/client-identity.d.ts.map +1 -0
- package/dist/pdpp/client-identity.js +196 -0
- package/dist/pdpp/client-identity.js.map +1 -0
- package/dist/pdpp/client-metadata.d.ts +95 -0
- package/dist/pdpp/client-metadata.d.ts.map +1 -0
- package/dist/pdpp/client-metadata.js +96 -0
- package/dist/pdpp/client-metadata.js.map +1 -0
- package/dist/pdpp/commitments.d.ts +75 -0
- package/dist/pdpp/commitments.d.ts.map +1 -0
- package/dist/pdpp/commitments.js +113 -0
- package/dist/pdpp/commitments.js.map +1 -0
- package/dist/pdpp/declaration.d.ts +118 -0
- package/dist/pdpp/declaration.d.ts.map +1 -0
- package/dist/pdpp/declaration.js +836 -0
- package/dist/pdpp/declaration.js.map +1 -0
- package/dist/pdpp/index.d.ts +37 -0
- package/dist/pdpp/index.d.ts.map +1 -0
- package/dist/pdpp/index.js +23 -0
- package/dist/pdpp/index.js.map +1 -0
- package/dist/pdpp/issuance.d.ts +126 -0
- package/dist/pdpp/issuance.d.ts.map +1 -0
- package/dist/pdpp/issuance.js +180 -0
- package/dist/pdpp/issuance.js.map +1 -0
- package/dist/pdpp/pkce.d.ts +53 -0
- package/dist/pdpp/pkce.d.ts.map +1 -0
- package/dist/pdpp/pkce.js +109 -0
- package/dist/pdpp/pkce.js.map +1 -0
- package/dist/pdpp/redirect.d.ts +60 -0
- package/dist/pdpp/redirect.d.ts.map +1 -0
- package/dist/pdpp/redirect.js +125 -0
- package/dist/pdpp/redirect.js.map +1 -0
- package/dist/pdpp/resolve.d.ts +109 -0
- package/dist/pdpp/resolve.d.ts.map +1 -0
- package/dist/pdpp/resolve.js +393 -0
- package/dist/pdpp/resolve.js.map +1 -0
- package/dist/pdpp/review.d.ts +280 -0
- package/dist/pdpp/review.d.ts.map +1 -0
- package/dist/pdpp/review.js +205 -0
- package/dist/pdpp/review.js.map +1 -0
- package/dist/pdpp/selection.d.ts +50 -0
- package/dist/pdpp/selection.d.ts.map +1 -0
- package/dist/pdpp/selection.js +442 -0
- package/dist/pdpp/selection.js.map +1 -0
- package/dist/pdpp/store.d.ts +228 -0
- package/dist/pdpp/store.d.ts.map +1 -0
- package/dist/pdpp/store.js +542 -0
- package/dist/pdpp/store.js.map +1 -0
- package/dist/pdpp/tokens.d.ts +181 -0
- package/dist/pdpp/tokens.d.ts.map +1 -0
- package/dist/pdpp/tokens.js +419 -0
- package/dist/pdpp/tokens.js.map +1 -0
- package/dist/pdpp/types.d.ts +441 -0
- package/dist/pdpp/types.d.ts.map +1 -0
- package/dist/pdpp/types.js +61 -0
- package/dist/pdpp/types.js.map +1 -0
- package/dist/pdpp-version.d.ts +28 -0
- package/dist/pdpp-version.d.ts.map +1 -0
- package/dist/pdpp-version.js +28 -0
- package/dist/pdpp-version.js.map +1 -0
- package/dist/policy/data-read.d.ts +24 -0
- package/dist/policy/data-read.d.ts.map +1 -1
- package/dist/policy/data-read.js +60 -3
- package/dist/policy/data-read.js.map +1 -1
- package/dist/policy/data-write.d.ts.map +1 -1
- package/dist/policy/data-write.js +3 -0
- package/dist/policy/data-write.js.map +1 -1
- package/dist/policy/index.d.ts +1 -0
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/index.js +1 -0
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/reserved-scopes.d.ts +3 -0
- package/dist/policy/reserved-scopes.d.ts.map +1 -0
- package/dist/policy/reserved-scopes.js +5 -0
- package/dist/policy/reserved-scopes.js.map +1 -0
- package/dist/ports/index.d.ts +63 -0
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js.map +1 -1
- package/dist/ports/pdpp-auth.d.ts +129 -0
- package/dist/ports/pdpp-auth.d.ts.map +1 -0
- package/dist/ports/pdpp-auth.js +60 -0
- package/dist/ports/pdpp-auth.js.map +1 -0
- package/dist/ports/pdpp-auth.test-utils.d.ts +9 -0
- package/dist/ports/pdpp-auth.test-utils.d.ts.map +1 -0
- package/dist/ports/pdpp-auth.test-utils.js +18 -0
- package/dist/ports/pdpp-auth.test-utils.js.map +1 -0
- package/dist/schemas/server-config.d.ts +44 -0
- package/dist/schemas/server-config.d.ts.map +1 -1
- package/dist/schemas/server-config.js +91 -0
- package/dist/schemas/server-config.js.map +1 -1
- package/dist/signing/request-signer.d.ts +2 -0
- package/dist/signing/request-signer.d.ts.map +1 -1
- package/dist/signing/request-signer.js +1 -0
- package/dist/signing/request-signer.js.map +1 -1
- package/dist/storage/adapters/interface.d.ts +3 -0
- package/dist/storage/adapters/interface.d.ts.map +1 -1
- package/dist/storage/adapters/vana-audience.d.ts +12 -0
- package/dist/storage/adapters/vana-audience.d.ts.map +1 -0
- package/dist/storage/adapters/vana-audience.js +72 -0
- package/dist/storage/adapters/vana-audience.js.map +1 -0
- package/dist/storage/adapters/vana.d.ts +2 -0
- package/dist/storage/adapters/vana.d.ts.map +1 -1
- package/dist/storage/adapters/vana.js +53 -20
- package/dist/storage/adapters/vana.js.map +1 -1
- package/dist/storage/canonical-legacy-projection.d.ts +262 -0
- package/dist/storage/canonical-legacy-projection.d.ts.map +1 -0
- package/dist/storage/canonical-legacy-projection.js +761 -0
- package/dist/storage/canonical-legacy-projection.js.map +1 -0
- package/dist/storage/index/manager.d.ts +29 -2
- package/dist/storage/index/manager.d.ts.map +1 -1
- package/dist/storage/index/schema.d.ts +1 -1
- package/dist/storage/index/schema.js +1 -1
- package/dist/storage/index/types.d.ts +7 -1
- package/dist/storage/index/types.d.ts.map +1 -1
- package/dist/storage/legacy-projection.d.ts +13 -10
- package/dist/storage/legacy-projection.d.ts.map +1 -1
- package/dist/storage/legacy-projection.js +269 -74
- package/dist/storage/legacy-projection.js.map +1 -1
- package/dist/storage/legacy-scope-coverage-exceptions.d.ts +8 -0
- package/dist/storage/legacy-scope-coverage-exceptions.d.ts.map +1 -0
- package/dist/storage/legacy-scope-coverage-exceptions.js +10 -0
- package/dist/storage/legacy-scope-coverage-exceptions.js.map +1 -0
- package/dist/storage/legacy-scope-coverage.d.ts +53 -0
- package/dist/storage/legacy-scope-coverage.d.ts.map +1 -0
- package/dist/storage/legacy-scope-coverage.js +403 -0
- package/dist/storage/legacy-scope-coverage.js.map +1 -0
- package/dist/storage/legacy-scope-entity-keys.d.ts +4 -0
- package/dist/storage/legacy-scope-entity-keys.d.ts.map +1 -0
- package/dist/storage/legacy-scope-entity-keys.js +92 -0
- package/dist/storage/legacy-scope-entity-keys.js.map +1 -0
- package/dist/storage/legacy-scope-view.d.ts +154 -0
- package/dist/storage/legacy-scope-view.d.ts.map +1 -0
- package/dist/storage/legacy-scope-view.js +735 -0
- package/dist/storage/legacy-scope-view.js.map +1 -0
- package/dist/storage/pdpp-records/completion.d.ts +91 -0
- package/dist/storage/pdpp-records/completion.d.ts.map +1 -0
- package/dist/storage/pdpp-records/completion.js +170 -0
- package/dist/storage/pdpp-records/completion.js.map +1 -0
- package/dist/storage/pdpp-records/cursor.d.ts +41 -0
- package/dist/storage/pdpp-records/cursor.d.ts.map +1 -0
- package/dist/storage/pdpp-records/cursor.js +49 -0
- package/dist/storage/pdpp-records/cursor.js.map +1 -0
- package/dist/storage/pdpp-records/declaration-witness.d.ts +58 -0
- package/dist/storage/pdpp-records/declaration-witness.d.ts.map +1 -0
- package/dist/storage/pdpp-records/declaration-witness.js +230 -0
- package/dist/storage/pdpp-records/declaration-witness.js.map +1 -0
- package/dist/storage/pdpp-records/enforcement.d.ts +52 -0
- package/dist/storage/pdpp-records/enforcement.d.ts.map +1 -0
- package/dist/storage/pdpp-records/enforcement.js +116 -0
- package/dist/storage/pdpp-records/enforcement.js.map +1 -0
- package/dist/storage/pdpp-records/index.d.ts +5 -0
- package/dist/storage/pdpp-records/index.d.ts.map +1 -0
- package/dist/storage/pdpp-records/index.js +5 -0
- package/dist/storage/pdpp-records/index.js.map +1 -0
- package/dist/storage/pdpp-records/ingest-plan.d.ts +39 -0
- package/dist/storage/pdpp-records/ingest-plan.d.ts.map +1 -0
- package/dist/storage/pdpp-records/ingest-plan.js +103 -0
- package/dist/storage/pdpp-records/ingest-plan.js.map +1 -0
- package/dist/storage/pdpp-records/interface.d.ts +104 -0
- package/dist/storage/pdpp-records/interface.d.ts.map +1 -0
- package/dist/storage/pdpp-records/interface.js +2 -0
- package/dist/storage/pdpp-records/interface.js.map +1 -0
- package/dist/storage/pdpp-records/memory-store.d.ts +9 -0
- package/dist/storage/pdpp-records/memory-store.d.ts.map +1 -0
- package/dist/storage/pdpp-records/memory-store.js +466 -0
- package/dist/storage/pdpp-records/memory-store.js.map +1 -0
- package/dist/storage/pdpp-records/portable.d.ts +9 -0
- package/dist/storage/pdpp-records/portable.d.ts.map +1 -0
- package/dist/storage/pdpp-records/portable.js +8 -0
- package/dist/storage/pdpp-records/portable.js.map +1 -0
- package/dist/storage/pdpp-records/read-port.d.ts +44 -0
- package/dist/storage/pdpp-records/read-port.d.ts.map +1 -0
- package/dist/storage/pdpp-records/read-port.js +22 -0
- package/dist/storage/pdpp-records/read-port.js.map +1 -0
- package/dist/storage/pdpp-records/record-key.d.ts +52 -0
- package/dist/storage/pdpp-records/record-key.d.ts.map +1 -0
- package/dist/storage/pdpp-records/record-key.js +97 -0
- package/dist/storage/pdpp-records/record-key.js.map +1 -0
- package/dist/storage/pdpp-records/schema.d.ts +41 -0
- package/dist/storage/pdpp-records/schema.d.ts.map +1 -0
- package/dist/storage/pdpp-records/schema.js +153 -0
- package/dist/storage/pdpp-records/schema.js.map +1 -0
- package/dist/storage/pdpp-records/stream-declaration.d.ts +88 -0
- package/dist/storage/pdpp-records/stream-declaration.d.ts.map +1 -0
- package/dist/storage/pdpp-records/stream-declaration.js +57 -0
- package/dist/storage/pdpp-records/stream-declaration.js.map +1 -0
- package/dist/storage/pdpp-records/types.d.ts +138 -0
- package/dist/storage/pdpp-records/types.d.ts.map +1 -0
- package/dist/storage/pdpp-records/types.js +38 -0
- package/dist/storage/pdpp-records/types.js.map +1 -0
- package/dist/sync/data-point-feed.d.ts +3 -0
- package/dist/sync/data-point-feed.d.ts.map +1 -1
- package/dist/sync/data-point-feed.js +17 -1
- package/dist/sync/data-point-feed.js.map +1 -1
- package/dist/sync/delete-data-port.d.ts +2 -0
- package/dist/sync/delete-data-port.d.ts.map +1 -1
- package/dist/sync/delete-data-port.js +1 -1
- package/dist/sync/delete-data-port.js.map +1 -1
- package/dist/sync/engine/sync-manager.d.ts.map +1 -1
- package/dist/sync/engine/sync-manager.js +5 -2
- package/dist/sync/engine/sync-manager.js.map +1 -1
- package/dist/sync/index.d.ts +3 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +4 -0
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/pdpp-import.d.ts +192 -0
- package/dist/sync/pdpp-import.d.ts.map +1 -0
- package/dist/sync/pdpp-import.js +441 -0
- package/dist/sync/pdpp-import.js.map +1 -0
- package/dist/sync/scope-deletions.d.ts +10 -0
- package/dist/sync/scope-deletions.d.ts.map +1 -1
- package/dist/sync/scope-deletions.js +40 -7
- package/dist/sync/scope-deletions.js.map +1 -1
- package/dist/sync/workers/download.d.ts +14 -0
- package/dist/sync/workers/download.d.ts.map +1 -1
- package/dist/sync/workers/download.js +149 -13
- package/dist/sync/workers/download.js.map +1 -1
- package/dist/sync/workers/upload.d.ts +2 -0
- package/dist/sync/workers/upload.d.ts.map +1 -1
- package/dist/sync/workers/upload.js +7 -0
- package/dist/sync/workers/upload.js.map +1 -1
- package/dist/test-utils/memory-storage.d.ts +1 -1
- package/dist/test-utils/memory-storage.d.ts.map +1 -1
- package/dist/test-utils/memory-storage.js +11 -5
- package/dist/test-utils/memory-storage.js.map +1 -1
- package/package.json +54 -4
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authorization sessions and authenticated owner approval.
|
|
3
|
+
*
|
|
4
|
+
* This is the module that decides whether a consent decision is real. The
|
|
5
|
+
* threat it exists to stop is an approval that looks right — correct session,
|
|
6
|
+
* correct review digest, arriving from the first-party consent UI — but that
|
|
7
|
+
* no authenticated owner actually made.
|
|
8
|
+
*
|
|
9
|
+
* The rule: **affiliation is not authentication.** The AS does not accept an
|
|
10
|
+
* approval because it came from an allowlisted origin, a first-party console,
|
|
11
|
+
* a shared UI/server secret, or a signed assertion from the consent broker
|
|
12
|
+
* saying "the owner agreed". Each of those authenticates a *channel* or
|
|
13
|
+
* delegates the decision to a browser-reachable component; compromise it and
|
|
14
|
+
* it mints approvals for any subject. Instead, the owner authenticates to the
|
|
15
|
+
* PS itself, and the resulting owner token — resolved through the same token
|
|
16
|
+
* service the RS uses — is what authorizes the decision. The consent UI
|
|
17
|
+
* forwards that token; it can never substitute for it.
|
|
18
|
+
*
|
|
19
|
+
* Two independent checks must both pass, and neither implies the other:
|
|
20
|
+
*
|
|
21
|
+
* 1. The caller presents an active token with `pdpp_token_kind: "owner"`
|
|
22
|
+
* whose `subject_id` equals the session's subject. Possession of the
|
|
23
|
+
* session id is not authority over it.
|
|
24
|
+
* 2. The presented `review_digest` matches a re-derivation over what is
|
|
25
|
+
* about to be issued (§7 staleness). Authenticating the owner does not
|
|
26
|
+
* excuse approving something other than what they reviewed.
|
|
27
|
+
*/
|
|
28
|
+
import { type ConsentReviewModel, type RequesterIdentity } from "./review.js";
|
|
29
|
+
import { type ConsentEvidence } from "./issuance.js";
|
|
30
|
+
import { type InstanceInventory, type OwnerChoices } from "./resolve.js";
|
|
31
|
+
import type { PdppAuthStore } from "./store.js";
|
|
32
|
+
import type { PdppTokenService } from "./tokens.js";
|
|
33
|
+
import type { DeclarationSnapshot, Grant, OwnerConditions, RecipientTerms, SelectionRequest } from "./types.js";
|
|
34
|
+
/** How long an owner has to act on a consent screen before it goes stale. */
|
|
35
|
+
export declare const REVIEW_SESSION_TTL_SECONDS: number;
|
|
36
|
+
export type SessionState = "pending" | "approved" | "denied";
|
|
37
|
+
export interface AuthorizationSession {
|
|
38
|
+
session_id: string;
|
|
39
|
+
/** The subject this session belongs to. An approval must authenticate as this. */
|
|
40
|
+
subject_id: string;
|
|
41
|
+
request: SelectionRequest;
|
|
42
|
+
snapshot: DeclarationSnapshot;
|
|
43
|
+
requester: RequesterIdentity;
|
|
44
|
+
redirect_uri: string;
|
|
45
|
+
state_param?: string;
|
|
46
|
+
/** RFC 7636 challenge, carried to the authorization code minted on approval. */
|
|
47
|
+
code_challenge?: string;
|
|
48
|
+
code_challenge_method?: string;
|
|
49
|
+
expires_at: string;
|
|
50
|
+
status: SessionState;
|
|
51
|
+
/** AS-policy grant expiry carried into issuance. */
|
|
52
|
+
grant_expires_at?: string;
|
|
53
|
+
stream_descriptions?: Record<string, string>;
|
|
54
|
+
/** The owner's optional reason for denying. Never sent to the client. */
|
|
55
|
+
denial_reason?: string;
|
|
56
|
+
}
|
|
57
|
+
export type ApprovalFailureCode =
|
|
58
|
+
/** No owner token, an inactive one, a client token, or the wrong subject. */
|
|
59
|
+
"unauthorized" | "session_not_found" | "stale_review" | "ai_training_consent_required"
|
|
60
|
+
/** The session is already decided. Not a v0.2 refusal — see below. */
|
|
61
|
+
| "access_denied"
|
|
62
|
+
/**
|
|
63
|
+
* v0.2: the owner's choices cannot satisfy the request's own requirements —
|
|
64
|
+
* a declined required stream, an unmet required minimum, or an approval with
|
|
65
|
+
* no stream left. PR #1 names `access_denied` as the OAuth error for this,
|
|
66
|
+
* but it is deliberately a *separate* Core code from the already-decided
|
|
67
|
+
* `access_denied` above: the two want different HTTP statuses and different
|
|
68
|
+
* consent-UI handling (adjust your choices vs. start over), and collapsing
|
|
69
|
+
* them changed the status of the existing session-state case.
|
|
70
|
+
*/
|
|
71
|
+
| "selection_refused"
|
|
72
|
+
/**
|
|
73
|
+
* v0.2: an owner condition on purpose or retention the recipient's authority
|
|
74
|
+
* does not cover. Separate from `selection_refused` because the resolution
|
|
75
|
+
* differs: the owner can adjust a selection themselves, but only the
|
|
76
|
+
* recipient can accept a term.
|
|
77
|
+
*/
|
|
78
|
+
| "recipient_terms_unsupported" | "unsupported_instance_fan_in" | "invalid_request";
|
|
79
|
+
export interface ApprovalFailure {
|
|
80
|
+
code: ApprovalFailureCode;
|
|
81
|
+
message: string;
|
|
82
|
+
}
|
|
83
|
+
export type ApprovalResult = {
|
|
84
|
+
ok: true;
|
|
85
|
+
grant: Grant;
|
|
86
|
+
consentEvidence: ConsentEvidence;
|
|
87
|
+
} | {
|
|
88
|
+
ok: false;
|
|
89
|
+
failure: ApprovalFailure;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* In-memory pending-session store. Sessions are short-lived and pre-decision,
|
|
93
|
+
* so they hold no issued authority — losing them on restart costs an owner a
|
|
94
|
+
* re-click, not a grant. Issued grants and tokens go to SQLite, where
|
|
95
|
+
* durability actually matters.
|
|
96
|
+
*/
|
|
97
|
+
export declare class AuthorizationSessionStore {
|
|
98
|
+
private readonly sessions;
|
|
99
|
+
create(input: {
|
|
100
|
+
subjectId: string;
|
|
101
|
+
request: SelectionRequest;
|
|
102
|
+
snapshot: DeclarationSnapshot;
|
|
103
|
+
requester: RequesterIdentity;
|
|
104
|
+
redirectUri: string;
|
|
105
|
+
stateParam?: string;
|
|
106
|
+
codeChallenge?: string;
|
|
107
|
+
codeChallengeMethod?: string;
|
|
108
|
+
grantExpiresAt?: string;
|
|
109
|
+
streamDescriptions?: Record<string, string>;
|
|
110
|
+
now?: Date;
|
|
111
|
+
}): AuthorizationSession;
|
|
112
|
+
get(sessionId: string): AuthorizationSession | null;
|
|
113
|
+
setStatus(sessionId: string, status: SessionState): void;
|
|
114
|
+
/**
|
|
115
|
+
* Retain the owner's reason for denying, beside the denial itself.
|
|
116
|
+
*
|
|
117
|
+
* Kept on the session rather than in the grant store because there is no
|
|
118
|
+
* grant: a denial produces no authorization, and the reason is the owner's
|
|
119
|
+
* note about a decision, not a term of one.
|
|
120
|
+
*/
|
|
121
|
+
setDenialReason(sessionId: string, reason: string): void;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* A stream the owner must pick an instance for before the review can resolve.
|
|
125
|
+
*
|
|
126
|
+
* §6 is strict that omitting `instance_ids` never means fan-in, so a stream
|
|
127
|
+
* with several eligible handles and none named is a decision only the owner
|
|
128
|
+
* can make. Surfacing the candidates as first-class review data is what turns
|
|
129
|
+
* that from a dead-end resolution failure into a consent step: the UI renders
|
|
130
|
+
* the choice, the owner picks, and the pick flows back through
|
|
131
|
+
* `instanceChoices` on the next review fetch and on approval.
|
|
132
|
+
*/
|
|
133
|
+
export interface InstanceChoice {
|
|
134
|
+
stream: string;
|
|
135
|
+
candidates: string[];
|
|
136
|
+
}
|
|
137
|
+
export interface ReviewFetchResult {
|
|
138
|
+
session_id: string;
|
|
139
|
+
/** Present only once every stream resolves. Absent while a choice is pending. */
|
|
140
|
+
review?: ConsentReviewModel;
|
|
141
|
+
/**
|
|
142
|
+
* Non-empty when the owner must choose instance handles before there is a
|
|
143
|
+
* decision to review. The UI collects these and re-fetches with the picks.
|
|
144
|
+
*/
|
|
145
|
+
instance_choice_required?: InstanceChoice[];
|
|
146
|
+
expires_at: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Build the review an authenticated owner sees.
|
|
150
|
+
*
|
|
151
|
+
* Resolution runs here against current inventory, so the digest the owner is
|
|
152
|
+
* handed reflects the world as it is right now. If it changes before they
|
|
153
|
+
* approve, `approveAuthorization` will re-derive a different digest and reject.
|
|
154
|
+
*/
|
|
155
|
+
export declare function fetchReview(input: {
|
|
156
|
+
sessions: AuthorizationSessionStore;
|
|
157
|
+
tokens: PdppTokenService;
|
|
158
|
+
sessionId: string;
|
|
159
|
+
ownerToken: string | undefined;
|
|
160
|
+
inventory: InstanceInventory;
|
|
161
|
+
/** The owner's instance picks, keyed by stream, from a prior choice step. */
|
|
162
|
+
instanceChoices?: Record<string, string[]>;
|
|
163
|
+
/**
|
|
164
|
+
* The owner's v0.2 narrowing so far. The review re-resolves against it, so
|
|
165
|
+
* the surface always shows the *current* proposal and its digest — which is
|
|
166
|
+
* what the owner then approves. A narrowing that would refuse issuance
|
|
167
|
+
* surfaces here as a failure rather than at approval, so the owner learns
|
|
168
|
+
* their choice is incompatible while they can still change it.
|
|
169
|
+
*/
|
|
170
|
+
ownerChoices?: OwnerChoices;
|
|
171
|
+
/** v0.2: conditions the owner attached beyond narrowing the data. */
|
|
172
|
+
ownerConditions?: OwnerConditions;
|
|
173
|
+
/** v0.2: standing terms the recipient authorized, when the AS tracks them. */
|
|
174
|
+
standingTerms?: RecipientTerms;
|
|
175
|
+
/**
|
|
176
|
+
* When given, the review lists this requesting client's other active
|
|
177
|
+
* grants for this owner, so the consent surface can say what is already
|
|
178
|
+
* shared. Approval itself is unaffected either way.
|
|
179
|
+
*/
|
|
180
|
+
store?: PdppAuthStore;
|
|
181
|
+
/**
|
|
182
|
+
* Optional owner-token instance scope for `existing_grants`. When present,
|
|
183
|
+
* only grants wholly contained by this scope are included in the review.
|
|
184
|
+
*/
|
|
185
|
+
existingGrantInstanceIds?: string[];
|
|
186
|
+
now?: Date;
|
|
187
|
+
}): {
|
|
188
|
+
ok: true;
|
|
189
|
+
result: ReviewFetchResult;
|
|
190
|
+
} | {
|
|
191
|
+
ok: false;
|
|
192
|
+
failure: ApprovalFailure;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Approve an authorization: authenticate the owner, then issue.
|
|
196
|
+
*
|
|
197
|
+
* Order is deliberate. Authentication runs before anything else, so an
|
|
198
|
+
* unauthenticated caller cannot learn from the error whether their digest was
|
|
199
|
+
* fresh — a spoofed approval with a perfectly valid digest gets the same
|
|
200
|
+
* `unauthorized` as one with a garbage digest.
|
|
201
|
+
*
|
|
202
|
+
* This function does not mark the session `"approved"` — it only decides
|
|
203
|
+
* whether the review is valid and computes what to issue. The session
|
|
204
|
+
* transitions to `"approved"` only once the caller has durably persisted the
|
|
205
|
+
* grant and its authorization code (see `pdpp-auth.ts`'s approve route). A
|
|
206
|
+
* session marked approved before that write lands would leave a caller whose
|
|
207
|
+
* persistence failed with no way to retry: the session is already terminal
|
|
208
|
+
* (`status !== "pending"` above), so a retry of the same reviewed approval
|
|
209
|
+
* would be rejected as already-decided even though nothing durable exists.
|
|
210
|
+
*/
|
|
211
|
+
export declare function approveAuthorization(input: {
|
|
212
|
+
sessions: AuthorizationSessionStore;
|
|
213
|
+
tokens: PdppTokenService;
|
|
214
|
+
sessionId: string;
|
|
215
|
+
ownerToken: string | undefined;
|
|
216
|
+
reviewDigest: string;
|
|
217
|
+
inventory: InstanceInventory;
|
|
218
|
+
/**
|
|
219
|
+
* The owner's instance picks, which must match the ones the review was
|
|
220
|
+
* rendered with. They feed resolution, so they land inside the recomputed
|
|
221
|
+
* digest — a different pick than the owner reviewed fails as stale rather
|
|
222
|
+
* than silently issuing a grant over another instance.
|
|
223
|
+
*/
|
|
224
|
+
instanceChoices?: Record<string, string[]>;
|
|
225
|
+
/**
|
|
226
|
+
* The owner's v0.2 narrowing, which must match the narrowing the review was
|
|
227
|
+
* rendered with. Like `instanceChoices`, it feeds resolution and so lands
|
|
228
|
+
* inside the recomputed digest: a narrowing other than the reviewed one
|
|
229
|
+
* fails as stale rather than silently issuing a different grant.
|
|
230
|
+
*/
|
|
231
|
+
ownerChoices?: OwnerChoices;
|
|
232
|
+
/**
|
|
233
|
+
* The owner's v0.2 conditions and the standing terms that may cover them.
|
|
234
|
+
* These feed commitment resolution, whose output is a digest field, so a
|
|
235
|
+
* commitment other than the reviewed one fails as stale.
|
|
236
|
+
*/
|
|
237
|
+
ownerConditions?: OwnerConditions;
|
|
238
|
+
standingTerms?: RecipientTerms;
|
|
239
|
+
explicitAiTrainingConsent?: boolean;
|
|
240
|
+
now?: Date;
|
|
241
|
+
}): ApprovalResult;
|
|
242
|
+
/**
|
|
243
|
+
* Deny an authorization. Terminal, and retains no consent evidence — there is
|
|
244
|
+
* nothing the owner consented to, so there is nothing to hold evidence of.
|
|
245
|
+
*/
|
|
246
|
+
export declare function denyAuthorization(input: {
|
|
247
|
+
sessions: AuthorizationSessionStore;
|
|
248
|
+
tokens: PdppTokenService;
|
|
249
|
+
sessionId: string;
|
|
250
|
+
ownerToken: string | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* The owner's optional free-text reason for refusing.
|
|
253
|
+
*
|
|
254
|
+
* Retained with the denial, and deliberately NOT forwarded to the client:
|
|
255
|
+
* the OAuth binding answers a denial with `access_denied` and nothing more,
|
|
256
|
+
* so a reason that reached the requester would turn an optional courtesy
|
|
257
|
+
* into a disclosure the owner did not intend. It exists so the owner's own
|
|
258
|
+
* record of the decision says why.
|
|
259
|
+
*
|
|
260
|
+
* A consent surface must not offer a box whose contents are discarded. The
|
|
261
|
+
* parameter exists so the control on the screen is real.
|
|
262
|
+
*/
|
|
263
|
+
reason?: string;
|
|
264
|
+
now?: Date;
|
|
265
|
+
}): {
|
|
266
|
+
ok: true;
|
|
267
|
+
} | {
|
|
268
|
+
ok: false;
|
|
269
|
+
failure: ApprovalFailure;
|
|
270
|
+
};
|
|
271
|
+
//# sourceMappingURL=approval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/pdpp/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EACV,mBAAmB,EACnB,KAAK,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,6EAA6E;AAC7E,eAAO,MAAM,0BAA0B,QAAU,CAAC;AAElD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE7D,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB,oDAAoD;I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