@openleash/core 0.0.3 → 0.1.0
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 +191 -0
- package/dist/audit.d.ts +11 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +76 -0
- package/dist/audit.js.map +1 -0
- package/dist/canonicalize.d.ts +5 -0
- package/dist/canonicalize.d.ts.map +1 -0
- package/dist/canonicalize.js +51 -0
- package/dist/canonicalize.js.map +1 -0
- package/dist/constraints.d.ts +3 -0
- package/dist/constraints.d.ts.map +1 -0
- package/dist/constraints.js +51 -0
- package/dist/constraints.js.map +1 -0
- package/dist/engine.d.ts +21 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +139 -0
- package/dist/engine.js.map +1 -0
- package/dist/expression.d.ts +3 -0
- package/dist/expression.d.ts.map +1 -0
- package/dist/expression.js +60 -0
- package/dist/expression.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonpath.d.ts +8 -0
- package/dist/jsonpath.d.ts.map +1 -0
- package/dist/jsonpath.js +48 -0
- package/dist/jsonpath.js.map +1 -0
- package/dist/keys.d.ts +9 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +80 -0
- package/dist/keys.js.map +1 -0
- package/dist/nonce-cache.d.ts +17 -0
- package/dist/nonce-cache.d.ts.map +1 -0
- package/dist/nonce-cache.js +53 -0
- package/dist/nonce-cache.js.map +1 -0
- package/dist/obligations.d.ts +9 -0
- package/dist/obligations.d.ts.map +1 -0
- package/dist/obligations.js +89 -0
- package/dist/obligations.js.map +1 -0
- package/dist/policy-parser.d.ts +192 -0
- package/dist/policy-parser.d.ts.map +1 -0
- package/dist/policy-parser.js +153 -0
- package/dist/policy-parser.js.map +1 -0
- package/dist/signing.d.ts +34 -0
- package/dist/signing.d.ts.map +1 -0
- package/dist/signing.js +79 -0
- package/dist/signing.js.map +1 -0
- package/dist/state.d.ts +11 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +111 -0
- package/dist/state.js.map +1 -0
- package/dist/tokens.d.ts +38 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +56 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +273 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +67 -0
- package/dist/types.js.map +1 -0
- package/package.json +20 -19
- package/README.md +0 -46
- package/index.js +0 -3
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.issueProofToken = issueProofToken;
|
|
4
|
+
exports.verifyProofToken = verifyProofToken;
|
|
5
|
+
const paseto_1 = require("paseto");
|
|
6
|
+
const keys_js_1 = require("./keys.js");
|
|
7
|
+
async function issueProofToken(params) {
|
|
8
|
+
const now = new Date();
|
|
9
|
+
const exp = new Date(now.getTime() + params.ttlSeconds * 1000);
|
|
10
|
+
const claims = {
|
|
11
|
+
iss: 'openleash',
|
|
12
|
+
kid: params.key.kid,
|
|
13
|
+
iat: now.toISOString(),
|
|
14
|
+
exp: exp.toISOString(),
|
|
15
|
+
decision_id: params.decisionId,
|
|
16
|
+
owner_principal_id: params.ownerPrincipalId,
|
|
17
|
+
agent_id: params.agentId,
|
|
18
|
+
action_type: params.actionType,
|
|
19
|
+
action_hash: params.actionHash,
|
|
20
|
+
matched_rule_id: params.matchedRuleId,
|
|
21
|
+
};
|
|
22
|
+
if (params.trustProfile) {
|
|
23
|
+
claims.trust_profile = params.trustProfile;
|
|
24
|
+
}
|
|
25
|
+
if (params.constraintsSnapshot) {
|
|
26
|
+
claims.constraints_snapshot = params.constraintsSnapshot;
|
|
27
|
+
}
|
|
28
|
+
const privateKey = (0, keys_js_1.getPrivateKeyObject)(params.key);
|
|
29
|
+
const token = await paseto_1.V4.sign({ ...claims }, privateKey, {
|
|
30
|
+
expiresIn: `${params.ttlSeconds} seconds`,
|
|
31
|
+
});
|
|
32
|
+
return { token, expiresAt: exp.toISOString(), claims };
|
|
33
|
+
}
|
|
34
|
+
async function verifyProofToken(token, keys) {
|
|
35
|
+
// Try each key
|
|
36
|
+
for (const key of keys) {
|
|
37
|
+
try {
|
|
38
|
+
const publicKey = (0, keys_js_1.getPublicKeyObject)(key);
|
|
39
|
+
const payload = await paseto_1.V4.verify(token, publicKey);
|
|
40
|
+
// Check expiration
|
|
41
|
+
if (payload.exp) {
|
|
42
|
+
const expDate = new Date(payload.exp);
|
|
43
|
+
if (expDate.getTime() < Date.now()) {
|
|
44
|
+
return { valid: false, reason: 'Token expired', claims: payload };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { valid: true, claims: payload };
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Try next key
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { valid: false, reason: 'No matching key found or invalid signature' };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":";;AAiCA,0CAkCC;AAED,4CA0BC;AA9FD,mCAA4B;AAE5B,uCAAoE;AA8B7D,KAAK,UAAU,eAAe,CAAC,MAAwB;IAK5D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAE/D,MAAM,MAAM,GAAgB;QAC1B,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG;QACnB,GAAG,EAAE,GAAG,CAAC,WAAW,EAAE;QACtB,GAAG,EAAE,GAAG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;gBACtC,IAAI,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;oBACnC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;gBACpE,CAAC;YACH,CAAC;YAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;YACf,SAAS;QACX,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,4CAA4C,EAAE,CAAC;AAChF,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DecisionResult: z.ZodEnum<["ALLOW", "DENY", "REQUIRE_APPROVAL", "REQUIRE_STEP_UP", "REQUIRE_DEPOSIT"]>;
|
|
3
|
+
export type DecisionResult = z.infer<typeof DecisionResult>;
|
|
4
|
+
export declare const ObligationType: z.ZodEnum<["HUMAN_APPROVAL", "STEP_UP_AUTH", "DEPOSIT", "COUNTERPARTY_ATTESTATION"]>;
|
|
5
|
+
export type ObligationType = z.infer<typeof ObligationType>;
|
|
6
|
+
export declare const ObligationStatus: z.ZodEnum<["PENDING", "FULFILLED", "WAIVED"]>;
|
|
7
|
+
export type ObligationStatus = z.infer<typeof ObligationStatus>;
|
|
8
|
+
export declare const PrincipalType: z.ZodEnum<["HUMAN", "ORG"]>;
|
|
9
|
+
export type PrincipalType = z.infer<typeof PrincipalType>;
|
|
10
|
+
export declare const PrincipalStatus: z.ZodEnum<["ACTIVE", "SUSPENDED", "REVOKED"]>;
|
|
11
|
+
export type PrincipalStatus = z.infer<typeof PrincipalStatus>;
|
|
12
|
+
export declare const AgentStatus: z.ZodEnum<["ACTIVE", "REVOKED"]>;
|
|
13
|
+
export type AgentStatus = z.infer<typeof AgentStatus>;
|
|
14
|
+
export declare const TrustProfile: z.ZodEnum<["LOW", "MEDIUM", "HIGH", "REGULATED"]>;
|
|
15
|
+
export type TrustProfile = z.infer<typeof TrustProfile>;
|
|
16
|
+
export declare const AssuranceLevel: z.ZodEnum<["LOW", "SUBSTANTIAL", "HIGH"]>;
|
|
17
|
+
export type AssuranceLevel = z.infer<typeof AssuranceLevel>;
|
|
18
|
+
export declare const ActionRequestSchema: z.ZodObject<{
|
|
19
|
+
action_id: z.ZodString;
|
|
20
|
+
action_type: z.ZodString;
|
|
21
|
+
requested_at: z.ZodString;
|
|
22
|
+
principal: z.ZodObject<{
|
|
23
|
+
agent_id: z.ZodString;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
agent_id: string;
|
|
26
|
+
}, {
|
|
27
|
+
agent_id: string;
|
|
28
|
+
}>;
|
|
29
|
+
subject: z.ZodObject<{
|
|
30
|
+
principal_id: z.ZodString;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
principal_id: string;
|
|
33
|
+
}, {
|
|
34
|
+
principal_id: string;
|
|
35
|
+
}>;
|
|
36
|
+
relying_party: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
rp_id: z.ZodOptional<z.ZodString>;
|
|
38
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
39
|
+
trust_profile: z.ZodOptional<z.ZodEnum<["LOW", "MEDIUM", "HIGH", "REGULATED"]>>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
rp_id?: string | undefined;
|
|
42
|
+
domain?: string | undefined;
|
|
43
|
+
trust_profile?: "LOW" | "MEDIUM" | "HIGH" | "REGULATED" | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
rp_id?: string | undefined;
|
|
46
|
+
domain?: string | undefined;
|
|
47
|
+
trust_profile?: "LOW" | "MEDIUM" | "HIGH" | "REGULATED" | undefined;
|
|
48
|
+
}>>;
|
|
49
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
action_id: string;
|
|
52
|
+
action_type: string;
|
|
53
|
+
requested_at: string;
|
|
54
|
+
principal: {
|
|
55
|
+
agent_id: string;
|
|
56
|
+
};
|
|
57
|
+
subject: {
|
|
58
|
+
principal_id: string;
|
|
59
|
+
};
|
|
60
|
+
payload: Record<string, unknown>;
|
|
61
|
+
relying_party?: {
|
|
62
|
+
rp_id?: string | undefined;
|
|
63
|
+
domain?: string | undefined;
|
|
64
|
+
trust_profile?: "LOW" | "MEDIUM" | "HIGH" | "REGULATED" | undefined;
|
|
65
|
+
} | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
action_id: string;
|
|
68
|
+
action_type: string;
|
|
69
|
+
requested_at: string;
|
|
70
|
+
principal: {
|
|
71
|
+
agent_id: string;
|
|
72
|
+
};
|
|
73
|
+
subject: {
|
|
74
|
+
principal_id: string;
|
|
75
|
+
};
|
|
76
|
+
payload: Record<string, unknown>;
|
|
77
|
+
relying_party?: {
|
|
78
|
+
rp_id?: string | undefined;
|
|
79
|
+
domain?: string | undefined;
|
|
80
|
+
trust_profile?: "LOW" | "MEDIUM" | "HIGH" | "REGULATED" | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
}>;
|
|
83
|
+
export type ActionRequest = z.infer<typeof ActionRequestSchema>;
|
|
84
|
+
export declare const ObligationSchema: z.ZodObject<{
|
|
85
|
+
obligation_id: z.ZodString;
|
|
86
|
+
type: z.ZodEnum<["HUMAN_APPROVAL", "STEP_UP_AUTH", "DEPOSIT", "COUNTERPARTY_ATTESTATION"]>;
|
|
87
|
+
status: z.ZodEnum<["PENDING", "FULFILLED", "WAIVED"]>;
|
|
88
|
+
details_json: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
89
|
+
}, "strip", z.ZodTypeAny, {
|
|
90
|
+
type: "HUMAN_APPROVAL" | "STEP_UP_AUTH" | "DEPOSIT" | "COUNTERPARTY_ATTESTATION";
|
|
91
|
+
status: "PENDING" | "FULFILLED" | "WAIVED";
|
|
92
|
+
obligation_id: string;
|
|
93
|
+
details_json?: Record<string, unknown> | undefined;
|
|
94
|
+
}, {
|
|
95
|
+
type: "HUMAN_APPROVAL" | "STEP_UP_AUTH" | "DEPOSIT" | "COUNTERPARTY_ATTESTATION";
|
|
96
|
+
status: "PENDING" | "FULFILLED" | "WAIVED";
|
|
97
|
+
obligation_id: string;
|
|
98
|
+
details_json?: Record<string, unknown> | undefined;
|
|
99
|
+
}>;
|
|
100
|
+
export type Obligation = z.infer<typeof ObligationSchema>;
|
|
101
|
+
export interface AuthorizeResponse {
|
|
102
|
+
decision_id: string;
|
|
103
|
+
action_id: string;
|
|
104
|
+
action_hash: string;
|
|
105
|
+
result: DecisionResult;
|
|
106
|
+
matched_rule_id: string | null;
|
|
107
|
+
reason: string;
|
|
108
|
+
proof_token: string | null;
|
|
109
|
+
proof_expires_at: string | null;
|
|
110
|
+
obligations: Obligation[];
|
|
111
|
+
}
|
|
112
|
+
export interface PolicyExprMatch {
|
|
113
|
+
path: string;
|
|
114
|
+
op: 'eq' | 'neq' | 'in' | 'nin' | 'lt' | 'lte' | 'gt' | 'gte' | 'regex' | 'exists';
|
|
115
|
+
value?: unknown;
|
|
116
|
+
}
|
|
117
|
+
export type PolicyExpr = {
|
|
118
|
+
all: PolicyExpr[];
|
|
119
|
+
} | {
|
|
120
|
+
any: PolicyExpr[];
|
|
121
|
+
} | {
|
|
122
|
+
not: PolicyExpr;
|
|
123
|
+
} | {
|
|
124
|
+
match: PolicyExprMatch;
|
|
125
|
+
};
|
|
126
|
+
export interface PolicyConstraints {
|
|
127
|
+
amount_max?: number;
|
|
128
|
+
amount_min?: number;
|
|
129
|
+
currency?: string[];
|
|
130
|
+
merchant_domain?: string[];
|
|
131
|
+
allowed_domains?: string[];
|
|
132
|
+
blocked_domains?: string[];
|
|
133
|
+
}
|
|
134
|
+
export interface PolicyRequirements {
|
|
135
|
+
min_assurance_level?: 'LOW' | 'SUBSTANTIAL' | 'HIGH';
|
|
136
|
+
credential_scheme?: string;
|
|
137
|
+
}
|
|
138
|
+
export interface PolicyObligation {
|
|
139
|
+
type: string;
|
|
140
|
+
params?: Record<string, unknown>;
|
|
141
|
+
}
|
|
142
|
+
export interface PolicyProof {
|
|
143
|
+
required?: boolean;
|
|
144
|
+
ttl_seconds?: number;
|
|
145
|
+
}
|
|
146
|
+
export interface PolicyRule {
|
|
147
|
+
id: string;
|
|
148
|
+
effect: 'allow' | 'deny';
|
|
149
|
+
action: string;
|
|
150
|
+
description?: string;
|
|
151
|
+
when?: PolicyExpr;
|
|
152
|
+
constraints?: PolicyConstraints;
|
|
153
|
+
requirements?: PolicyRequirements;
|
|
154
|
+
obligations?: PolicyObligation[];
|
|
155
|
+
proof?: PolicyProof;
|
|
156
|
+
}
|
|
157
|
+
export interface Policy {
|
|
158
|
+
version: 1;
|
|
159
|
+
default: 'allow' | 'deny';
|
|
160
|
+
rules: PolicyRule[];
|
|
161
|
+
}
|
|
162
|
+
export interface RuleTrace {
|
|
163
|
+
rule_id: string;
|
|
164
|
+
pattern_match: boolean;
|
|
165
|
+
when_match: boolean | null;
|
|
166
|
+
constraints_match: boolean | null;
|
|
167
|
+
final_match: boolean;
|
|
168
|
+
}
|
|
169
|
+
export interface EvaluationTrace {
|
|
170
|
+
rules: RuleTrace[];
|
|
171
|
+
}
|
|
172
|
+
export interface StateKeyEntry {
|
|
173
|
+
kid: string;
|
|
174
|
+
path: string;
|
|
175
|
+
}
|
|
176
|
+
export interface StateOwnerEntry {
|
|
177
|
+
owner_principal_id: string;
|
|
178
|
+
path: string;
|
|
179
|
+
}
|
|
180
|
+
export interface StateAgentEntry {
|
|
181
|
+
agent_principal_id: string;
|
|
182
|
+
agent_id: string;
|
|
183
|
+
owner_principal_id: string;
|
|
184
|
+
path: string;
|
|
185
|
+
}
|
|
186
|
+
export interface StatePolicyEntry {
|
|
187
|
+
policy_id: string;
|
|
188
|
+
owner_principal_id: string;
|
|
189
|
+
applies_to_agent_principal_id: string | null;
|
|
190
|
+
path: string;
|
|
191
|
+
}
|
|
192
|
+
export interface StateBinding {
|
|
193
|
+
owner_principal_id: string;
|
|
194
|
+
policy_id: string;
|
|
195
|
+
applies_to_agent_principal_id: string | null;
|
|
196
|
+
}
|
|
197
|
+
export interface StateData {
|
|
198
|
+
version: 1;
|
|
199
|
+
created_at: string;
|
|
200
|
+
server_keys: {
|
|
201
|
+
active_kid: string;
|
|
202
|
+
keys: StateKeyEntry[];
|
|
203
|
+
};
|
|
204
|
+
owners: StateOwnerEntry[];
|
|
205
|
+
agents: StateAgentEntry[];
|
|
206
|
+
policies: StatePolicyEntry[];
|
|
207
|
+
bindings: StateBinding[];
|
|
208
|
+
}
|
|
209
|
+
export interface ServerKeyFile {
|
|
210
|
+
kid: string;
|
|
211
|
+
public_key_b64: string;
|
|
212
|
+
private_key_b64: string;
|
|
213
|
+
created_at: string;
|
|
214
|
+
revoked_at: string | null;
|
|
215
|
+
}
|
|
216
|
+
export interface OwnerFrontmatter {
|
|
217
|
+
owner_principal_id: string;
|
|
218
|
+
principal_type: PrincipalType;
|
|
219
|
+
display_name: string;
|
|
220
|
+
status: PrincipalStatus;
|
|
221
|
+
attributes: Record<string, unknown>;
|
|
222
|
+
created_at: string;
|
|
223
|
+
}
|
|
224
|
+
export interface AgentFrontmatter {
|
|
225
|
+
agent_principal_id: string;
|
|
226
|
+
agent_id: string;
|
|
227
|
+
owner_principal_id: string;
|
|
228
|
+
public_key_b64: string;
|
|
229
|
+
status: AgentStatus;
|
|
230
|
+
attributes: Record<string, unknown>;
|
|
231
|
+
created_at: string;
|
|
232
|
+
revoked_at: string | null;
|
|
233
|
+
}
|
|
234
|
+
export declare const AuditEventType: z.ZodEnum<["OWNER_CREATED", "AGENT_CHALLENGE_ISSUED", "AGENT_REGISTERED", "POLICY_UPSERTED", "AUTHORIZE_CALLED", "DECISION_CREATED", "PROOF_ISSUED", "PROOF_VERIFIED", "PLAYGROUND_RUN", "KEY_ROTATED", "SERVER_STARTED"]>;
|
|
235
|
+
export type AuditEventType = z.infer<typeof AuditEventType>;
|
|
236
|
+
export interface AuditEvent {
|
|
237
|
+
event_id: string;
|
|
238
|
+
timestamp: string;
|
|
239
|
+
event_type: string;
|
|
240
|
+
principal_id: string | null;
|
|
241
|
+
action_id: string | null;
|
|
242
|
+
decision_id: string | null;
|
|
243
|
+
metadata_json: Record<string, unknown>;
|
|
244
|
+
}
|
|
245
|
+
export interface OpenleashConfig {
|
|
246
|
+
server: {
|
|
247
|
+
bind_address: string;
|
|
248
|
+
};
|
|
249
|
+
admin: {
|
|
250
|
+
mode: 'localhost' | 'token' | 'localhost_or_token';
|
|
251
|
+
token: string;
|
|
252
|
+
allow_remote_admin: boolean;
|
|
253
|
+
};
|
|
254
|
+
security: {
|
|
255
|
+
nonce_ttl_seconds: number;
|
|
256
|
+
clock_skew_seconds: number;
|
|
257
|
+
};
|
|
258
|
+
tokens: {
|
|
259
|
+
format: 'paseto_v4_public';
|
|
260
|
+
default_ttl_seconds: number;
|
|
261
|
+
max_ttl_seconds: number;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
export interface RegistrationChallenge {
|
|
265
|
+
challenge_id: string;
|
|
266
|
+
challenge_b64: string;
|
|
267
|
+
agent_id: string;
|
|
268
|
+
agent_pubkey_b64: string;
|
|
269
|
+
owner_principal_id?: string;
|
|
270
|
+
agent_attributes_json?: Record<string, unknown>;
|
|
271
|
+
expires_at: string;
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,cAAc,wFAMzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,C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B,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditEventType = exports.ObligationSchema = exports.ActionRequestSchema = exports.AssuranceLevel = exports.TrustProfile = exports.AgentStatus = exports.PrincipalStatus = exports.PrincipalType = exports.ObligationStatus = exports.ObligationType = exports.DecisionResult = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
// ─── Decision results ────────────────────────────────────────────────
|
|
6
|
+
exports.DecisionResult = zod_1.z.enum([
|
|
7
|
+
'ALLOW',
|
|
8
|
+
'DENY',
|
|
9
|
+
'REQUIRE_APPROVAL',
|
|
10
|
+
'REQUIRE_STEP_UP',
|
|
11
|
+
'REQUIRE_DEPOSIT',
|
|
12
|
+
]);
|
|
13
|
+
// ─── Obligation types ────────────────────────────────────────────────
|
|
14
|
+
exports.ObligationType = zod_1.z.enum([
|
|
15
|
+
'HUMAN_APPROVAL',
|
|
16
|
+
'STEP_UP_AUTH',
|
|
17
|
+
'DEPOSIT',
|
|
18
|
+
'COUNTERPARTY_ATTESTATION',
|
|
19
|
+
]);
|
|
20
|
+
exports.ObligationStatus = zod_1.z.enum(['PENDING', 'FULFILLED', 'WAIVED']);
|
|
21
|
+
// ─── Principal types ─────────────────────────────────────────────────
|
|
22
|
+
exports.PrincipalType = zod_1.z.enum(['HUMAN', 'ORG']);
|
|
23
|
+
exports.PrincipalStatus = zod_1.z.enum(['ACTIVE', 'SUSPENDED', 'REVOKED']);
|
|
24
|
+
exports.AgentStatus = zod_1.z.enum(['ACTIVE', 'REVOKED']);
|
|
25
|
+
// ─── Trust profiles ──────────────────────────────────────────────────
|
|
26
|
+
exports.TrustProfile = zod_1.z.enum(['LOW', 'MEDIUM', 'HIGH', 'REGULATED']);
|
|
27
|
+
exports.AssuranceLevel = zod_1.z.enum(['LOW', 'SUBSTANTIAL', 'HIGH']);
|
|
28
|
+
// ─── ActionRequest ───────────────────────────────────────────────────
|
|
29
|
+
exports.ActionRequestSchema = zod_1.z.object({
|
|
30
|
+
action_id: zod_1.z.string().uuid(),
|
|
31
|
+
action_type: zod_1.z.string().min(1),
|
|
32
|
+
requested_at: zod_1.z.string(), // RFC3339
|
|
33
|
+
principal: zod_1.z.object({
|
|
34
|
+
agent_id: zod_1.z.string().min(1),
|
|
35
|
+
}),
|
|
36
|
+
subject: zod_1.z.object({
|
|
37
|
+
principal_id: zod_1.z.string().uuid(),
|
|
38
|
+
}),
|
|
39
|
+
relying_party: zod_1.z.object({
|
|
40
|
+
rp_id: zod_1.z.string().uuid().optional(),
|
|
41
|
+
domain: zod_1.z.string().optional(),
|
|
42
|
+
trust_profile: exports.TrustProfile.optional(),
|
|
43
|
+
}).optional(),
|
|
44
|
+
payload: zod_1.z.record(zod_1.z.unknown()),
|
|
45
|
+
});
|
|
46
|
+
// ─── Obligation ──────────────────────────────────────────────────────
|
|
47
|
+
exports.ObligationSchema = zod_1.z.object({
|
|
48
|
+
obligation_id: zod_1.z.string().uuid(),
|
|
49
|
+
type: exports.ObligationType,
|
|
50
|
+
status: exports.ObligationStatus,
|
|
51
|
+
details_json: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
52
|
+
});
|
|
53
|
+
// ─── Audit event ─────────────────────────────────────────────────────
|
|
54
|
+
exports.AuditEventType = zod_1.z.enum([
|
|
55
|
+
'OWNER_CREATED',
|
|
56
|
+
'AGENT_CHALLENGE_ISSUED',
|
|
57
|
+
'AGENT_REGISTERED',
|
|
58
|
+
'POLICY_UPSERTED',
|
|
59
|
+
'AUTHORIZE_CALLED',
|
|
60
|
+
'DECISION_CREATED',
|
|
61
|
+
'PROOF_ISSUED',
|
|
62
|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kBAAkB;IAClB,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,aAAa;IACb,gBAAgB;CACjB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
"private": false,
|
|
3
|
-
"publishConfig": {
|
|
4
|
-
"access": "public"
|
|
5
|
-
},
|
|
6
2
|
"name": "@openleash/core",
|
|
7
|
-
"version": "0.0
|
|
8
|
-
"description": "Core authorization
|
|
9
|
-
"main": "index.js",
|
|
10
|
-
"types": "index.d.ts",
|
|
11
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Core authorization engine for openleash",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"files": ["dist", "LICENSE"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc -b"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"ajv": "^8.12.0",
|
|
13
|
+
"json-canonicalize": "^1.0.6",
|
|
14
|
+
"paseto": "^3.1.4",
|
|
15
|
+
"yaml": "^2.3.4",
|
|
16
|
+
"zod": "^3.22.4"
|
|
17
|
+
},
|
|
18
|
+
"license": "Apache-2.0",
|
|
12
19
|
"repository": {
|
|
13
20
|
"type": "git",
|
|
14
21
|
"url": "git+https://github.com/openleash/openleash.git",
|
|
15
22
|
"directory": "packages/core"
|
|
16
23
|
},
|
|
17
|
-
"homepage": "https://openleash
|
|
18
|
-
"
|
|
19
|
-
"openleash"
|
|
20
|
-
|
|
21
|
-
"ai-agents",
|
|
22
|
-
"policy-engine",
|
|
23
|
-
"paseto",
|
|
24
|
-
"proof-tokens",
|
|
25
|
-
"security"
|
|
26
|
-
]
|
|
24
|
+
"homepage": "https://github.com/openleash/openleash/tree/main/packages/core",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/openleash/openleash/issues"
|
|
27
|
+
}
|
|
27
28
|
}
|
package/README.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# @openleash/core
|
|
2
|
-
|
|
3
|
-
Core authorization and proof engine for [OpenLeash](https://openleash.ai).
|
|
4
|
-
|
|
5
|
-
> **This package is a placeholder.** The full implementation is under active development.
|
|
6
|
-
|
|
7
|
-
## What is OpenLeash?
|
|
8
|
-
|
|
9
|
-
OpenLeash is a local-first authorization and proof sidecar for AI agents. It answers two questions:
|
|
10
|
-
|
|
11
|
-
1. **Is this agent allowed to do this action right now?**
|
|
12
|
-
2. **Can the agent produce a cryptographic proof that others can verify?**
|
|
13
|
-
|
|
14
|
-
## What does `@openleash/core` provide?
|
|
15
|
-
|
|
16
|
-
This package contains the core logic that powers OpenLeash:
|
|
17
|
-
|
|
18
|
-
- **Policy engine** — Evaluates structured `ActionRequest` objects against YAML policies and returns a `DecisionResult` (`ALLOW`, `DENY`, `REQUIRE_APPROVAL`, `REQUIRE_STEP_UP`, `REQUIRE_DEPOSIT`).
|
|
19
|
-
- **Expression evaluator** — A safe, sandboxed expression language for policy `when` clauses supporting `all`, `any`, `not`, and `match` operators with JSONPath-lite accessors.
|
|
20
|
-
- **Constraints evaluation** — Built-in constraint shortcuts for `amount_max`, `amount_min`, `currency`, `merchant_domain`, `allowed_domains`, and `blocked_domains`.
|
|
21
|
-
- **Obligations & precedence** — Computes obligations from matched rules and maps them to the final decision using blocking precedence (`HUMAN_APPROVAL` > `STEP_UP_AUTH` > `DEPOSIT` > `COUNTERPARTY_ATTESTATION`).
|
|
22
|
-
- **Canonical hashing** — RFC 8785 JSON Canonicalization Scheme (JCS) for deterministic `action_hash` computation.
|
|
23
|
-
- **Proof token issuance & verification** — PASETO v4.public (Ed25519) tokens bound to `action_hash`.
|
|
24
|
-
- **File-based state management** — Read/write for `state.md`, owner/agent markdown files, and policy YAML.
|
|
25
|
-
- **Audit logging** — Append-only JSONL audit log.
|
|
26
|
-
- **Nonce replay cache** — In-memory TTL cache to prevent request replay.
|
|
27
|
-
|
|
28
|
-
## Installation
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npm install @openleash/core
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Status
|
|
35
|
-
|
|
36
|
-
This package is under active development. See the [OpenLeash repository](https://github.com/openleash/openleash) for progress and documentation.
|
|
37
|
-
|
|
38
|
-
## Links
|
|
39
|
-
|
|
40
|
-
- [OpenLeash website](https://openleash.ai)
|
|
41
|
-
- [GitHub repository](https://github.com/openleash/openleash)
|
|
42
|
-
- [OpenClaw](https://openclaw.ai) — agent runtime that integrates with OpenLeash
|
|
43
|
-
|
|
44
|
-
## License
|
|
45
|
-
|
|
46
|
-
MIT
|
package/index.js
DELETED