@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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PEAC Subject Profile Types
|
|
3
|
+
*
|
|
4
|
+
* Subject profiles for identity and authorization context.
|
|
5
|
+
* Used in conjunction with receipts and control decisions.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Subject identifier (opaque string)
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* - "user:alice@example.com"
|
|
12
|
+
* - "org:acme-corp"
|
|
13
|
+
* - "agent:gpt-4-crawler"
|
|
14
|
+
*/
|
|
15
|
+
export type SubjectId = string;
|
|
16
|
+
/**
|
|
17
|
+
* Subject type classification
|
|
18
|
+
*
|
|
19
|
+
* - "human": Individual person
|
|
20
|
+
* - "org": Organization or legal entity
|
|
21
|
+
* - "agent": Autonomous software agent (AI, bot, crawler)
|
|
22
|
+
*/
|
|
23
|
+
export type SubjectType = 'human' | 'org' | 'agent';
|
|
24
|
+
/**
|
|
25
|
+
* Subject profile - identity and classification
|
|
26
|
+
*
|
|
27
|
+
* Minimal profile structure for subjects in the PEAC ecosystem.
|
|
28
|
+
* Profiles are intentionally lightweight; detailed identity
|
|
29
|
+
* attributes belong in external identity systems.
|
|
30
|
+
*
|
|
31
|
+
* Invariants:
|
|
32
|
+
* - `id` is REQUIRED (non-empty string)
|
|
33
|
+
* - `type` is REQUIRED (one of: human, org, agent)
|
|
34
|
+
* - `labels` if present must be non-empty strings
|
|
35
|
+
*/
|
|
36
|
+
export interface SubjectProfile {
|
|
37
|
+
/**
|
|
38
|
+
* Subject identifier (REQUIRED)
|
|
39
|
+
*
|
|
40
|
+
* Stable, unique identifier for this subject.
|
|
41
|
+
* Format is application-specific.
|
|
42
|
+
*/
|
|
43
|
+
id: SubjectId;
|
|
44
|
+
/**
|
|
45
|
+
* Subject type (REQUIRED)
|
|
46
|
+
*
|
|
47
|
+
* Classification of the subject for policy purposes.
|
|
48
|
+
*/
|
|
49
|
+
type: SubjectType;
|
|
50
|
+
/**
|
|
51
|
+
* Labels for categorization (OPTIONAL)
|
|
52
|
+
*
|
|
53
|
+
* Freeform tags for grouping or filtering subjects.
|
|
54
|
+
* Examples: ["premium", "verified"], ["crawler", "indexer"]
|
|
55
|
+
*/
|
|
56
|
+
labels?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* Additional metadata (OPTIONAL)
|
|
59
|
+
*
|
|
60
|
+
* Application-specific attributes.
|
|
61
|
+
*/
|
|
62
|
+
metadata?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Subject profile snapshot - point-in-time capture
|
|
66
|
+
*
|
|
67
|
+
* Captures the state of a subject profile at a specific moment.
|
|
68
|
+
* Used for audit trails, policy evaluation records, and receipts.
|
|
69
|
+
*
|
|
70
|
+
* Invariants:
|
|
71
|
+
* - `subject` is REQUIRED (valid SubjectProfile)
|
|
72
|
+
* - `captured_at` is REQUIRED (ISO 8601 timestamp)
|
|
73
|
+
*/
|
|
74
|
+
export interface SubjectProfileSnapshot {
|
|
75
|
+
/**
|
|
76
|
+
* Subject profile (REQUIRED)
|
|
77
|
+
*
|
|
78
|
+
* The captured profile state.
|
|
79
|
+
*/
|
|
80
|
+
subject: SubjectProfile;
|
|
81
|
+
/**
|
|
82
|
+
* Capture timestamp (REQUIRED)
|
|
83
|
+
*
|
|
84
|
+
* MUST be an RFC 3339 / ISO 8601 UTC timestamp string.
|
|
85
|
+
* Examples:
|
|
86
|
+
* - "2025-01-15T10:30:00Z"
|
|
87
|
+
* - "2025-01-15T10:30:00.123Z"
|
|
88
|
+
*
|
|
89
|
+
* Note: Schema validates non-empty string only; format
|
|
90
|
+
* enforcement is left to application layer for v0.9.16.
|
|
91
|
+
*/
|
|
92
|
+
captured_at: string;
|
|
93
|
+
/**
|
|
94
|
+
* Source of the snapshot (OPTIONAL)
|
|
95
|
+
*
|
|
96
|
+
* Identifies where this profile data came from.
|
|
97
|
+
* Examples:
|
|
98
|
+
* - "idp:auth0"
|
|
99
|
+
* - "directory:ldap"
|
|
100
|
+
* - "manual"
|
|
101
|
+
*/
|
|
102
|
+
source?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Profile version (OPTIONAL)
|
|
105
|
+
*
|
|
106
|
+
* Version tag for the profile schema or data.
|
|
107
|
+
* Useful for tracking profile format changes over time.
|
|
108
|
+
*/
|
|
109
|
+
version?: string;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=subject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subject.d.ts","sourceRoot":"","sources":["../src/subject.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,EAAE,EAAE,SAAS,CAAC;IAEd;;;;OAIG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,OAAO,EAAE,cAAc,CAAC;IAExB;;;;;;;;;;OAUG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/subject.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PEAC Subject Profile Types
|
|
4
|
+
*
|
|
5
|
+
* Subject profiles for identity and authorization context.
|
|
6
|
+
* Used in conjunction with receipts and control decisions.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=subject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subject.js","sourceRoot":"","sources":["../src/subject.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PEAC Protocol TypeScript types
|
|
3
|
+
*/
|
|
4
|
+
import { PEAC_WIRE_TYP, PEAC_ALG } from './constants';
|
|
5
|
+
import type { ControlBlock } from './control';
|
|
6
|
+
import type { PaymentEvidence } from './evidence';
|
|
7
|
+
/**
|
|
8
|
+
* Subject of the receipt (what was paid for)
|
|
9
|
+
*/
|
|
10
|
+
export interface Subject {
|
|
11
|
+
/** URI of the resource being paid for */
|
|
12
|
+
uri: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* AIPREF snapshot (if applicable)
|
|
16
|
+
*/
|
|
17
|
+
export interface AIPREFSnapshot {
|
|
18
|
+
/** URL of the AIPREF document */
|
|
19
|
+
url: string;
|
|
20
|
+
/** JCS+SHA-256 hash of the AIPREF document */
|
|
21
|
+
hash: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Extension fields (additive-only growth path)
|
|
25
|
+
*/
|
|
26
|
+
export interface ReceiptExtensions {
|
|
27
|
+
/** AIPREF snapshot at time of issuance */
|
|
28
|
+
aipref_snapshot?: AIPREFSnapshot;
|
|
29
|
+
/** Control block for mandate management (CAL) */
|
|
30
|
+
control?: ControlBlock;
|
|
31
|
+
/** Additional extensions (PEIP-defined) */
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* JWS Header for PEAC receipts
|
|
36
|
+
*/
|
|
37
|
+
export interface PEACReceiptHeader {
|
|
38
|
+
/** Wire format version - FROZEN at 0.9 until GA */
|
|
39
|
+
typ: typeof PEAC_WIRE_TYP;
|
|
40
|
+
/** Signature algorithm - Ed25519 */
|
|
41
|
+
alg: typeof PEAC_ALG;
|
|
42
|
+
/** Key ID (ISO 8601 timestamp) */
|
|
43
|
+
kid: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* PEAC Receipt Claims (JWS payload)
|
|
47
|
+
*/
|
|
48
|
+
export interface PEACReceiptClaims {
|
|
49
|
+
/** Issuer URL (https://) */
|
|
50
|
+
iss: string;
|
|
51
|
+
/** Audience / resource URL */
|
|
52
|
+
aud: string;
|
|
53
|
+
/** Issued at (Unix timestamp seconds) */
|
|
54
|
+
iat: number;
|
|
55
|
+
/** Expiry (Unix timestamp seconds, optional) */
|
|
56
|
+
exp?: number;
|
|
57
|
+
/** Receipt ID (UUIDv7) */
|
|
58
|
+
rid: string;
|
|
59
|
+
/** Amount (smallest currency unit) */
|
|
60
|
+
amt: number;
|
|
61
|
+
/** Currency (ISO 4217 uppercase) */
|
|
62
|
+
cur: string;
|
|
63
|
+
/** Normalized payment details */
|
|
64
|
+
payment: PaymentEvidence;
|
|
65
|
+
/** Subject (what was paid for) */
|
|
66
|
+
subject?: Subject;
|
|
67
|
+
/** Extensions (additive-only) */
|
|
68
|
+
ext?: ReceiptExtensions;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Complete PEAC Receipt (header + claims)
|
|
72
|
+
*/
|
|
73
|
+
export interface PEACReceipt {
|
|
74
|
+
header: PEACReceiptHeader;
|
|
75
|
+
claims: PEACReceiptClaims;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Verify request body
|
|
79
|
+
*/
|
|
80
|
+
export interface VerifyRequest {
|
|
81
|
+
/** JWS compact serialization */
|
|
82
|
+
receipt_jws: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Verify response (success)
|
|
86
|
+
*/
|
|
87
|
+
export interface VerifyResponseSuccess {
|
|
88
|
+
/** Verification succeeded */
|
|
89
|
+
ok: true;
|
|
90
|
+
/** JWS header (decoded) */
|
|
91
|
+
header: PEACReceiptHeader;
|
|
92
|
+
/** Claims (decoded and validated) */
|
|
93
|
+
claims: PEACReceiptClaims;
|
|
94
|
+
/** Performance metrics */
|
|
95
|
+
perf?: {
|
|
96
|
+
verify_ms: number;
|
|
97
|
+
jwks_fetch_ms?: number;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Verify response (failure)
|
|
102
|
+
*/
|
|
103
|
+
export interface VerifyResponseFailure {
|
|
104
|
+
/** Verification failed */
|
|
105
|
+
ok: false;
|
|
106
|
+
/** Error reason */
|
|
107
|
+
reason: string;
|
|
108
|
+
/** Error details */
|
|
109
|
+
details?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Verify response (union)
|
|
113
|
+
*/
|
|
114
|
+
export type VerifyResponse = VerifyResponseSuccess | VerifyResponseFailure;
|
|
115
|
+
/**
|
|
116
|
+
* Discovery manifest (peac.txt parsed)
|
|
117
|
+
*/
|
|
118
|
+
export interface PEACDiscovery {
|
|
119
|
+
/** PEAC protocol version */
|
|
120
|
+
version: string;
|
|
121
|
+
/** Issuer URL */
|
|
122
|
+
issuer: string;
|
|
123
|
+
/** Verify endpoint URL */
|
|
124
|
+
verify: string;
|
|
125
|
+
/** JWKS URL */
|
|
126
|
+
jwks: string;
|
|
127
|
+
/** Supported payment rails */
|
|
128
|
+
payments: Array<{
|
|
129
|
+
rail: string;
|
|
130
|
+
info?: string;
|
|
131
|
+
}>;
|
|
132
|
+
/** AIPREF URL (optional) */
|
|
133
|
+
aipref?: string;
|
|
134
|
+
/** SLO endpoint (optional) */
|
|
135
|
+
slos?: string;
|
|
136
|
+
/** Security contact (optional) */
|
|
137
|
+
security?: string;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../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