@peac/schema 0.9.18
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/README.md +23 -0
- package/dist/constants.d.ts +28 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +32 -0
- package/dist/constants.js.map +1 -0
- package/dist/control.d.ts +155 -0
- package/dist/control.d.ts.map +1 -0
- package/dist/control.js +9 -0
- package/dist/control.js.map +1 -0
- package/dist/envelope.d.ts +62 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +9 -0
- package/dist/envelope.js.map +1 -0
- package/dist/errors.d.ts +134 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +51 -0
- package/dist/errors.js.map +1 -0
- package/dist/evidence.d.ts +267 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +8 -0
- package/dist/evidence.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/normalize.d.ts +92 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +102 -0
- package/dist/normalize.js.map +1 -0
- package/dist/schemas.d.ts +3 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +7 -0
- package/dist/schemas.js.map +1 -0
- package/dist/subject.d.ts +111 -0
- package/dist/subject.d.ts.map +1 -0
- package/dist/subject.js +9 -0
- package/dist/subject.js.map +1 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/validators.d.ts +656 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +290 -0
- package/dist/validators.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @peac/schema
|
|
2
|
+
|
|
3
|
+
PEAC Protocol JSON schemas, OpenAPI specs, and TypeScript types
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @peac/schema
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Documentation
|
|
12
|
+
|
|
13
|
+
See [peacprotocol.org](https://peacprotocol.org) for full documentation.
|
|
14
|
+
|
|
15
|
+
## License
|
|
16
|
+
|
|
17
|
+
Apache-2.0
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
PEAC Protocol is an open source project stewarded by Originary and community contributors.
|
|
22
|
+
|
|
23
|
+
[Originary](https://www.originary.xyz) | [Docs](https://peacprotocol.org) | [GitHub](https://github.com/peacprotocol/peac)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire format constants - FROZEN
|
|
3
|
+
*
|
|
4
|
+
* These constants are now sourced from @peac/kernel
|
|
5
|
+
* (normative source: specs/kernel/constants.json)
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Wire format version - FROZEN at 0.9 with v1.0-equivalent semantics
|
|
9
|
+
* Will flip to 1.0 at GA (Week 12)
|
|
10
|
+
*/
|
|
11
|
+
export declare const PEAC_WIRE_TYP: "peac.receipt/0.9";
|
|
12
|
+
/**
|
|
13
|
+
* Signature algorithm - FROZEN forever
|
|
14
|
+
*/
|
|
15
|
+
export declare const PEAC_ALG: "EdDSA";
|
|
16
|
+
/**
|
|
17
|
+
* Canonical header name
|
|
18
|
+
*/
|
|
19
|
+
export declare const PEAC_RECEIPT_HEADER: "PEAC-Receipt";
|
|
20
|
+
/**
|
|
21
|
+
* Discovery file path
|
|
22
|
+
*/
|
|
23
|
+
export declare const PEAC_DISCOVERY_PATH: "/.well-known/peac.txt";
|
|
24
|
+
/**
|
|
25
|
+
* Maximum discovery file size (20 lines × ~100 chars/line)
|
|
26
|
+
*/
|
|
27
|
+
export declare const PEAC_DISCOVERY_MAX_BYTES: 2000;
|
|
28
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,eAAO,MAAM,aAAa,oBAAY,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,QAAQ,SAAqB,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,mBAAmB,gBAAkB,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,mBAAmB,yBAAyB,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAG,IAAa,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Wire format constants - FROZEN
|
|
4
|
+
*
|
|
5
|
+
* These constants are now sourced from @peac/kernel
|
|
6
|
+
* (normative source: specs/kernel/constants.json)
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PEAC_DISCOVERY_MAX_BYTES = exports.PEAC_DISCOVERY_PATH = exports.PEAC_RECEIPT_HEADER = exports.PEAC_ALG = exports.PEAC_WIRE_TYP = void 0;
|
|
10
|
+
const kernel_1 = require("@peac/kernel");
|
|
11
|
+
/**
|
|
12
|
+
* Wire format version - FROZEN at 0.9 with v1.0-equivalent semantics
|
|
13
|
+
* Will flip to 1.0 at GA (Week 12)
|
|
14
|
+
*/
|
|
15
|
+
exports.PEAC_WIRE_TYP = kernel_1.WIRE_TYPE;
|
|
16
|
+
/**
|
|
17
|
+
* Signature algorithm - FROZEN forever
|
|
18
|
+
*/
|
|
19
|
+
exports.PEAC_ALG = kernel_1.ALGORITHMS.default;
|
|
20
|
+
/**
|
|
21
|
+
* Canonical header name
|
|
22
|
+
*/
|
|
23
|
+
exports.PEAC_RECEIPT_HEADER = kernel_1.HEADERS.receipt;
|
|
24
|
+
/**
|
|
25
|
+
* Discovery file path
|
|
26
|
+
*/
|
|
27
|
+
exports.PEAC_DISCOVERY_PATH = kernel_1.DISCOVERY.manifestPath;
|
|
28
|
+
/**
|
|
29
|
+
* Maximum discovery file size (20 lines × ~100 chars/line)
|
|
30
|
+
*/
|
|
31
|
+
exports.PEAC_DISCOVERY_MAX_BYTES = 2000;
|
|
32
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,yCAAyE;AAEzE;;;GAGG;AACU,QAAA,aAAa,GAAG,kBAAS,CAAC;AAEvC;;GAEG;AACU,QAAA,QAAQ,GAAG,mBAAU,CAAC,OAAO,CAAC;AAE3C;;GAEG;AACU,QAAA,mBAAmB,GAAG,gBAAO,CAAC,OAAO,CAAC;AAEnD;;GAEG;AACU,QAAA,mBAAmB,GAAG,kBAAS,CAAC,YAAY,CAAC;AAE1D;;GAEG;AACU,QAAA,wBAAwB,GAAG,IAAa,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PEAC Control Abstraction Layer (CAL) Types
|
|
3
|
+
*
|
|
4
|
+
* Composable governance for multi-party authorization.
|
|
5
|
+
* Supports TAP, AP2, and custom control engines.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Control decision type
|
|
9
|
+
*/
|
|
10
|
+
export type ControlDecision = 'allow' | 'deny' | 'review';
|
|
11
|
+
/**
|
|
12
|
+
* Control purpose - what the access is for
|
|
13
|
+
*
|
|
14
|
+
* Used to map RSL, Content Signals, and other policy dialects
|
|
15
|
+
* to a normalized purpose for receipts.
|
|
16
|
+
*
|
|
17
|
+
* Well-known purposes:
|
|
18
|
+
* - "crawl": Web crawling/scraping
|
|
19
|
+
* - "index": Search engine indexing
|
|
20
|
+
* - "train": AI/ML model training
|
|
21
|
+
* - "inference": AI/ML inference/generation
|
|
22
|
+
* - "ai_input": RAG/grounding (using content as input to AI) [v0.9.17+, RSL alignment]
|
|
23
|
+
* - "ai_index": AI-powered search/indexing [v0.9.18+, RSL 1.0 alignment]
|
|
24
|
+
* - "search": Traditional search indexing [v0.9.17+, RSL alignment]
|
|
25
|
+
*
|
|
26
|
+
* Note: RSL 1.0 uses "ai-index" (not "ai-search"). PEAC maps RSL "ai-index" to
|
|
27
|
+
* "ai_index". Previous versions used "ai_search" which has been removed.
|
|
28
|
+
*
|
|
29
|
+
* @see https://rslstandard.org/rsl for RSL 1.0 specification
|
|
30
|
+
*/
|
|
31
|
+
export type ControlPurpose = 'crawl' | 'index' | 'train' | 'inference' | 'ai_input' | 'ai_index' | 'search';
|
|
32
|
+
/**
|
|
33
|
+
* Control licensing mode - how access is licensed
|
|
34
|
+
*
|
|
35
|
+
* Used to capture the commercial arrangement for access.
|
|
36
|
+
*
|
|
37
|
+
* Well-known modes:
|
|
38
|
+
* - "subscription": Access via active subscription
|
|
39
|
+
* - "pay_per_crawl": Per-crawl payment
|
|
40
|
+
* - "pay_per_inference": Per-inference payment
|
|
41
|
+
*/
|
|
42
|
+
export type ControlLicensingMode = 'subscription' | 'pay_per_crawl' | 'pay_per_inference';
|
|
43
|
+
/**
|
|
44
|
+
* Composable control block - multi-party governance
|
|
45
|
+
*
|
|
46
|
+
* Structure:
|
|
47
|
+
* - chain: Ordered list of control decisions from different engines
|
|
48
|
+
* - decision: Final decision (MUST be consistent with chain)
|
|
49
|
+
* - combinator: Logic for combining chain results
|
|
50
|
+
*
|
|
51
|
+
* v0.9.x semantics:
|
|
52
|
+
* - combinator is always "any_can_veto"
|
|
53
|
+
* - If any step has result: "deny", decision MUST be "deny"
|
|
54
|
+
* - If all steps have result: "allow", decision MUST be "allow"
|
|
55
|
+
* - If any step has result: "review" and none "deny", decision MAY be "review"
|
|
56
|
+
*/
|
|
57
|
+
export interface ControlBlock {
|
|
58
|
+
/** Chain of control decisions (length >= 1) */
|
|
59
|
+
chain: ControlStep[];
|
|
60
|
+
/** Final decision (MUST be consistent with chain) */
|
|
61
|
+
decision: ControlDecision;
|
|
62
|
+
/** Combinator logic (v0.9: only "any_can_veto") */
|
|
63
|
+
combinator?: 'any_can_veto';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Single control step in governance chain
|
|
67
|
+
*
|
|
68
|
+
* Represents one control engine's decision in a multi-party
|
|
69
|
+
* governance flow. Examples:
|
|
70
|
+
* - Visa TAP mandate decision
|
|
71
|
+
* - Spend control limit check
|
|
72
|
+
* - Google AP2 mandate authorization
|
|
73
|
+
* - Merchant/platform policy enforcement
|
|
74
|
+
* - Payment fraud check
|
|
75
|
+
*/
|
|
76
|
+
export interface ControlStep {
|
|
77
|
+
/**
|
|
78
|
+
* Control engine identifier
|
|
79
|
+
*
|
|
80
|
+
* Well-known engines:
|
|
81
|
+
* - "spend-control-service" - Spend control mandate engine
|
|
82
|
+
* - "visa-tap" - Visa Trusted Agent Protocol
|
|
83
|
+
* - "google-ap2" - Google Agent Protocol v2
|
|
84
|
+
* - "risk-engine" - Risk scoring
|
|
85
|
+
* - "merchant-policy" - Merchant-specific policy
|
|
86
|
+
* - "platform-policy" - Platform governance
|
|
87
|
+
* - "custom" - Custom engine
|
|
88
|
+
*/
|
|
89
|
+
engine: string;
|
|
90
|
+
/** Engine version (optional, for tracking) */
|
|
91
|
+
version?: string;
|
|
92
|
+
/** Policy ID within engine (engine-specific identifier) */
|
|
93
|
+
policy_id?: string;
|
|
94
|
+
/** Decision from this step */
|
|
95
|
+
result: ControlDecision;
|
|
96
|
+
/** Human-readable reason for decision */
|
|
97
|
+
reason?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Purpose of this access (v0.9.16+)
|
|
100
|
+
*
|
|
101
|
+
* Normalized from RSL, Content Signals, ai.txt, etc.
|
|
102
|
+
* Used to capture what the access is for.
|
|
103
|
+
*/
|
|
104
|
+
purpose?: ControlPurpose;
|
|
105
|
+
/**
|
|
106
|
+
* Licensing mode for this access (v0.9.16+)
|
|
107
|
+
*
|
|
108
|
+
* Captures the commercial arrangement.
|
|
109
|
+
*/
|
|
110
|
+
licensing_mode?: ControlLicensingMode;
|
|
111
|
+
/**
|
|
112
|
+
* Scope of this control step (v0.9.16+)
|
|
113
|
+
*
|
|
114
|
+
* URI pattern(s) or resource identifier(s) this step applies to.
|
|
115
|
+
* Can be a single scope or multiple scopes.
|
|
116
|
+
*
|
|
117
|
+
* Examples:
|
|
118
|
+
* - "https://example.com/api/*"
|
|
119
|
+
* - ["https://example.com/docs/*", "https://example.com/blog/*"]
|
|
120
|
+
*/
|
|
121
|
+
scope?: string | string[];
|
|
122
|
+
/**
|
|
123
|
+
* Limits snapshot at time of decision
|
|
124
|
+
*
|
|
125
|
+
* Engine-specific structure capturing the state of limits/rules
|
|
126
|
+
* that were evaluated. Examples:
|
|
127
|
+
* - Spending limits (per-transaction, daily, weekly)
|
|
128
|
+
* - Usage quotas
|
|
129
|
+
* - Rate limits
|
|
130
|
+
* - Authorization scopes
|
|
131
|
+
*/
|
|
132
|
+
limits_snapshot?: unknown;
|
|
133
|
+
/**
|
|
134
|
+
* Reference to external evidence (URL or ID)
|
|
135
|
+
*
|
|
136
|
+
* Link to detailed evidence stored by the control engine.
|
|
137
|
+
* Examples:
|
|
138
|
+
* - Visa TAP evidence URL
|
|
139
|
+
* - Fraud report URL
|
|
140
|
+
* - Internal audit log ID
|
|
141
|
+
*/
|
|
142
|
+
evidence_ref?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Control validation result
|
|
146
|
+
*/
|
|
147
|
+
export interface ControlValidationResult {
|
|
148
|
+
/** Whether control chain is valid */
|
|
149
|
+
valid: boolean;
|
|
150
|
+
/** Validation error if invalid */
|
|
151
|
+
error?: string;
|
|
152
|
+
/** Decision is consistent with chain */
|
|
153
|
+
consistent: boolean;
|
|
154
|
+
}
|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H,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,qCAAqC;IACrC,KAAK,EAAE,OAAO,CAAC;IAEf,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,wCAAwC;IACxC,UAAU,EAAE,OAAO,CAAC;CACrB"}
|
package/dist/control.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PEAC Control Abstraction Layer (CAL) Types
|
|
4
|
+
*
|
|
5
|
+
* Composable governance for multi-party authorization.
|
|
6
|
+
* Supports TAP, AP2, and custom control engines.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.js","sourceRoot":"","sources":["../src/control.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PEAC Envelope Types (v0.9.15+)
|
|
3
|
+
*
|
|
4
|
+
* These types match the normative JSON Schema (PEAC-RECEIPT-SCHEMA-v0.9.json).
|
|
5
|
+
* The envelope is the canonical structure for PEAC receipts.
|
|
6
|
+
*/
|
|
7
|
+
import type { ControlBlock } from './control';
|
|
8
|
+
import type { PaymentEvidence, AttestationEvidence } from './evidence';
|
|
9
|
+
import type { SubjectProfileSnapshot } from './subject';
|
|
10
|
+
/**
|
|
11
|
+
* Authentication and Authorization Context
|
|
12
|
+
*/
|
|
13
|
+
export interface AuthContext {
|
|
14
|
+
iss: string;
|
|
15
|
+
aud: string;
|
|
16
|
+
sub: string;
|
|
17
|
+
iat: number;
|
|
18
|
+
exp?: number;
|
|
19
|
+
rid: string;
|
|
20
|
+
policy_hash: string;
|
|
21
|
+
policy_uri: string;
|
|
22
|
+
control?: ControlBlock;
|
|
23
|
+
enforcement?: EnforcementContext;
|
|
24
|
+
binding?: TransportBinding;
|
|
25
|
+
ctx?: ContextMetadata;
|
|
26
|
+
/** Subject profile snapshot for policy evaluation (v0.9.17+) */
|
|
27
|
+
subject_snapshot?: SubjectProfileSnapshot;
|
|
28
|
+
}
|
|
29
|
+
export interface EnforcementContext {
|
|
30
|
+
method: string;
|
|
31
|
+
details?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface TransportBinding {
|
|
34
|
+
transport: string;
|
|
35
|
+
method: string;
|
|
36
|
+
evidence?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface ContextMetadata {
|
|
39
|
+
resource?: string;
|
|
40
|
+
method?: string;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
export interface EvidenceBlock {
|
|
44
|
+
payment?: PaymentEvidence;
|
|
45
|
+
attestation?: AttestationEvidence;
|
|
46
|
+
payments?: PaymentEvidence[];
|
|
47
|
+
}
|
|
48
|
+
export interface MetadataBlock {
|
|
49
|
+
redactions?: string[];
|
|
50
|
+
privacy_budget?: Record<string, unknown>;
|
|
51
|
+
debug?: Record<string, unknown>;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* PEAC Envelope - normative structure for v0.9.15+
|
|
56
|
+
*/
|
|
57
|
+
export interface PEACEnvelope {
|
|
58
|
+
auth: AuthContext;
|
|
59
|
+
evidence?: EvidenceBlock;
|
|
60
|
+
meta?: MetadataBlock;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CA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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB"}
|
package/dist/envelope.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PEAC Envelope Types (v0.9.15+)
|
|
4
|
+
*
|
|
5
|
+
* These types match the normative JSON Schema (PEAC-RECEIPT-SCHEMA-v0.9.json).
|
|
6
|
+
* The envelope is the canonical structure for PEAC receipts.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PEAC Structured Error Model
|
|
3
|
+
*
|
|
4
|
+
* Standardized error responses for protocol failures.
|
|
5
|
+
* See docs/specs/ERRORS.md for complete error registry.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Error category - broad classification of error type
|
|
9
|
+
*/
|
|
10
|
+
export type ErrorCategory = 'validation' | 'security' | 'network' | 'authorization' | 'rate_limit' | 'internal';
|
|
11
|
+
/**
|
|
12
|
+
* Error severity
|
|
13
|
+
*/
|
|
14
|
+
export type ErrorSeverity = 'error' | 'warning';
|
|
15
|
+
/**
|
|
16
|
+
* Structured PEAC error
|
|
17
|
+
*
|
|
18
|
+
* Provides machine-readable error information with:
|
|
19
|
+
* - Stable error codes
|
|
20
|
+
* - Category classification
|
|
21
|
+
* - Retryability hints
|
|
22
|
+
* - Remediation guidance
|
|
23
|
+
*/
|
|
24
|
+
export interface PEACError {
|
|
25
|
+
/**
|
|
26
|
+
* Error code
|
|
27
|
+
*
|
|
28
|
+
* Stable identifier for this error type.
|
|
29
|
+
* See docs/specs/ERRORS.md for registry.
|
|
30
|
+
*
|
|
31
|
+
* Examples:
|
|
32
|
+
* - "E_CONTROL_REQUIRED"
|
|
33
|
+
* - "E_INVALID_SIGNATURE"
|
|
34
|
+
* - "E_SSRF_BLOCKED"
|
|
35
|
+
* - "E_DPOP_REPLAY"
|
|
36
|
+
*/
|
|
37
|
+
code: string;
|
|
38
|
+
/**
|
|
39
|
+
* Error category
|
|
40
|
+
*
|
|
41
|
+
* Broad classification for programmatic handling.
|
|
42
|
+
*/
|
|
43
|
+
category: ErrorCategory;
|
|
44
|
+
/**
|
|
45
|
+
* Error severity
|
|
46
|
+
*
|
|
47
|
+
* - "error": Operation failed, cannot proceed
|
|
48
|
+
* - "warning": Operation succeeded but with caveats
|
|
49
|
+
*/
|
|
50
|
+
severity: ErrorSeverity;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the operation is retryable
|
|
53
|
+
*
|
|
54
|
+
* - true: Client should retry (network, rate limit, transient)
|
|
55
|
+
* - false: Client should not retry (validation, security, permanent)
|
|
56
|
+
*/
|
|
57
|
+
retryable: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Suggested HTTP status code
|
|
60
|
+
*
|
|
61
|
+
* Maps error to appropriate HTTP response code.
|
|
62
|
+
* Examples:
|
|
63
|
+
* - 400: Validation errors
|
|
64
|
+
* - 401: Signature/authentication failures
|
|
65
|
+
* - 403: Authorization/control denials
|
|
66
|
+
* - 429: Rate limit exceeded
|
|
67
|
+
* - 502: Network failures (JWKS fetch, etc.)
|
|
68
|
+
*/
|
|
69
|
+
http_status?: number;
|
|
70
|
+
/**
|
|
71
|
+
* JSON Pointer (RFC 6901) to problematic field
|
|
72
|
+
*
|
|
73
|
+
* Identifies the specific field that caused the error.
|
|
74
|
+
* Examples:
|
|
75
|
+
* - "/auth/control" - Missing control block
|
|
76
|
+
* - "/evidence/payment/amount" - Invalid amount
|
|
77
|
+
* - "/auth/control/chain/0/result" - Invalid result value
|
|
78
|
+
*/
|
|
79
|
+
pointer?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Human-readable remediation guidance
|
|
82
|
+
*
|
|
83
|
+
* Short hint for fixing the error.
|
|
84
|
+
* Examples:
|
|
85
|
+
* - "Add control{} block when payment{} is present"
|
|
86
|
+
* - "Ensure JWS signature is valid"
|
|
87
|
+
* - "Retry after 60 seconds"
|
|
88
|
+
*/
|
|
89
|
+
remediation?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Implementation-specific error details
|
|
92
|
+
*
|
|
93
|
+
* Additional context for debugging.
|
|
94
|
+
* Structure varies by error code.
|
|
95
|
+
*/
|
|
96
|
+
details?: unknown;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Error code registry
|
|
100
|
+
*
|
|
101
|
+
* Well-known error codes. See docs/specs/ERRORS.md for complete list.
|
|
102
|
+
*/
|
|
103
|
+
export declare const ERROR_CODES: {
|
|
104
|
+
readonly E_CONTROL_REQUIRED: "E_CONTROL_REQUIRED";
|
|
105
|
+
readonly E_INVALID_ENVELOPE: "E_INVALID_ENVELOPE";
|
|
106
|
+
readonly E_INVALID_CONTROL_CHAIN: "E_INVALID_CONTROL_CHAIN";
|
|
107
|
+
readonly E_INVALID_PAYMENT: "E_INVALID_PAYMENT";
|
|
108
|
+
readonly E_INVALID_POLICY_HASH: "E_INVALID_POLICY_HASH";
|
|
109
|
+
readonly E_EXPIRED_RECEIPT: "E_EXPIRED_RECEIPT";
|
|
110
|
+
readonly E_INVALID_SIGNATURE: "E_INVALID_SIGNATURE";
|
|
111
|
+
readonly E_SSRF_BLOCKED: "E_SSRF_BLOCKED";
|
|
112
|
+
readonly E_DPOP_REPLAY: "E_DPOP_REPLAY";
|
|
113
|
+
readonly E_DPOP_INVALID: "E_DPOP_INVALID";
|
|
114
|
+
readonly E_CONTROL_DENIED: "E_CONTROL_DENIED";
|
|
115
|
+
readonly E_JWKS_FETCH_FAILED: "E_JWKS_FETCH_FAILED";
|
|
116
|
+
readonly E_POLICY_FETCH_FAILED: "E_POLICY_FETCH_FAILED";
|
|
117
|
+
readonly E_NETWORK_ERROR: "E_NETWORK_ERROR";
|
|
118
|
+
readonly E_RATE_LIMIT: "E_RATE_LIMIT";
|
|
119
|
+
readonly E_INTERNAL_ERROR: "E_INTERNAL_ERROR";
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Error code type
|
|
123
|
+
*/
|
|
124
|
+
export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
125
|
+
/**
|
|
126
|
+
* Helper to create a structured error
|
|
127
|
+
*/
|
|
128
|
+
export declare function createPEACError(code: ErrorCode, category: ErrorCategory, severity: ErrorSeverity, retryable: boolean, options?: {
|
|
129
|
+
http_status?: number;
|
|
130
|
+
pointer?: string;
|
|
131
|
+
remediation?: string;
|
|
132
|
+
details?: unknown;
|
|
133
|
+
}): PEACError;
|
|
134
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,UAAU,GACV,SAAS,GACT,eAAe,GACf,YAAY,GACZ,UAAU,CAAC;AAEf;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;;;;;;OAWG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,QAAQ,EAAE,aAAa,CAAC;IAExB;;;;;OAKG;IACH,QAAQ,EAAE,aAAa,CAAC;IAExB;;;;;OAKG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;CA0Bd,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEvE;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACA,SAAS,CAQX"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PEAC Structured Error Model
|
|
4
|
+
*
|
|
5
|
+
* Standardized error responses for protocol failures.
|
|
6
|
+
* See docs/specs/ERRORS.md for complete error registry.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ERROR_CODES = void 0;
|
|
10
|
+
exports.createPEACError = createPEACError;
|
|
11
|
+
/**
|
|
12
|
+
* Error code registry
|
|
13
|
+
*
|
|
14
|
+
* Well-known error codes. See docs/specs/ERRORS.md for complete list.
|
|
15
|
+
*/
|
|
16
|
+
exports.ERROR_CODES = {
|
|
17
|
+
// Validation errors (400)
|
|
18
|
+
E_CONTROL_REQUIRED: 'E_CONTROL_REQUIRED',
|
|
19
|
+
E_INVALID_ENVELOPE: 'E_INVALID_ENVELOPE',
|
|
20
|
+
E_INVALID_CONTROL_CHAIN: 'E_INVALID_CONTROL_CHAIN',
|
|
21
|
+
E_INVALID_PAYMENT: 'E_INVALID_PAYMENT',
|
|
22
|
+
E_INVALID_POLICY_HASH: 'E_INVALID_POLICY_HASH',
|
|
23
|
+
E_EXPIRED_RECEIPT: 'E_EXPIRED_RECEIPT',
|
|
24
|
+
// Security errors (401/403)
|
|
25
|
+
E_INVALID_SIGNATURE: 'E_INVALID_SIGNATURE',
|
|
26
|
+
E_SSRF_BLOCKED: 'E_SSRF_BLOCKED',
|
|
27
|
+
E_DPOP_REPLAY: 'E_DPOP_REPLAY',
|
|
28
|
+
E_DPOP_INVALID: 'E_DPOP_INVALID',
|
|
29
|
+
E_CONTROL_DENIED: 'E_CONTROL_DENIED',
|
|
30
|
+
// Network errors (502/503)
|
|
31
|
+
E_JWKS_FETCH_FAILED: 'E_JWKS_FETCH_FAILED',
|
|
32
|
+
E_POLICY_FETCH_FAILED: 'E_POLICY_FETCH_FAILED',
|
|
33
|
+
E_NETWORK_ERROR: 'E_NETWORK_ERROR',
|
|
34
|
+
// Rate limit errors (429)
|
|
35
|
+
E_RATE_LIMIT: 'E_RATE_LIMIT',
|
|
36
|
+
// Internal errors (500)
|
|
37
|
+
E_INTERNAL_ERROR: 'E_INTERNAL_ERROR',
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Helper to create a structured error
|
|
41
|
+
*/
|
|
42
|
+
function createPEACError(code, category, severity, retryable, options) {
|
|
43
|
+
return {
|
|
44
|
+
code,
|
|
45
|
+
category,
|
|
46
|
+
severity,
|
|
47
|
+
retryable,
|
|
48
|
+
...options,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAsJH,0CAmBC;AA5DD;;;;GAIG;AACU,QAAA,WAAW,GAAG;IACzB,0BAA0B;IAC1B,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;IACxC,uBAAuB,EAAE,yBAAyB;IAClD,iBAAiB,EAAE,mBAAmB;IACtC,qBAAqB,EAAE,uBAAuB;IAC9C,iBAAiB,EAAE,mBAAmB;IAEtC,4BAA4B;IAC5B,mBAAmB,EAAE,qBAAqB;IAC1C,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,eAAe;IAC9B,cAAc,EAAE,gBAAgB;IAChC,gBAAgB,EAAE,kBAAkB;IAEpC,2BAA2B;IAC3B,mBAAmB,EAAE,qBAAqB;IAC1C,qBAAqB,EAAE,uBAAuB;IAC9C,eAAe,EAAE,iBAAiB;IAElC,0BAA0B;IAC1B,YAAY,EAAE,cAAc;IAE5B,wBAAwB;IACxB,gBAAgB,EAAE,kBAAkB;CAC5B,CAAC;AAOX;;GAEG;AACH,SAAgB,eAAe,CAC7B,IAAe,EACf,QAAuB,EACvB,QAAuB,EACvB,SAAkB,EAClB,OAKC;IAED,OAAO;QACL,IAAI;QACJ,QAAQ;QACR,QAAQ;QACR,SAAS;QACT,GAAG,OAAO;KACX,CAAC;AACJ,CAAC"}
|