@atlasauth/pca-analyzer 0.0.0-stage → 0.2.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 +21 -0
- package/README.md +109 -2
- package/dist/caveats.d.ts +22 -0
- package/dist/caveats.js +88 -0
- package/dist/caveats.js.map +1 -0
- package/dist/enumerate.d.ts +68 -0
- package/dist/enumerate.js +375 -0
- package/dist/enumerate.js.map +1 -0
- package/dist/field.d.ts +42 -0
- package/dist/field.js +232 -0
- package/dist/field.js.map +1 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +374 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +109 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":";;;AA8DA,kCAoFC;AAcD,0CA2CC;AAGD,sCAIC;AASD,sEAOC;AAlOD,wCAAmF;AAEnF;;;;;;;;;;;;;GAaG;AAEH,uGAAuG;AAC1F,QAAA,YAAY,GAAG,6CAA6C,CAAC;AAE1E,SAAS,cAAc,CAAC,CAAU;IAChC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,UAA6B;IACpD,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;I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EAAE,CAAC,WAAW,CAAC,CAAC;IAChE,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAAC,UAAgC;IAC5E,IAAI,EAAE,GAAG,qBAAa,CAAC;IACvB,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAA,qBAAe,EAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,SAAS;YAAE,SAAS;QACzD,EAAE,GAAG,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @atlasauth/pca-analyzer — STATIC ANALYZABILITY OF AUTHORITY.
|
|
3
|
+
*
|
|
4
|
+
* PCA can prove a quantitative trust-budget bound and verify a single action, but on its own it cannot
|
|
5
|
+
* statically answer "what can this whole delegated authority EVER do?". This package decides that over
|
|
6
|
+
* PCA's predicate/caveat policy: reachability, vacuity/totality, delegation-safety subsumption,
|
|
7
|
+
* disjointness, equivalence, and — the distinct safety check — conformance to a declared intent
|
|
8
|
+
* envelope (the "$14k renewal under a $10k cap on an approved vendor still violates intent" class).
|
|
9
|
+
*
|
|
10
|
+
* The engine is a SOUND, BOUNDED decision procedure (Cedar/SymCC-style, but with no SMT dependency):
|
|
11
|
+
* it enumerates a finite, distinguishing set of representative actions built from the literals,
|
|
12
|
+
* thresholds, prefixes, verbs and resource matchers in the policies, and evaluates the REAL
|
|
13
|
+
* `evaluatePredicates` at each. See README.md for the exact decided fragment and the honest
|
|
14
|
+
* incompleteness boundary. Soundness rule: a verdict is reported as proven only when the fragment is
|
|
15
|
+
* fully decided; otherwise it fails safe and is marked `approximate`.
|
|
16
|
+
*/
|
|
17
|
+
import type { Condition } from '@atlasauth/pca';
|
|
18
|
+
import { admits, admitsAction, collectProbes, repToAction, representatives, search, type Rep } from './enumerate';
|
|
19
|
+
import type { AlwaysAllowsResult, AlwaysDeniesResult, AnalyzerAction, DisjointResult, EquivalentResult, Intent, IntentConformanceResult, PolicyInput, ReachableResult, SubsumesResult } from './types';
|
|
20
|
+
export * from './types';
|
|
21
|
+
export { analyzeCaveats } from './caveats';
|
|
22
|
+
export type { CaveatAnalysis } from './caveats';
|
|
23
|
+
export { numericConjunctionSatisfiable, tightenInterval, intervalEmpty, FULL_INTERVAL, type NumInterval, } from './field';
|
|
24
|
+
export { DEFAULT_MAX_COMBINATIONS, toModel, type PolicyModel } from './enumerate';
|
|
25
|
+
export interface AnalyzerOptions {
|
|
26
|
+
/** Cap on the representative grid size; a larger grid fails safe (`approximate`). */
|
|
27
|
+
maxCombinations?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Can any input complete `action` into one the policy ALLOWs? (some predicate matches AND the caveat
|
|
31
|
+
* set is satisfiable). `verb` and `resource` are taken as given; unspecified `params` / `subject` /
|
|
32
|
+
* `env` fields are existentially searched. A returned `witness` is a concrete action verified against
|
|
33
|
+
* the real evaluator, so `reachable: true` is always proven. `reachable: false` is proven only for the
|
|
34
|
+
* decided fragment; otherwise it fails safe to `reachable: true, approximate: true`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function reachable(policy: PolicyInput, action: AnalyzerAction, opts?: AnalyzerOptions): ReachableResult;
|
|
37
|
+
/**
|
|
38
|
+
* Is the policy vacuous — does it deny everything (optionally restricted to `verb`)? Proven only for
|
|
39
|
+
* the decided fragment; any undecidable feature or grid overflow fails safe to `alwaysDenies: false`
|
|
40
|
+
* (assume it can admit something).
|
|
41
|
+
*/
|
|
42
|
+
export declare function alwaysDenies(policy: PolicyInput, verb?: string, opts?: AnalyzerOptions): AlwaysDeniesResult;
|
|
43
|
+
/**
|
|
44
|
+
* Is the policy total for `verb` — does it admit EVERY action of that verb (any resource, any params)?
|
|
45
|
+
* Proven only for the decided fragment; any undecidable feature or grid overflow fails safe to
|
|
46
|
+
* `alwaysAllows: false`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function alwaysAllows(policy: PolicyInput, verb: string, opts?: AnalyzerOptions): AlwaysAllowsResult;
|
|
49
|
+
/**
|
|
50
|
+
* Does policy `a` permit everything `b` permits (admitted(b) ⊆ admitted(a))? This is the
|
|
51
|
+
* delegation-safety check: a child capability must be subsumed by its parent. A counterexample is an
|
|
52
|
+
* action `b` admits that `a` denies. Proven only for the decided fragment; any undecidable feature in
|
|
53
|
+
* either policy, or grid overflow, fails safe to `subsumes: false`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function subsumes(a: PolicyInput, b: PolicyInput, opts?: AnalyzerOptions): SubsumesResult;
|
|
56
|
+
/**
|
|
57
|
+
* Are the two policies' admitted sets disjoint (no action both admit)? A witness is an action both
|
|
58
|
+
* admit. Proven only for the decided fragment; otherwise fails safe to `disjoint: false`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function disjoint(a: PolicyInput, b: PolicyInput, opts?: AnalyzerOptions): DisjointResult;
|
|
61
|
+
/**
|
|
62
|
+
* Do the two policies admit exactly the same actions? A counterexample is an action admitted by one
|
|
63
|
+
* but not the other. Proven only for the decided fragment; otherwise fails safe to `equivalent: false`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function equivalent(a: PolicyInput, b: PolicyInput, opts?: AnalyzerOptions): EquivalentResult;
|
|
66
|
+
/**
|
|
67
|
+
* Does the policy admit ONLY actions inside the declared `intent` envelope (allowed verbs + resource
|
|
68
|
+
* scopes + an amount ceiling)? This is the key safety check distinct from the runtime trust-budget: an
|
|
69
|
+
* action can pass the policy's predicates and stay under budget yet still fall outside what the
|
|
70
|
+
* principal intended — e.g. a $14k renewal admitted under a $10k intent cap because the policy's own
|
|
71
|
+
* ceiling is higher (or absent). Each reported violation is a concrete admitted action outside the
|
|
72
|
+
* envelope, so `conforms: false` with violations is always proven. `conforms: true` is proven only for
|
|
73
|
+
* the decided fragment; an undecidable policy feature, a `re:` intent scope, or grid overflow fails
|
|
74
|
+
* safe to `conforms: false, approximate: true` with no violations listed.
|
|
75
|
+
*/
|
|
76
|
+
export declare function intentConformance(policy: PolicyInput, intent: Intent, opts?: AnalyzerOptions): IntentConformanceResult;
|
|
77
|
+
/** Concrete, exact admission check for a fully-specified action (no existential search). */
|
|
78
|
+
export declare function admitsConcrete(policy: PolicyInput, action: AnalyzerAction): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Whether a predicate's own numeric `where` conjunction is satisfiable (an explicit use of the interval
|
|
81
|
+
* engine; e.g. `amount >= 100 AND amount <= 10` is not). Non-numeric / `ref` conditions are ignored.
|
|
82
|
+
*/
|
|
83
|
+
export declare function predicateNumericSatisfiable(where: readonly Condition[] | undefined): boolean;
|
|
84
|
+
export { admits, admitsAction, collectProbes, representatives, repToAction, search, type Rep };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @atlasauth/pca-analyzer — STATIC ANALYZABILITY OF AUTHORITY.
|
|
4
|
+
*
|
|
5
|
+
* PCA can prove a quantitative trust-budget bound and verify a single action, but on its own it cannot
|
|
6
|
+
* statically answer "what can this whole delegated authority EVER do?". This package decides that over
|
|
7
|
+
* PCA's predicate/caveat policy: reachability, vacuity/totality, delegation-safety subsumption,
|
|
8
|
+
* disjointness, equivalence, and — the distinct safety check — conformance to a declared intent
|
|
9
|
+
* envelope (the "$14k renewal under a $10k cap on an approved vendor still violates intent" class).
|
|
10
|
+
*
|
|
11
|
+
* The engine is a SOUND, BOUNDED decision procedure (Cedar/SymCC-style, but with no SMT dependency):
|
|
12
|
+
* it enumerates a finite, distinguishing set of representative actions built from the literals,
|
|
13
|
+
* thresholds, prefixes, verbs and resource matchers in the policies, and evaluates the REAL
|
|
14
|
+
* `evaluatePredicates` at each. See README.md for the exact decided fragment and the honest
|
|
15
|
+
* incompleteness boundary. Soundness rule: a verdict is reported as proven only when the fragment is
|
|
16
|
+
* fully decided; otherwise it fails safe and is marked `approximate`.
|
|
17
|
+
*/
|
|
18
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(o, k2, desc);
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
30
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.search = exports.repToAction = exports.representatives = exports.collectProbes = exports.admitsAction = exports.admits = exports.toModel = exports.DEFAULT_MAX_COMBINATIONS = exports.FULL_INTERVAL = exports.intervalEmpty = exports.tightenInterval = exports.numericConjunctionSatisfiable = exports.analyzeCaveats = void 0;
|
|
34
|
+
exports.reachable = reachable;
|
|
35
|
+
exports.alwaysDenies = alwaysDenies;
|
|
36
|
+
exports.alwaysAllows = alwaysAllows;
|
|
37
|
+
exports.subsumes = subsumes;
|
|
38
|
+
exports.disjoint = disjoint;
|
|
39
|
+
exports.equivalent = equivalent;
|
|
40
|
+
exports.intentConformance = intentConformance;
|
|
41
|
+
exports.admitsConcrete = admitsConcrete;
|
|
42
|
+
exports.predicateNumericSatisfiable = predicateNumericSatisfiable;
|
|
43
|
+
const enumerate_1 = require("./enumerate");
|
|
44
|
+
Object.defineProperty(exports, "admits", { enumerable: true, get: function () { return enumerate_1.admits; } });
|
|
45
|
+
Object.defineProperty(exports, "admitsAction", { enumerable: true, get: function () { return enumerate_1.admitsAction; } });
|
|
46
|
+
Object.defineProperty(exports, "collectProbes", { enumerable: true, get: function () { return enumerate_1.collectProbes; } });
|
|
47
|
+
Object.defineProperty(exports, "repToAction", { enumerable: true, get: function () { return enumerate_1.repToAction; } });
|
|
48
|
+
Object.defineProperty(exports, "representatives", { enumerable: true, get: function () { return enumerate_1.representatives; } });
|
|
49
|
+
Object.defineProperty(exports, "search", { enumerable: true, get: function () { return enumerate_1.search; } });
|
|
50
|
+
const field_1 = require("./field");
|
|
51
|
+
const types_1 = require("./types");
|
|
52
|
+
__exportStar(require("./types"), exports);
|
|
53
|
+
var caveats_1 = require("./caveats");
|
|
54
|
+
Object.defineProperty(exports, "analyzeCaveats", { enumerable: true, get: function () { return caveats_1.analyzeCaveats; } });
|
|
55
|
+
var field_2 = require("./field");
|
|
56
|
+
Object.defineProperty(exports, "numericConjunctionSatisfiable", { enumerable: true, get: function () { return field_2.numericConjunctionSatisfiable; } });
|
|
57
|
+
Object.defineProperty(exports, "tightenInterval", { enumerable: true, get: function () { return field_2.tightenInterval; } });
|
|
58
|
+
Object.defineProperty(exports, "intervalEmpty", { enumerable: true, get: function () { return field_2.intervalEmpty; } });
|
|
59
|
+
Object.defineProperty(exports, "FULL_INTERVAL", { enumerable: true, get: function () { return field_2.FULL_INTERVAL; } });
|
|
60
|
+
var enumerate_2 = require("./enumerate");
|
|
61
|
+
Object.defineProperty(exports, "DEFAULT_MAX_COMBINATIONS", { enumerable: true, get: function () { return enumerate_2.DEFAULT_MAX_COMBINATIONS; } });
|
|
62
|
+
Object.defineProperty(exports, "toModel", { enumerable: true, get: function () { return enumerate_2.toModel; } });
|
|
63
|
+
function reversibilityIndex(cls) {
|
|
64
|
+
if (cls === undefined)
|
|
65
|
+
return -1;
|
|
66
|
+
return types_1.REVERSIBILITY_ORDER.indexOf(cls);
|
|
67
|
+
}
|
|
68
|
+
// ---- reachable ------------------------------------------------------------------------------------
|
|
69
|
+
/**
|
|
70
|
+
* Can any input complete `action` into one the policy ALLOWs? (some predicate matches AND the caveat
|
|
71
|
+
* set is satisfiable). `verb` and `resource` are taken as given; unspecified `params` / `subject` /
|
|
72
|
+
* `env` fields are existentially searched. A returned `witness` is a concrete action verified against
|
|
73
|
+
* the real evaluator, so `reachable: true` is always proven. `reachable: false` is proven only for the
|
|
74
|
+
* decided fragment; otherwise it fails safe to `reachable: true, approximate: true`.
|
|
75
|
+
*/
|
|
76
|
+
function reachable(policy, action, opts = {}) {
|
|
77
|
+
const model = (0, enumerate_1.toModel)(policy);
|
|
78
|
+
const max = opts.maxCombinations ?? enumerate_1.DEFAULT_MAX_COMBINATIONS;
|
|
79
|
+
if (!model.caveatSat) {
|
|
80
|
+
return { reachable: false, reason: `caveats unsatisfiable: ${model.caveatReason ?? 'unknown'}` };
|
|
81
|
+
}
|
|
82
|
+
if (action.reversibilityClass !== undefined && model.revCap !== undefined) {
|
|
83
|
+
const idx = reversibilityIndex(action.reversibilityClass);
|
|
84
|
+
if (idx < 0 || idx > model.revCap) {
|
|
85
|
+
return { reachable: false, reason: `reversibility class '${action.reversibilityClass}' exceeds the caveat cap` };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Fast path: the action is already concrete enough to decide directly.
|
|
89
|
+
if ((0, enumerate_1.admitsAction)(model, action)) {
|
|
90
|
+
return { reachable: true, witness: action };
|
|
91
|
+
}
|
|
92
|
+
// Existential search over free fields, with verb/resource fixed and provided params pinned.
|
|
93
|
+
const base = (0, enumerate_1.collectProbes)({ predicateSets: [model.predicates], varyReversibility: model.revCap !== undefined });
|
|
94
|
+
const provided = action.params ?? {};
|
|
95
|
+
const fields = base.fields.map((f) => {
|
|
96
|
+
if (f.path.startsWith('action.params.')) {
|
|
97
|
+
const key = f.path.slice('action.params.'.length);
|
|
98
|
+
if (Object.prototype.hasOwnProperty.call(provided, key)) {
|
|
99
|
+
return { path: f.path, values: [provided[key]] };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return f;
|
|
103
|
+
});
|
|
104
|
+
const revClasses = action.reversibilityClass !== undefined
|
|
105
|
+
? [action.reversibilityClass]
|
|
106
|
+
: model.revCap !== undefined
|
|
107
|
+
? [...types_1.REVERSIBILITY_ORDER]
|
|
108
|
+
: [undefined];
|
|
109
|
+
const pr = { verbs: [action.verb], resources: [action.resource], revClasses, fields };
|
|
110
|
+
const outcome = (0, enumerate_1.search)(pr, (rep) => (0, enumerate_1.admits)(model, rep), max);
|
|
111
|
+
if (outcome.hit !== undefined) {
|
|
112
|
+
const witness = mergeWitness((0, enumerate_1.repToAction)(outcome.hit), action);
|
|
113
|
+
return { reachable: true, witness };
|
|
114
|
+
}
|
|
115
|
+
if (outcome.overflow) {
|
|
116
|
+
return { reachable: true, approximate: true, reason: 'representative grid exceeded the bound; could not prove unreachable' };
|
|
117
|
+
}
|
|
118
|
+
if (model.undecidable.length > 0) {
|
|
119
|
+
return {
|
|
120
|
+
reachable: true,
|
|
121
|
+
approximate: true,
|
|
122
|
+
reason: `over-approximated (${model.undecidable.join('; ')}); could not construct a witness but cannot prove unreachable`,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return { reachable: false, reason: 'no predicate admits this action for any input (proven over the decided fragment)' };
|
|
126
|
+
}
|
|
127
|
+
function mergeWitness(witness, provided) {
|
|
128
|
+
const params = { ...(witness.params ?? {}), ...(provided.params ?? {}) };
|
|
129
|
+
const out = { verb: provided.verb, resource: provided.resource, params };
|
|
130
|
+
const rc = provided.reversibilityClass ?? witness.reversibilityClass;
|
|
131
|
+
if (rc !== undefined)
|
|
132
|
+
out.reversibilityClass = rc;
|
|
133
|
+
if (witness.subject !== undefined)
|
|
134
|
+
out.subject = witness.subject;
|
|
135
|
+
if (witness.env !== undefined)
|
|
136
|
+
out.env = witness.env;
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
// ---- alwaysDenies / alwaysAllows ------------------------------------------------------------------
|
|
140
|
+
/**
|
|
141
|
+
* Is the policy vacuous — does it deny everything (optionally restricted to `verb`)? Proven only for
|
|
142
|
+
* the decided fragment; any undecidable feature or grid overflow fails safe to `alwaysDenies: false`
|
|
143
|
+
* (assume it can admit something).
|
|
144
|
+
*/
|
|
145
|
+
function alwaysDenies(policy, verb, opts = {}) {
|
|
146
|
+
const model = (0, enumerate_1.toModel)(policy);
|
|
147
|
+
const max = opts.maxCombinations ?? enumerate_1.DEFAULT_MAX_COMBINATIONS;
|
|
148
|
+
if (!model.caveatSat) {
|
|
149
|
+
return { alwaysDenies: true, reason: `caveats unsatisfiable: ${model.caveatReason ?? 'unknown'}` };
|
|
150
|
+
}
|
|
151
|
+
const pr = probesFor([model], verb);
|
|
152
|
+
const outcome = (0, enumerate_1.search)(pr, (rep) => (0, enumerate_1.admits)(model, rep), max);
|
|
153
|
+
if (outcome.hit !== undefined) {
|
|
154
|
+
return { alwaysDenies: false, witness: (0, enumerate_1.repToAction)(outcome.hit) };
|
|
155
|
+
}
|
|
156
|
+
if (outcome.overflow) {
|
|
157
|
+
return { alwaysDenies: false, approximate: true, reason: 'grid exceeded the bound; cannot prove vacuity' };
|
|
158
|
+
}
|
|
159
|
+
if (model.undecidable.length > 0) {
|
|
160
|
+
return { alwaysDenies: false, approximate: true, reason: `over-approximated (${model.undecidable.join('; ')}); cannot prove vacuity` };
|
|
161
|
+
}
|
|
162
|
+
return { alwaysDenies: true };
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Is the policy total for `verb` — does it admit EVERY action of that verb (any resource, any params)?
|
|
166
|
+
* Proven only for the decided fragment; any undecidable feature or grid overflow fails safe to
|
|
167
|
+
* `alwaysAllows: false`.
|
|
168
|
+
*/
|
|
169
|
+
function alwaysAllows(policy, verb, opts = {}) {
|
|
170
|
+
const model = (0, enumerate_1.toModel)(policy);
|
|
171
|
+
const max = opts.maxCombinations ?? enumerate_1.DEFAULT_MAX_COMBINATIONS;
|
|
172
|
+
if (!model.caveatSat) {
|
|
173
|
+
return { alwaysAllows: false, reason: `caveats unsatisfiable: ${model.caveatReason ?? 'unknown'}` };
|
|
174
|
+
}
|
|
175
|
+
const pr = probesFor([model], verb);
|
|
176
|
+
const outcome = (0, enumerate_1.search)(pr, (rep) => !(0, enumerate_1.admits)(model, rep), max);
|
|
177
|
+
if (outcome.hit !== undefined) {
|
|
178
|
+
return { alwaysAllows: false, counterexample: (0, enumerate_1.repToAction)(outcome.hit) };
|
|
179
|
+
}
|
|
180
|
+
if (outcome.overflow) {
|
|
181
|
+
return { alwaysAllows: false, approximate: true, reason: 'grid exceeded the bound; cannot prove totality' };
|
|
182
|
+
}
|
|
183
|
+
if (model.undecidable.length > 0) {
|
|
184
|
+
return { alwaysAllows: false, approximate: true, reason: `over-approximated (${model.undecidable.join('; ')}); cannot prove totality` };
|
|
185
|
+
}
|
|
186
|
+
return { alwaysAllows: true };
|
|
187
|
+
}
|
|
188
|
+
function probesFor(models, verb) {
|
|
189
|
+
const anyRev = models.some((m) => m.revCap !== undefined);
|
|
190
|
+
const pr = (0, enumerate_1.collectProbes)({ predicateSets: models.map((m) => m.predicates), varyReversibility: anyRev });
|
|
191
|
+
if (verb !== undefined)
|
|
192
|
+
pr.verbs = [verb];
|
|
193
|
+
return pr;
|
|
194
|
+
}
|
|
195
|
+
// ---- subsumes / disjoint / equivalent -------------------------------------------------------------
|
|
196
|
+
/**
|
|
197
|
+
* Does policy `a` permit everything `b` permits (admitted(b) ⊆ admitted(a))? This is the
|
|
198
|
+
* delegation-safety check: a child capability must be subsumed by its parent. A counterexample is an
|
|
199
|
+
* action `b` admits that `a` denies. Proven only for the decided fragment; any undecidable feature in
|
|
200
|
+
* either policy, or grid overflow, fails safe to `subsumes: false`.
|
|
201
|
+
*/
|
|
202
|
+
function subsumes(a, b, opts = {}) {
|
|
203
|
+
const ma = (0, enumerate_1.toModel)(a);
|
|
204
|
+
const mb = (0, enumerate_1.toModel)(b);
|
|
205
|
+
const max = opts.maxCombinations ?? enumerate_1.DEFAULT_MAX_COMBINATIONS;
|
|
206
|
+
const pr = probesFor([ma, mb]);
|
|
207
|
+
const outcome = (0, enumerate_1.search)(pr, (rep) => (0, enumerate_1.admits)(mb, rep) && !(0, enumerate_1.admits)(ma, rep), max);
|
|
208
|
+
if (outcome.hit !== undefined) {
|
|
209
|
+
return { subsumes: false, counterexample: (0, enumerate_1.repToAction)(outcome.hit) };
|
|
210
|
+
}
|
|
211
|
+
const note = approxNote([ma, mb], outcome.overflow);
|
|
212
|
+
if (note !== undefined)
|
|
213
|
+
return { subsumes: false, approximate: true, reason: note };
|
|
214
|
+
return { subsumes: true };
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Are the two policies' admitted sets disjoint (no action both admit)? A witness is an action both
|
|
218
|
+
* admit. Proven only for the decided fragment; otherwise fails safe to `disjoint: false`.
|
|
219
|
+
*/
|
|
220
|
+
function disjoint(a, b, opts = {}) {
|
|
221
|
+
const ma = (0, enumerate_1.toModel)(a);
|
|
222
|
+
const mb = (0, enumerate_1.toModel)(b);
|
|
223
|
+
const max = opts.maxCombinations ?? enumerate_1.DEFAULT_MAX_COMBINATIONS;
|
|
224
|
+
const pr = probesFor([ma, mb]);
|
|
225
|
+
const outcome = (0, enumerate_1.search)(pr, (rep) => (0, enumerate_1.admits)(ma, rep) && (0, enumerate_1.admits)(mb, rep), max);
|
|
226
|
+
if (outcome.hit !== undefined) {
|
|
227
|
+
return { disjoint: false, witness: (0, enumerate_1.repToAction)(outcome.hit) };
|
|
228
|
+
}
|
|
229
|
+
const note = approxNote([ma, mb], outcome.overflow);
|
|
230
|
+
if (note !== undefined)
|
|
231
|
+
return { disjoint: false, approximate: true, reason: note };
|
|
232
|
+
return { disjoint: true };
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Do the two policies admit exactly the same actions? A counterexample is an action admitted by one
|
|
236
|
+
* but not the other. Proven only for the decided fragment; otherwise fails safe to `equivalent: false`.
|
|
237
|
+
*/
|
|
238
|
+
function equivalent(a, b, opts = {}) {
|
|
239
|
+
const ma = (0, enumerate_1.toModel)(a);
|
|
240
|
+
const mb = (0, enumerate_1.toModel)(b);
|
|
241
|
+
const max = opts.maxCombinations ?? enumerate_1.DEFAULT_MAX_COMBINATIONS;
|
|
242
|
+
const pr = probesFor([ma, mb]);
|
|
243
|
+
const outcome = (0, enumerate_1.search)(pr, (rep) => (0, enumerate_1.admits)(ma, rep) !== (0, enumerate_1.admits)(mb, rep), max);
|
|
244
|
+
if (outcome.hit !== undefined) {
|
|
245
|
+
return { equivalent: false, counterexample: (0, enumerate_1.repToAction)(outcome.hit) };
|
|
246
|
+
}
|
|
247
|
+
const note = approxNote([ma, mb], outcome.overflow);
|
|
248
|
+
if (note !== undefined)
|
|
249
|
+
return { equivalent: false, approximate: true, reason: note };
|
|
250
|
+
return { equivalent: true };
|
|
251
|
+
}
|
|
252
|
+
function approxNote(models, overflow) {
|
|
253
|
+
if (overflow)
|
|
254
|
+
return 'representative grid exceeded the bound; cannot prove the relation';
|
|
255
|
+
const reasons = models.flatMap((m) => m.undecidable);
|
|
256
|
+
if (reasons.length > 0)
|
|
257
|
+
return `over-approximated (${[...new Set(reasons)].join('; ')}); cannot prove the relation`;
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
// ---- intentConformance ----------------------------------------------------------------------------
|
|
261
|
+
/**
|
|
262
|
+
* Does the policy admit ONLY actions inside the declared `intent` envelope (allowed verbs + resource
|
|
263
|
+
* scopes + an amount ceiling)? This is the key safety check distinct from the runtime trust-budget: an
|
|
264
|
+
* action can pass the policy's predicates and stay under budget yet still fall outside what the
|
|
265
|
+
* principal intended — e.g. a $14k renewal admitted under a $10k intent cap because the policy's own
|
|
266
|
+
* ceiling is higher (or absent). Each reported violation is a concrete admitted action outside the
|
|
267
|
+
* envelope, so `conforms: false` with violations is always proven. `conforms: true` is proven only for
|
|
268
|
+
* the decided fragment; an undecidable policy feature, a `re:` intent scope, or grid overflow fails
|
|
269
|
+
* safe to `conforms: false, approximate: true` with no violations listed.
|
|
270
|
+
*/
|
|
271
|
+
function intentConformance(policy, intent, opts = {}) {
|
|
272
|
+
const model = (0, enumerate_1.toModel)(policy);
|
|
273
|
+
const max = opts.maxCombinations ?? enumerate_1.DEFAULT_MAX_COMBINATIONS;
|
|
274
|
+
const amountField = intent.amountField ?? 'amount';
|
|
275
|
+
const minAmount = intent.minAmount ?? 0;
|
|
276
|
+
if (!model.caveatSat) {
|
|
277
|
+
// Admits nothing, so it trivially admits only within-intent actions.
|
|
278
|
+
return { conforms: true, violations: [] };
|
|
279
|
+
}
|
|
280
|
+
const extraFieldConditions = [];
|
|
281
|
+
if (intent.maxAmount !== undefined) {
|
|
282
|
+
const path = `action.params.${amountField}`;
|
|
283
|
+
extraFieldConditions.push({ path, cond: { field: path, op: 'lte', value: intent.maxAmount } });
|
|
284
|
+
extraFieldConditions.push({ path, cond: { field: path, op: 'gte', value: minAmount } });
|
|
285
|
+
}
|
|
286
|
+
const pr = (0, enumerate_1.collectProbes)({
|
|
287
|
+
predicateSets: [model.predicates],
|
|
288
|
+
extraVerbs: intent.verbs.filter((v) => v !== '*'),
|
|
289
|
+
extraResources: intent.resourceScopes ?? [],
|
|
290
|
+
extraFieldConditions,
|
|
291
|
+
varyReversibility: model.revCap !== undefined,
|
|
292
|
+
});
|
|
293
|
+
if (pr.verbs.length * pr.resources.length * pr.revClasses.length * fieldProduct(pr.fields) > max) {
|
|
294
|
+
return { conforms: false, approximate: true, violations: [], reason: 'grid exceeded the bound; cannot prove conformance' };
|
|
295
|
+
}
|
|
296
|
+
const violations = [];
|
|
297
|
+
const maxViolations = 16;
|
|
298
|
+
for (const rep of (0, enumerate_1.representatives)(pr)) {
|
|
299
|
+
if (!(0, enumerate_1.admits)(model, rep))
|
|
300
|
+
continue;
|
|
301
|
+
const action = (0, enumerate_1.repToAction)(rep);
|
|
302
|
+
const kinds = intentViolationKinds(action, intent, amountField, minAmount);
|
|
303
|
+
if (kinds.length > 0) {
|
|
304
|
+
violations.push({ action, kinds });
|
|
305
|
+
if (violations.length >= maxViolations)
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (violations.length > 0) {
|
|
310
|
+
return { conforms: false, violations };
|
|
311
|
+
}
|
|
312
|
+
const intentRegex = (intent.resourceScopes ?? []).some((s) => s.startsWith('re:'));
|
|
313
|
+
if (model.undecidable.length > 0 || intentRegex) {
|
|
314
|
+
const reasons = [...model.undecidable];
|
|
315
|
+
if (intentRegex)
|
|
316
|
+
reasons.push('re: intent resource scope not enumerated soundly');
|
|
317
|
+
return { conforms: false, approximate: true, violations: [], reason: `over-approximated (${reasons.join('; ')}); cannot prove conformance` };
|
|
318
|
+
}
|
|
319
|
+
return { conforms: true, violations: [] };
|
|
320
|
+
}
|
|
321
|
+
function fieldProduct(fields) {
|
|
322
|
+
let n = 1;
|
|
323
|
+
for (const f of fields)
|
|
324
|
+
n *= f.values.length;
|
|
325
|
+
return n;
|
|
326
|
+
}
|
|
327
|
+
function scopeMatches(scope, resource) {
|
|
328
|
+
if (scope === '*')
|
|
329
|
+
return true;
|
|
330
|
+
if (scope.startsWith('re:')) {
|
|
331
|
+
try {
|
|
332
|
+
return new RegExp('^(?:' + scope.slice(3) + ')$').test(resource);
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (scope.endsWith('*'))
|
|
339
|
+
return resource.startsWith(scope.slice(0, -1));
|
|
340
|
+
return scope === resource;
|
|
341
|
+
}
|
|
342
|
+
function intentViolationKinds(action, intent, amountField, minAmount) {
|
|
343
|
+
const kinds = [];
|
|
344
|
+
if (!(intent.verbs.includes('*') || intent.verbs.includes(action.verb)))
|
|
345
|
+
kinds.push('off-verb');
|
|
346
|
+
const scopes = intent.resourceScopes ?? [];
|
|
347
|
+
if (scopes.length > 0 && !scopes.some((s) => scopeMatches(s, action.resource)))
|
|
348
|
+
kinds.push('off-scope');
|
|
349
|
+
if (intent.maxAmount !== undefined) {
|
|
350
|
+
const amt = (action.params ?? {})[amountField];
|
|
351
|
+
if (typeof amt === 'number' && Number.isFinite(amt)) {
|
|
352
|
+
if (amt > intent.maxAmount)
|
|
353
|
+
kinds.push('over-amount');
|
|
354
|
+
else if (amt < minAmount)
|
|
355
|
+
kinds.push('under-amount');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return kinds;
|
|
359
|
+
}
|
|
360
|
+
// ---- convenience ----------------------------------------------------------------------------------
|
|
361
|
+
/** Concrete, exact admission check for a fully-specified action (no existential search). */
|
|
362
|
+
function admitsConcrete(policy, action) {
|
|
363
|
+
return (0, enumerate_1.admitsAction)((0, enumerate_1.toModel)(policy), action);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Whether a predicate's own numeric `where` conjunction is satisfiable (an explicit use of the interval
|
|
367
|
+
* engine; e.g. `amount >= 100 AND amount <= 10` is not). Non-numeric / `ref` conditions are ignored.
|
|
368
|
+
*/
|
|
369
|
+
function predicateNumericSatisfiable(where) {
|
|
370
|
+
if (!Array.isArray(where))
|
|
371
|
+
return true;
|
|
372
|
+
return (0, field_1.numericConjunctionSatisfiable)(where);
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;AA+DH,8BAsDC;AAmBD,oCAkBC;AAOD,oCAkBC;AAiBD,4BAYC;AAMD,4BAYC;AAMD,gCAYC;AAqBD,8CAmDC;AA4CD,wCAEC;AAMD,kEAGC;AAhXD,2CAWqB;AAwWZ,uFAjXP,kBAAM,OAiXO;AAAE,6FAhXf,wBAAY,OAgXe;AAAE,8FA/W7B,yBAAa,OA+W6B;AAAmB,4FA9W7D,uBAAW,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C,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxG,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;QAC/C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACpD,IAAI,GAAG,GAAG,MAAM,CAAC,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;iBACjD,IAAI,GAAG,GAAG,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,sGAAsG;AAEtG,4FAA4F;AAC5F,SAAgB,cAAc,CAAC,MAAmB,EAAE,MAAsB;IACxE,OAAO,IAAA,wBAAY,EAAC,IAAA,mBAAO,EAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,SAAgB,2BAA2B,CAAC,KAAuC;IACjF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,IAAA,qCAA6B,EAAC,KAAK,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { Caveat, CompiledPolicy, Predicate } from '@atlasauth/pca';
|
|
2
|
+
/**
|
|
3
|
+
* Public types for the PCA authority analyzer.
|
|
4
|
+
*
|
|
5
|
+
* The analyzer decides static questions over PCA's predicate/caveat policy — "what can this whole
|
|
6
|
+
* delegated authority EVER do?" — independently of any single runtime action. See README.md for the
|
|
7
|
+
* exact decided fragment and the honest incompleteness boundary.
|
|
8
|
+
*/
|
|
9
|
+
/** Reversibility classes in increasing severity (mirrors @atlasauth/pca's `REVERSIBILITY_ORDER`). */
|
|
10
|
+
export declare const REVERSIBILITY_ORDER: readonly ["reversible", "rate_limited", "irreversible"];
|
|
11
|
+
export type ReversibilityClass = (typeof REVERSIBILITY_ORDER)[number];
|
|
12
|
+
/**
|
|
13
|
+
* A policy to analyze: either a full `CompiledPolicy` (from `compilePolicy`/`agent().policy`) or a
|
|
14
|
+
* bare predicate set with an optional caveat set. A chain's acting authority is the leaf's cumulative
|
|
15
|
+
* (append-only) caveat list plus the grant's predicates.
|
|
16
|
+
*/
|
|
17
|
+
export type PolicyInput = CompiledPolicy | {
|
|
18
|
+
predicates: Predicate[];
|
|
19
|
+
caveats?: Caveat[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A concrete (or partially-concrete) action in the query/answer vocabulary. `params` are the
|
|
23
|
+
* `action.params.*` inputs; `subject`/`env` carry witness assignments to `subject.*` / `env.*` fields
|
|
24
|
+
* that a predicate's `where` may reference.
|
|
25
|
+
*/
|
|
26
|
+
export interface AnalyzerAction {
|
|
27
|
+
verb: string;
|
|
28
|
+
resource: string;
|
|
29
|
+
params?: Record<string, unknown>;
|
|
30
|
+
/** Reversibility class of the action (checked against a `reversibility_max` caveat). */
|
|
31
|
+
reversibilityClass?: string;
|
|
32
|
+
/** Witness assignment to `subject.*` fields (only populated when a witness needs them). */
|
|
33
|
+
subject?: Record<string, unknown>;
|
|
34
|
+
/** Witness assignment to `env.*` fields (only populated when a witness needs them). */
|
|
35
|
+
env?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `true` on a result means the verdict is SOUND but could not be decided EXACTLY (it was
|
|
39
|
+
* over-approximated / failed safe): e.g. a `re:` regex resource matcher, a cross-field `ref`
|
|
40
|
+
* condition, or a representative grid larger than the configured bound. A fail-safe verdict never
|
|
41
|
+
* claims the "safe" answer (subsumed / always-deny / disjoint / equivalent / conforms) without proof.
|
|
42
|
+
*/
|
|
43
|
+
export interface Approx {
|
|
44
|
+
approximate?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface ReachableResult extends Approx {
|
|
47
|
+
reachable: boolean;
|
|
48
|
+
/** A concrete action proving reachability (verified against the real evaluator). */
|
|
49
|
+
witness?: AnalyzerAction;
|
|
50
|
+
reason?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface AlwaysDeniesResult extends Approx {
|
|
53
|
+
alwaysDenies: boolean;
|
|
54
|
+
/** When `false`: a concrete action the policy admits (proving it is not vacuous). */
|
|
55
|
+
witness?: AnalyzerAction;
|
|
56
|
+
reason?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface AlwaysAllowsResult extends Approx {
|
|
59
|
+
alwaysAllows: boolean;
|
|
60
|
+
/** When `false`: a concrete action of the verb the policy denies. */
|
|
61
|
+
counterexample?: AnalyzerAction;
|
|
62
|
+
reason?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface SubsumesResult extends Approx {
|
|
65
|
+
subsumes: boolean;
|
|
66
|
+
/** When `false`: an action `b` admits that `a` does not (a delegation-safety violation). */
|
|
67
|
+
counterexample?: AnalyzerAction;
|
|
68
|
+
reason?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface DisjointResult extends Approx {
|
|
71
|
+
disjoint: boolean;
|
|
72
|
+
/** When `false`: an action both policies admit. */
|
|
73
|
+
witness?: AnalyzerAction;
|
|
74
|
+
reason?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface EquivalentResult extends Approx {
|
|
77
|
+
equivalent: boolean;
|
|
78
|
+
/** When `false`: an action admitted by exactly one of the two policies. */
|
|
79
|
+
counterexample?: AnalyzerAction;
|
|
80
|
+
reason?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A declared intent envelope — the authority the principal MEANT to grant, distinct from the runtime
|
|
84
|
+
* limits the policy happens to encode. `intentConformance` checks the policy admits ONLY actions
|
|
85
|
+
* inside this envelope.
|
|
86
|
+
*/
|
|
87
|
+
export interface Intent {
|
|
88
|
+
/** Allowed verbs. Include `'*'` to allow any verb. */
|
|
89
|
+
verbs: string[];
|
|
90
|
+
/** Allowed resource matchers (exact / `'*'` / trailing-`*` prefix / `re:`). Omitted/empty = any. */
|
|
91
|
+
resourceScopes?: string[];
|
|
92
|
+
/** Upper ceiling on the action's monetary amount, if any. */
|
|
93
|
+
maxAmount?: number;
|
|
94
|
+
/** Lower floor on the amount (default 0 when `maxAmount` is set). */
|
|
95
|
+
minAmount?: number;
|
|
96
|
+
/** The `action.params.<field>` that carries the amount (default `'amount'`). */
|
|
97
|
+
amountField?: string;
|
|
98
|
+
}
|
|
99
|
+
export type IntentViolationKind = 'off-verb' | 'off-scope' | 'over-amount' | 'under-amount';
|
|
100
|
+
export interface IntentViolation {
|
|
101
|
+
action: AnalyzerAction;
|
|
102
|
+
kinds: IntentViolationKind[];
|
|
103
|
+
}
|
|
104
|
+
export interface IntentConformanceResult extends Approx {
|
|
105
|
+
conforms: boolean;
|
|
106
|
+
/** Concrete actions the policy admits that fall OUTSIDE the intent envelope. */
|
|
107
|
+
violations: IntentViolation[];
|
|
108
|
+
reason?: string;
|
|
109
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REVERSIBILITY_ORDER = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Public types for the PCA authority analyzer.
|
|
6
|
+
*
|
|
7
|
+
* The analyzer decides static questions over PCA's predicate/caveat policy — "what can this whole
|
|
8
|
+
* delegated authority EVER do?" — independently of any single runtime action. See README.md for the
|
|
9
|
+
* exact decided fragment and the honest incompleteness boundary.
|
|
10
|
+
*/
|
|
11
|
+
/** Reversibility classes in increasing severity (mirrors @atlasauth/pca's `REVERSIBILITY_ORDER`). */
|
|
12
|
+
exports.REVERSIBILITY_ORDER = ['reversible', 'rate_limited', 'irreversible'];
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AAEH,qGAAqG;AACxF,QAAA,mBAAmB,GAAG,CAAC,YAAY,EAAE,cAAc,EAAE,cAAc,CAAU,CAAC"}
|