@peac/contracts 0.9.31

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/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 PEAC Protocol Contributors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # @peac/contracts
2
+
3
+ **Canonical error codes and verification mode contracts for PEAC Protocol.**
4
+
5
+ This package is the **single source of truth** for error codes, HTTP status mappings, and verification mode behavior. All surface implementations (workers, middleware) MUST import from this package to prevent contract drift.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add @peac/contracts
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import {
17
+ CANONICAL_ERROR_CODES,
18
+ CANONICAL_STATUS_MAPPINGS,
19
+ MODE_BEHAVIOR,
20
+ problemTypeFor,
21
+ ERROR_CATALOG,
22
+ type PeacErrorCode,
23
+ type VerificationMode,
24
+ } from '@peac/contracts';
25
+
26
+ // Get HTTP status for an error code
27
+ const status = CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.TAP_SIGNATURE_INVALID];
28
+ // 401
29
+
30
+ // Get RFC 9457 Problem Details type URI
31
+ const problemType = problemTypeFor(CANONICAL_ERROR_CODES.TAP_SIGNATURE_INVALID);
32
+ // "https://peacprotocol.org/problems/E_TAP_SIGNATURE_INVALID"
33
+
34
+ // Check verification mode behavior
35
+ const modeBehavior = MODE_BEHAVIOR.tap_only;
36
+ // { noTapHeadersStatus: 401, noTapHeadersCode: 'E_TAP_SIGNATURE_MISSING' }
37
+
38
+ // Get error catalog entry
39
+ const catalogEntry = ERROR_CATALOG[CANONICAL_ERROR_CODES.TAP_SIGNATURE_INVALID];
40
+ // { status: 401, title: 'Invalid Signature', defaultDetail: '...' }
41
+ ```
42
+
43
+ ## Exports
44
+
45
+ ### Types
46
+
47
+ - `PeacErrorCode` - Union type of all canonical error codes (compile-time safety)
48
+ - `VerificationMode` - Union type: `'tap_only' | 'receipt_or_tap'`
49
+ - `ErrorCatalogEntry` - Structure for error catalog entries
50
+
51
+ ### Constants
52
+
53
+ - `CANONICAL_ERROR_CODES` - All error codes with `E_*` prefix
54
+ - `CANONICAL_STATUS_MAPPINGS` - Error code → HTTP status mappings
55
+ - `CANONICAL_TITLES` - Error code → RFC 9457 title mappings
56
+ - `MODE_BEHAVIOR` - Verification mode → missing TAP behavior
57
+ - `WWW_AUTHENTICATE_STATUSES` - HTTP statuses requiring WWW-Authenticate header `[401, 402]`
58
+ - `ERROR_CATALOG` - Full error catalog with status, title, and default detail
59
+ - `PROBLEM_TYPE_BASE` - Base URI for Problem Details type field
60
+
61
+ ### Functions
62
+
63
+ - `problemTypeFor(code: PeacErrorCode): string` - Get RFC 9457 type URI for error code
64
+ - `getStatusForCode(code: PeacErrorCode): number` - Get HTTP status for error code
65
+ - `requiresWwwAuthenticate(status: number): boolean` - Check if status requires WWW-Authenticate
66
+
67
+ ## Error Codes
68
+
69
+ All error codes use the `E_*` prefix format:
70
+
71
+ ### Receipt Errors (402 - Payment Required)
72
+
73
+ - `E_RECEIPT_MISSING` - Receipt required but not provided
74
+ - `E_RECEIPT_INVALID` - Receipt validation failed
75
+ - `E_RECEIPT_EXPIRED` - Receipt has expired
76
+
77
+ ### TAP Authentication Errors (401)
78
+
79
+ - `E_TAP_SIGNATURE_MISSING` - TAP headers missing
80
+ - `E_TAP_SIGNATURE_INVALID` - Signature verification failed
81
+ - `E_TAP_TIME_INVALID` - Signature time invalid
82
+ - `E_TAP_KEY_NOT_FOUND` - Signing key not found
83
+ - `E_TAP_REPLAY_PROTECTION_REQUIRED` - Replay protection required but not configured
84
+
85
+ ### TAP Malformed Request Errors (400)
86
+
87
+ - `E_TAP_WINDOW_TOO_LARGE` - Time window exceeds maximum
88
+ - `E_TAP_TAG_UNKNOWN` - Unknown signature tag
89
+ - `E_TAP_ALGORITHM_INVALID` - Invalid signature algorithm
90
+
91
+ ### Authorization Errors (403 - Forbidden)
92
+
93
+ - `E_ISSUER_NOT_ALLOWED` - Issuer not in allowlist
94
+
95
+ ### Replay Errors (409 - Conflict)
96
+
97
+ - `E_TAP_NONCE_REPLAY` - Nonce replay detected
98
+
99
+ ### Configuration Errors (500)
100
+
101
+ - `E_CONFIG_ISSUER_ALLOWLIST_REQUIRED` - ISSUER_ALLOWLIST required but not configured
102
+ - `E_INTERNAL_ERROR` - Internal server error
103
+
104
+ ## Verification Modes
105
+
106
+ ### `tap_only` (Default)
107
+
108
+ Missing TAP headers → 401 + `E_TAP_SIGNATURE_MISSING`
109
+
110
+ ### `receipt_or_tap`
111
+
112
+ Missing TAP headers → 402 + `E_RECEIPT_MISSING` (payment remedy)
113
+
114
+ ## Contract Guarantees
115
+
116
+ This package guarantees:
117
+
118
+ 1. **Single source of truth** - All error codes defined once
119
+ 2. **Compile-time safety** - `PeacErrorCode` union type prevents invalid codes
120
+ 3. **Consistent HTTP semantics** - Status codes match RFC semantics
121
+ 4. **RFC 9457 compliance** - Problem Details type URIs follow standard format
122
+ 5. **Cross-surface parity** - All surfaces use identical error codes and behavior
123
+
124
+ ## License
125
+
126
+ Apache-2.0
@@ -0,0 +1,172 @@
1
+ /**
2
+ * PEAC Canonical Contracts
3
+ *
4
+ * Single source of truth for error codes, HTTP status mappings, and verification mode behavior.
5
+ * All surface implementations MUST import from this package to prevent drift.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Base URI for RFC 9457 Problem Details type field.
11
+ */
12
+ export declare const PROBLEM_TYPE_BASE = "https://peacprotocol.org/problems";
13
+ /**
14
+ * Canonical PEAC error codes.
15
+ *
16
+ * Format: E_<CATEGORY>_<ERROR>
17
+ *
18
+ * All error codes use the E_ prefix for consistency with RFC/IETF error code conventions.
19
+ */
20
+ export declare const CANONICAL_ERROR_CODES: {
21
+ readonly RECEIPT_MISSING: "E_RECEIPT_MISSING";
22
+ readonly RECEIPT_INVALID: "E_RECEIPT_INVALID";
23
+ readonly RECEIPT_EXPIRED: "E_RECEIPT_EXPIRED";
24
+ readonly TAP_SIGNATURE_MISSING: "E_TAP_SIGNATURE_MISSING";
25
+ readonly TAP_SIGNATURE_INVALID: "E_TAP_SIGNATURE_INVALID";
26
+ readonly TAP_TIME_INVALID: "E_TAP_TIME_INVALID";
27
+ readonly TAP_WINDOW_TOO_LARGE: "E_TAP_WINDOW_TOO_LARGE";
28
+ readonly TAP_TAG_UNKNOWN: "E_TAP_TAG_UNKNOWN";
29
+ readonly TAP_ALGORITHM_INVALID: "E_TAP_ALGORITHM_INVALID";
30
+ readonly TAP_KEY_NOT_FOUND: "E_TAP_KEY_NOT_FOUND";
31
+ readonly TAP_NONCE_REPLAY: "E_TAP_NONCE_REPLAY";
32
+ readonly TAP_REPLAY_PROTECTION_REQUIRED: "E_TAP_REPLAY_PROTECTION_REQUIRED";
33
+ readonly ISSUER_NOT_ALLOWED: "E_ISSUER_NOT_ALLOWED";
34
+ readonly CONFIG_ISSUER_ALLOWLIST_REQUIRED: "E_CONFIG_ISSUER_ALLOWLIST_REQUIRED";
35
+ readonly INTERNAL_ERROR: "E_INTERNAL_ERROR";
36
+ };
37
+ /**
38
+ * PEAC error code type (union of all canonical error codes).
39
+ *
40
+ * Use this type for compile-time safety when handling error codes.
41
+ */
42
+ export type PeacErrorCode = (typeof CANONICAL_ERROR_CODES)[keyof typeof CANONICAL_ERROR_CODES];
43
+ /**
44
+ * Canonical HTTP status code mappings.
45
+ *
46
+ * Status code semantics:
47
+ * - 400: Client error (malformed request, invalid parameters)
48
+ * - 401: Authentication required (missing/invalid credentials)
49
+ * - 402: Payment Required (reserved for PEAC receipt payment flows)
50
+ * - 403: Forbidden (authenticated but not authorized)
51
+ * - 409: Conflict (replay detection - request conflicts with previous state)
52
+ * - 500: Server error (configuration, internal failure)
53
+ */
54
+ export declare const CANONICAL_STATUS_MAPPINGS: Record<PeacErrorCode, number>;
55
+ /**
56
+ * Canonical error titles for RFC 9457 Problem Details.
57
+ */
58
+ export declare const CANONICAL_TITLES: Record<PeacErrorCode, string>;
59
+ /**
60
+ * Verification mode.
61
+ *
62
+ * Determines behavior when TAP headers are missing:
63
+ * - tap_only: Missing TAP → 401 + E_TAP_SIGNATURE_MISSING (authentication required)
64
+ * - receipt_or_tap: Missing TAP → 402 + E_RECEIPT_MISSING (payment remedy)
65
+ */
66
+ export type VerificationMode = 'tap_only' | 'receipt_or_tap';
67
+ /**
68
+ * Handler action type.
69
+ *
70
+ * Determines how the handler should respond:
71
+ * - error: Authentication/authorization error
72
+ * - challenge: Payment challenge (402 only)
73
+ * - pass: Bypass verification (bypass paths)
74
+ * - forward: Verification succeeded, forward request
75
+ */
76
+ export type HandlerAction = 'error' | 'challenge' | 'pass' | 'forward';
77
+ /**
78
+ * Mode behavior for missing TAP headers.
79
+ */
80
+ export interface ModeBehavior {
81
+ /** HTTP status code */
82
+ status: number;
83
+ /** PEAC error code */
84
+ code: PeacErrorCode;
85
+ /** Handler action */
86
+ action: HandlerAction;
87
+ }
88
+ /**
89
+ * Verification mode behavior contract.
90
+ *
91
+ * Defines expected HTTP status, error code, and action when no TAP headers are present.
92
+ * This is the canonical source of truth for mode-based behavior.
93
+ */
94
+ export declare const MODE_BEHAVIOR: Record<VerificationMode, ModeBehavior>;
95
+ /**
96
+ * HTTP status codes that require WWW-Authenticate header.
97
+ *
98
+ * Per v0.9.27 decision: WWW-Authenticate is sent on both 401 (auth required) and 402 (payment remedy).
99
+ */
100
+ export declare const WWW_AUTHENTICATE_STATUSES: readonly [401, 402];
101
+ /**
102
+ * Get RFC 9457 Problem Details type URI for an error code.
103
+ *
104
+ * @param code - PEAC error code
105
+ * @returns Problem Details type URI (e.g., "https://peacprotocol.org/problems/E_TAP_SIGNATURE_MISSING")
106
+ */
107
+ export declare function problemTypeFor(code: PeacErrorCode): string;
108
+ /**
109
+ * Error catalog entry.
110
+ */
111
+ export interface ErrorCatalogEntry {
112
+ /** HTTP status code */
113
+ status: number;
114
+ /** RFC 9457 title */
115
+ title: string;
116
+ /** Default detail message (can be overridden at runtime) */
117
+ defaultDetail?: string;
118
+ }
119
+ /**
120
+ * Error catalog with HTTP status, title, and default detail for each error code.
121
+ *
122
+ * Use this for constructing RFC 9457 Problem Details responses.
123
+ */
124
+ export declare const ERROR_CATALOG: Record<PeacErrorCode, ErrorCatalogEntry>;
125
+ /**
126
+ * Get HTTP status code for a PEAC error code.
127
+ *
128
+ * @param code - PEAC error code
129
+ * @returns HTTP status code
130
+ */
131
+ export declare function getStatusForCode(code: PeacErrorCode): number;
132
+ /**
133
+ * Check if HTTP status requires WWW-Authenticate header.
134
+ *
135
+ * @param status - HTTP status code
136
+ * @returns true if WWW-Authenticate header is required
137
+ */
138
+ export declare function requiresWwwAuthenticate(status: number): boolean;
139
+ /**
140
+ * Build canonical WWW-Authenticate header value.
141
+ *
142
+ * Format: PEAC realm="<realm>", error="<code>", error_uri="<uri>"
143
+ *
144
+ * @param code - PEAC error code
145
+ * @param realm - Authentication realm (default: "peac")
146
+ * @returns Canonical WWW-Authenticate header value
147
+ */
148
+ export declare function buildWwwAuthenticate(code: PeacErrorCode, realm?: string): string;
149
+ /**
150
+ * Valid PEAC HTTP status codes.
151
+ *
152
+ * All status codes that can be returned by PEAC verification handlers.
153
+ */
154
+ export type PeacHttpStatus = 400 | 401 | 402 | 403 | 409 | 500;
155
+ /**
156
+ * Type guard to check if a value is a valid PEAC error code.
157
+ *
158
+ * Uses O(1) Set lookup for performance.
159
+ *
160
+ * @param x - Value to check
161
+ * @returns true if x is a valid PeacErrorCode
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * if (isPeacErrorCode(code)) {
166
+ * // TypeScript now knows code is PeacErrorCode
167
+ * const status = getStatusForCode(code);
168
+ * }
169
+ * ```
170
+ */
171
+ export declare function isPeacErrorCode(x: unknown): x is PeacErrorCode;
172
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,sCAAsC,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;CA6BxB,CAAC;AAEX;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OA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;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,SAAS,GAAG,MAAM,CAEhF;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAS/D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,aAAa,CAE9D"}
package/dist/index.js ADDED
@@ -0,0 +1,268 @@
1
+ /**
2
+ * PEAC Canonical Contracts
3
+ *
4
+ * Single source of truth for error codes, HTTP status mappings, and verification mode behavior.
5
+ * All surface implementations MUST import from this package to prevent drift.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Base URI for RFC 9457 Problem Details type field.
11
+ */
12
+ export const PROBLEM_TYPE_BASE = 'https://peacprotocol.org/problems';
13
+ /**
14
+ * Canonical PEAC error codes.
15
+ *
16
+ * Format: E_<CATEGORY>_<ERROR>
17
+ *
18
+ * All error codes use the E_ prefix for consistency with RFC/IETF error code conventions.
19
+ */
20
+ export const CANONICAL_ERROR_CODES = {
21
+ // Receipt errors (402 - Payment Required)
22
+ RECEIPT_MISSING: 'E_RECEIPT_MISSING',
23
+ RECEIPT_INVALID: 'E_RECEIPT_INVALID',
24
+ RECEIPT_EXPIRED: 'E_RECEIPT_EXPIRED',
25
+ // TAP errors (401 - Authentication)
26
+ TAP_SIGNATURE_MISSING: 'E_TAP_SIGNATURE_MISSING',
27
+ TAP_SIGNATURE_INVALID: 'E_TAP_SIGNATURE_INVALID',
28
+ TAP_TIME_INVALID: 'E_TAP_TIME_INVALID',
29
+ TAP_WINDOW_TOO_LARGE: 'E_TAP_WINDOW_TOO_LARGE',
30
+ TAP_TAG_UNKNOWN: 'E_TAP_TAG_UNKNOWN',
31
+ TAP_ALGORITHM_INVALID: 'E_TAP_ALGORITHM_INVALID',
32
+ TAP_KEY_NOT_FOUND: 'E_TAP_KEY_NOT_FOUND',
33
+ // Replay error (409 - Conflict)
34
+ TAP_NONCE_REPLAY: 'E_TAP_NONCE_REPLAY',
35
+ // Replay protection required (401 - requires config change)
36
+ TAP_REPLAY_PROTECTION_REQUIRED: 'E_TAP_REPLAY_PROTECTION_REQUIRED',
37
+ // Issuer errors (403 - Forbidden)
38
+ ISSUER_NOT_ALLOWED: 'E_ISSUER_NOT_ALLOWED',
39
+ // Configuration errors (500 - Server misconfiguration)
40
+ CONFIG_ISSUER_ALLOWLIST_REQUIRED: 'E_CONFIG_ISSUER_ALLOWLIST_REQUIRED',
41
+ // Internal errors (500)
42
+ INTERNAL_ERROR: 'E_INTERNAL_ERROR',
43
+ };
44
+ /**
45
+ * Canonical HTTP status code mappings.
46
+ *
47
+ * Status code semantics:
48
+ * - 400: Client error (malformed request, invalid parameters)
49
+ * - 401: Authentication required (missing/invalid credentials)
50
+ * - 402: Payment Required (reserved for PEAC receipt payment flows)
51
+ * - 403: Forbidden (authenticated but not authorized)
52
+ * - 409: Conflict (replay detection - request conflicts with previous state)
53
+ * - 500: Server error (configuration, internal failure)
54
+ */
55
+ export const CANONICAL_STATUS_MAPPINGS = {
56
+ // 402 - Payment Required (reserved for payment flows)
57
+ [CANONICAL_ERROR_CODES.RECEIPT_MISSING]: 402,
58
+ [CANONICAL_ERROR_CODES.RECEIPT_INVALID]: 402,
59
+ [CANONICAL_ERROR_CODES.RECEIPT_EXPIRED]: 402,
60
+ // 401 - Authentication errors
61
+ [CANONICAL_ERROR_CODES.TAP_SIGNATURE_MISSING]: 401,
62
+ [CANONICAL_ERROR_CODES.TAP_SIGNATURE_INVALID]: 401,
63
+ [CANONICAL_ERROR_CODES.TAP_TIME_INVALID]: 401,
64
+ [CANONICAL_ERROR_CODES.TAP_KEY_NOT_FOUND]: 401,
65
+ [CANONICAL_ERROR_CODES.TAP_REPLAY_PROTECTION_REQUIRED]: 401,
66
+ // 400 - Client errors (malformed)
67
+ [CANONICAL_ERROR_CODES.TAP_WINDOW_TOO_LARGE]: 400,
68
+ [CANONICAL_ERROR_CODES.TAP_TAG_UNKNOWN]: 400,
69
+ [CANONICAL_ERROR_CODES.TAP_ALGORITHM_INVALID]: 400,
70
+ // 403 - Forbidden (issuer not in allowlist)
71
+ [CANONICAL_ERROR_CODES.ISSUER_NOT_ALLOWED]: 403,
72
+ // 409 - Conflict (replay detected)
73
+ [CANONICAL_ERROR_CODES.TAP_NONCE_REPLAY]: 409,
74
+ // 500 - Server errors
75
+ [CANONICAL_ERROR_CODES.CONFIG_ISSUER_ALLOWLIST_REQUIRED]: 500,
76
+ [CANONICAL_ERROR_CODES.INTERNAL_ERROR]: 500,
77
+ };
78
+ /**
79
+ * Canonical error titles for RFC 9457 Problem Details.
80
+ */
81
+ export const CANONICAL_TITLES = {
82
+ [CANONICAL_ERROR_CODES.RECEIPT_MISSING]: 'Payment Required',
83
+ [CANONICAL_ERROR_CODES.RECEIPT_INVALID]: 'Invalid Receipt',
84
+ [CANONICAL_ERROR_CODES.RECEIPT_EXPIRED]: 'Receipt Expired',
85
+ [CANONICAL_ERROR_CODES.TAP_SIGNATURE_MISSING]: 'Signature Missing',
86
+ [CANONICAL_ERROR_CODES.TAP_SIGNATURE_INVALID]: 'Invalid Signature',
87
+ [CANONICAL_ERROR_CODES.TAP_TIME_INVALID]: 'Invalid Signature Time',
88
+ [CANONICAL_ERROR_CODES.TAP_WINDOW_TOO_LARGE]: 'Signature Window Too Large',
89
+ [CANONICAL_ERROR_CODES.TAP_TAG_UNKNOWN]: 'Unknown TAP Tag',
90
+ [CANONICAL_ERROR_CODES.TAP_ALGORITHM_INVALID]: 'Invalid Algorithm',
91
+ [CANONICAL_ERROR_CODES.TAP_KEY_NOT_FOUND]: 'Key Not Found',
92
+ [CANONICAL_ERROR_CODES.TAP_NONCE_REPLAY]: 'Nonce Replay Detected',
93
+ [CANONICAL_ERROR_CODES.TAP_REPLAY_PROTECTION_REQUIRED]: 'Replay Protection Required',
94
+ [CANONICAL_ERROR_CODES.ISSUER_NOT_ALLOWED]: 'Issuer Not Allowed',
95
+ [CANONICAL_ERROR_CODES.CONFIG_ISSUER_ALLOWLIST_REQUIRED]: 'Configuration Error',
96
+ [CANONICAL_ERROR_CODES.INTERNAL_ERROR]: 'Internal Server Error',
97
+ };
98
+ /**
99
+ * Verification mode behavior contract.
100
+ *
101
+ * Defines expected HTTP status, error code, and action when no TAP headers are present.
102
+ * This is the canonical source of truth for mode-based behavior.
103
+ */
104
+ export const MODE_BEHAVIOR = {
105
+ receipt_or_tap: {
106
+ status: 402,
107
+ code: CANONICAL_ERROR_CODES.RECEIPT_MISSING,
108
+ action: 'challenge',
109
+ },
110
+ tap_only: {
111
+ status: 401,
112
+ code: CANONICAL_ERROR_CODES.TAP_SIGNATURE_MISSING,
113
+ action: 'error',
114
+ },
115
+ };
116
+ /**
117
+ * HTTP status codes that require WWW-Authenticate header.
118
+ *
119
+ * Per v0.9.27 decision: WWW-Authenticate is sent on both 401 (auth required) and 402 (payment remedy).
120
+ */
121
+ export const WWW_AUTHENTICATE_STATUSES = [401, 402];
122
+ /**
123
+ * Get RFC 9457 Problem Details type URI for an error code.
124
+ *
125
+ * @param code - PEAC error code
126
+ * @returns Problem Details type URI (e.g., "https://peacprotocol.org/problems/E_TAP_SIGNATURE_MISSING")
127
+ */
128
+ export function problemTypeFor(code) {
129
+ return `${PROBLEM_TYPE_BASE}/${code}`;
130
+ }
131
+ /**
132
+ * Error catalog with HTTP status, title, and default detail for each error code.
133
+ *
134
+ * Use this for constructing RFC 9457 Problem Details responses.
135
+ */
136
+ export const ERROR_CATALOG = {
137
+ [CANONICAL_ERROR_CODES.RECEIPT_MISSING]: {
138
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.RECEIPT_MISSING],
139
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.RECEIPT_MISSING],
140
+ defaultDetail: 'A valid PEAC receipt is required to access this resource.',
141
+ },
142
+ [CANONICAL_ERROR_CODES.RECEIPT_INVALID]: {
143
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.RECEIPT_INVALID],
144
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.RECEIPT_INVALID],
145
+ defaultDetail: 'The provided receipt is invalid.',
146
+ },
147
+ [CANONICAL_ERROR_CODES.RECEIPT_EXPIRED]: {
148
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.RECEIPT_EXPIRED],
149
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.RECEIPT_EXPIRED],
150
+ defaultDetail: 'The provided receipt has expired.',
151
+ },
152
+ [CANONICAL_ERROR_CODES.TAP_SIGNATURE_MISSING]: {
153
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.TAP_SIGNATURE_MISSING],
154
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.TAP_SIGNATURE_MISSING],
155
+ defaultDetail: 'TAP signature headers are required.',
156
+ },
157
+ [CANONICAL_ERROR_CODES.TAP_SIGNATURE_INVALID]: {
158
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.TAP_SIGNATURE_INVALID],
159
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.TAP_SIGNATURE_INVALID],
160
+ defaultDetail: 'TAP signature verification failed.',
161
+ },
162
+ [CANONICAL_ERROR_CODES.TAP_TIME_INVALID]: {
163
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.TAP_TIME_INVALID],
164
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.TAP_TIME_INVALID],
165
+ defaultDetail: 'TAP signature time is invalid.',
166
+ },
167
+ [CANONICAL_ERROR_CODES.TAP_WINDOW_TOO_LARGE]: {
168
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.TAP_WINDOW_TOO_LARGE],
169
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.TAP_WINDOW_TOO_LARGE],
170
+ defaultDetail: 'TAP signature time window exceeds maximum allowed.',
171
+ },
172
+ [CANONICAL_ERROR_CODES.TAP_TAG_UNKNOWN]: {
173
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.TAP_TAG_UNKNOWN],
174
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.TAP_TAG_UNKNOWN],
175
+ defaultDetail: 'Unknown TAP tag in signature.',
176
+ },
177
+ [CANONICAL_ERROR_CODES.TAP_ALGORITHM_INVALID]: {
178
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.TAP_ALGORITHM_INVALID],
179
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.TAP_ALGORITHM_INVALID],
180
+ defaultDetail: 'TAP signature algorithm is invalid.',
181
+ },
182
+ [CANONICAL_ERROR_CODES.TAP_KEY_NOT_FOUND]: {
183
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.TAP_KEY_NOT_FOUND],
184
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.TAP_KEY_NOT_FOUND],
185
+ defaultDetail: 'TAP signing key not found.',
186
+ },
187
+ [CANONICAL_ERROR_CODES.TAP_NONCE_REPLAY]: {
188
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.TAP_NONCE_REPLAY],
189
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.TAP_NONCE_REPLAY],
190
+ defaultDetail: 'Nonce replay detected.',
191
+ },
192
+ [CANONICAL_ERROR_CODES.TAP_REPLAY_PROTECTION_REQUIRED]: {
193
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.TAP_REPLAY_PROTECTION_REQUIRED],
194
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.TAP_REPLAY_PROTECTION_REQUIRED],
195
+ defaultDetail: 'Replay protection required but not configured. Set UNSAFE_ALLOW_NO_REPLAY=true to bypass (UNSAFE for production).',
196
+ },
197
+ [CANONICAL_ERROR_CODES.ISSUER_NOT_ALLOWED]: {
198
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.ISSUER_NOT_ALLOWED],
199
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.ISSUER_NOT_ALLOWED],
200
+ defaultDetail: 'Issuer not in allowlist.',
201
+ },
202
+ [CANONICAL_ERROR_CODES.CONFIG_ISSUER_ALLOWLIST_REQUIRED]: {
203
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.CONFIG_ISSUER_ALLOWLIST_REQUIRED],
204
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.CONFIG_ISSUER_ALLOWLIST_REQUIRED],
205
+ defaultDetail: 'Worker misconfigured: ISSUER_ALLOWLIST is required. Set UNSAFE_ALLOW_ANY_ISSUER=true to bypass (UNSAFE for production).',
206
+ },
207
+ [CANONICAL_ERROR_CODES.INTERNAL_ERROR]: {
208
+ status: CANONICAL_STATUS_MAPPINGS[CANONICAL_ERROR_CODES.INTERNAL_ERROR],
209
+ title: CANONICAL_TITLES[CANONICAL_ERROR_CODES.INTERNAL_ERROR],
210
+ defaultDetail: 'An internal server error occurred.',
211
+ },
212
+ };
213
+ /**
214
+ * Get HTTP status code for a PEAC error code.
215
+ *
216
+ * @param code - PEAC error code
217
+ * @returns HTTP status code
218
+ */
219
+ export function getStatusForCode(code) {
220
+ return CANONICAL_STATUS_MAPPINGS[code];
221
+ }
222
+ /**
223
+ * Check if HTTP status requires WWW-Authenticate header.
224
+ *
225
+ * @param status - HTTP status code
226
+ * @returns true if WWW-Authenticate header is required
227
+ */
228
+ export function requiresWwwAuthenticate(status) {
229
+ return WWW_AUTHENTICATE_STATUSES.includes(status);
230
+ }
231
+ /**
232
+ * Build canonical WWW-Authenticate header value.
233
+ *
234
+ * Format: PEAC realm="<realm>", error="<code>", error_uri="<uri>"
235
+ *
236
+ * @param code - PEAC error code
237
+ * @param realm - Authentication realm (default: "peac")
238
+ * @returns Canonical WWW-Authenticate header value
239
+ */
240
+ export function buildWwwAuthenticate(code, realm = 'peac') {
241
+ return `PEAC realm="${realm}", error="${code}", error_uri="${problemTypeFor(code)}"`;
242
+ }
243
+ /**
244
+ * Set of all canonical PEAC error codes for O(1) validation.
245
+ *
246
+ * @internal
247
+ */
248
+ const PEAC_ERROR_CODE_SET = new Set(Object.values(CANONICAL_ERROR_CODES));
249
+ /**
250
+ * Type guard to check if a value is a valid PEAC error code.
251
+ *
252
+ * Uses O(1) Set lookup for performance.
253
+ *
254
+ * @param x - Value to check
255
+ * @returns true if x is a valid PeacErrorCode
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * if (isPeacErrorCode(code)) {
260
+ * // TypeScript now knows code is PeacErrorCode
261
+ * const status = getStatusForCode(code);
262
+ * }
263
+ * ```
264
+ */
265
+ export function isPeacErrorCode(x) {
266
+ return typeof x === 'string' && PEAC_ERROR_CODE_SET.has(x);
267
+ }
268
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mCAAmC,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,0CAA0C;IAC1C,eAAe,EAAE,mBAAmB;IACpC,eAAe,EAAE,mBAAmB;IACpC,eAAe,EAAE,mBAAmB;IAEpC,oCAAoC;IACpC,qBAAqB,EAAE,yBAAyB;IAChD,qBAAqB,EAAE,yBAAyB;IAChD,gBAAgB,EAAE,oBAAoB;IACtC,oBAAoB,EAAE,wBAAwB;IAC9C,eAAe,EAAE,mBAAmB;IACpC,qBAAqB,EAAE,yBAAyB;IAChD,iBAAiB,EAAE,qBAAqB;IAExC,gCAAgC;IAChC,gBAAgB,EAAE,oBAAoB;IAEtC,4DAA4D;IAC5D,8BAA8B,EAAE,kC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AC,KAAK,QAAQ,IAAI,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@peac/contracts",
3
+ "version": "0.9.31",
4
+ "description": "PEAC canonical error codes and verification mode contracts",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "keywords": [
18
+ "peac",
19
+ "protocol",
20
+ "errors",
21
+ "rfc9457",
22
+ "http"
23
+ ],
24
+ "author": "PEAC Protocol contributors",
25
+ "license": "Apache-2.0",
26
+ "devDependencies": {
27
+ "typescript": "^5.3.3",
28
+ "vitest": "^2.0.0"
29
+ },
30
+ "scripts": {
31
+ "build": "tsc",
32
+ "typecheck": "tsc --noEmit",
33
+ "test": "vitest run",
34
+ "test:watch": "vitest"
35
+ }
36
+ }