@zapier/policy-schema 0.19.0 → 1.0.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/dist/index.d.cts +48 -4
- package/dist/index.d.ts +48 -4
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1693,10 +1693,10 @@ type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
|
1693
1693
|
[key: string]: JsonValue;
|
|
1694
1694
|
};
|
|
1695
1695
|
type ConditionValue = JsonValue | RangeValue | SizeValue;
|
|
1696
|
-
|
|
1696
|
+
/** One permission/resource pair checked against the shared request context. */
|
|
1697
|
+
interface PolicyCheck {
|
|
1697
1698
|
permission: string;
|
|
1698
1699
|
resource: string;
|
|
1699
|
-
context?: Record<string, unknown>;
|
|
1700
1700
|
}
|
|
1701
1701
|
/** SHA-256 hex digest of an RFC 8785 (JCS) canonicalized JSON value. */
|
|
1702
1702
|
type CanonicalHash = string & {
|
|
@@ -1736,9 +1736,17 @@ interface RuleTrace {
|
|
|
1736
1736
|
passed: boolean;
|
|
1737
1737
|
overrides?: OverrideTrace[];
|
|
1738
1738
|
}
|
|
1739
|
+
/**
|
|
1740
|
+
* One request, one context, one or more checks. `requestContext` describes the
|
|
1741
|
+
* whole request and is shared by every check; it is required and must be
|
|
1742
|
+
* non-empty — an empty context has no binding to a real request, and an
|
|
1743
|
+
* approval token for it could be replayed against anything. A single check
|
|
1744
|
+
* is a one-element `checks` array.
|
|
1745
|
+
*/
|
|
1739
1746
|
interface EvaluatePolicyOptions {
|
|
1740
1747
|
policy: Policy;
|
|
1741
|
-
|
|
1748
|
+
requestContext: Record<string, unknown>;
|
|
1749
|
+
checks: PolicyCheck[];
|
|
1742
1750
|
overrides?: Override[];
|
|
1743
1751
|
trace?: boolean;
|
|
1744
1752
|
}
|
|
@@ -1747,6 +1755,12 @@ interface PolicyResult {
|
|
|
1747
1755
|
effect: Effect;
|
|
1748
1756
|
explicit: boolean;
|
|
1749
1757
|
reason: PolicyReason;
|
|
1758
|
+
/**
|
|
1759
|
+
* Ids of passed, non-overridden ask statements, in statement order. Empty
|
|
1760
|
+
* unless `effect === "ask"`; always empty for v1/v2 (no statement ids) and
|
|
1761
|
+
* for an ask that came from the policy's ask defaultEffect.
|
|
1762
|
+
*/
|
|
1763
|
+
askRuleIds: string[];
|
|
1750
1764
|
statements: StatementTrace[];
|
|
1751
1765
|
/** Trace mode only. Present when no statement matched and an ask default was consulted (never attached for deny defaults). */
|
|
1752
1766
|
default?: DefaultTrace;
|
|
@@ -1762,8 +1776,38 @@ interface PolicyResultV4 {
|
|
|
1762
1776
|
effect: Effect;
|
|
1763
1777
|
explicit: boolean;
|
|
1764
1778
|
reason: PolicyReason;
|
|
1779
|
+
/** Ids of passed, non-overridden ask rules. Empty unless `effect === "ask"`. */
|
|
1780
|
+
askRuleIds: string[];
|
|
1765
1781
|
rules: RuleTrace[];
|
|
1766
1782
|
}
|
|
1783
|
+
/**
|
|
1784
|
+
* Result of `evaluatePolicy`: the combined decision plus one per-check result.
|
|
1785
|
+
* Every check is always evaluated, so on successful return `results` always
|
|
1786
|
+
* has one entry per input check, in `checks` order (`results[i]` corresponds
|
|
1787
|
+
* to `checks[i]`). A call can still throw for an invalid override (e.g. one
|
|
1788
|
+
* targeting a deny statement or default) even when an earlier check already
|
|
1789
|
+
* decided the call denies -- that override was invalid regardless of check
|
|
1790
|
+
* order; evaluating every check is what surfaces it.
|
|
1791
|
+
*
|
|
1792
|
+
* - Deny on any check wins the combined effect (a deny cannot be approved
|
|
1793
|
+
* around), and `askRuleIds` is empty -- but `results` still reports every
|
|
1794
|
+
* check that was evaluated.
|
|
1795
|
+
* - `askRuleIds` is the union of every asking check's non-overridden ask
|
|
1796
|
+
* statement/rule ids, deduplicated, first-appearance order. Empty
|
|
1797
|
+
* unless `effect === "ask"`.
|
|
1798
|
+
*
|
|
1799
|
+
* No combined `explicit`/`reason`: with multiple checks, which check's
|
|
1800
|
+
* explicit/reason "wins" is an artifact of check order rather than a
|
|
1801
|
+
* meaningful signal (e.g. an implicit deny on check[0] and an explicit deny
|
|
1802
|
+
* on check[1] would report differently depending on which check ran first,
|
|
1803
|
+
* even though the combined effect is deny either way). A caller that needs
|
|
1804
|
+
* explicit/reason must read the per-check `results` (ENT-2614 review).
|
|
1805
|
+
*/
|
|
1806
|
+
interface EvaluatePolicyResult<R extends PolicyResult | PolicyResultV4 = PolicyResult | PolicyResultV4> {
|
|
1807
|
+
effect: Effect;
|
|
1808
|
+
askRuleIds: string[];
|
|
1809
|
+
results: R[];
|
|
1810
|
+
}
|
|
1767
1811
|
interface ParsedUrl {
|
|
1768
1812
|
scheme: string;
|
|
1769
1813
|
host: string;
|
|
@@ -1800,4 +1844,4 @@ interface OpenApiSchema {
|
|
|
1800
1844
|
anyOf?: OpenApiSchema[];
|
|
1801
1845
|
}
|
|
1802
1846
|
|
|
1803
|
-
export { type ArrayOperator, ArrayOperatorSchema, type CanonicalHash, CanonicalHashSchema, type Condition, ConditionSchema, type ConditionTrace, type ConditionValue, ConditionValueSchema, type DefaultEffect, DefaultEffectSchema, type DefaultTrace, type Effect, type EvaluatePolicyOptions, ID_BASED_VERSIONS, type JsonValue, type OpenApiSchema, type Operator, OperatorSchema, type OtherOperator, OtherOperatorSchema, type Override, OverrideSchema, type OverrideTrace, type ParsedUrl, type Policy, type PolicyActionRequest, type PolicyHttpRequest, type PolicyId, PolicyIdSchema, type PolicyReason, type
|
|
1847
|
+
export { type ArrayOperator, ArrayOperatorSchema, type CanonicalHash, CanonicalHashSchema, type Condition, ConditionSchema, type ConditionTrace, type ConditionValue, ConditionValueSchema, type DefaultEffect, DefaultEffectSchema, type DefaultTrace, type Effect, type EvaluatePolicyOptions, type EvaluatePolicyResult, ID_BASED_VERSIONS, type JsonValue, type OpenApiSchema, type Operator, OperatorSchema, type OtherOperator, OtherOperatorSchema, type Override, OverrideSchema, type OverrideTrace, type ParsedUrl, type Policy, type PolicyActionRequest, type PolicyCheck, type PolicyHttpRequest, type PolicyId, PolicyIdSchema, type PolicyReason, type PolicyResult, type PolicyResultV4, PolicySchema, RUBBERDUCK_POLICY_VERSION, type RangeValue, RangeValueSchema, type RuleId, RuleIdSchema, type RuleTrace, type ScalarOperator, ScalarOperatorSchema, type SizeValue, SizeValueSchema, type Statement, type StatementId, StatementIdSchema, StatementSchema, type StatementTrace, type UrlOperator, UrlOperatorSchema, V3_MAX_TIERS, V4_MAX_TIERS, VALID_EFFECTS, VALID_OPERATOR_LIST, VALID_VERSIONS, getOpenApiSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1693,10 +1693,10 @@ type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
|
1693
1693
|
[key: string]: JsonValue;
|
|
1694
1694
|
};
|
|
1695
1695
|
type ConditionValue = JsonValue | RangeValue | SizeValue;
|
|
1696
|
-
|
|
1696
|
+
/** One permission/resource pair checked against the shared request context. */
|
|
1697
|
+
interface PolicyCheck {
|
|
1697
1698
|
permission: string;
|
|
1698
1699
|
resource: string;
|
|
1699
|
-
context?: Record<string, unknown>;
|
|
1700
1700
|
}
|
|
1701
1701
|
/** SHA-256 hex digest of an RFC 8785 (JCS) canonicalized JSON value. */
|
|
1702
1702
|
type CanonicalHash = string & {
|
|
@@ -1736,9 +1736,17 @@ interface RuleTrace {
|
|
|
1736
1736
|
passed: boolean;
|
|
1737
1737
|
overrides?: OverrideTrace[];
|
|
1738
1738
|
}
|
|
1739
|
+
/**
|
|
1740
|
+
* One request, one context, one or more checks. `requestContext` describes the
|
|
1741
|
+
* whole request and is shared by every check; it is required and must be
|
|
1742
|
+
* non-empty — an empty context has no binding to a real request, and an
|
|
1743
|
+
* approval token for it could be replayed against anything. A single check
|
|
1744
|
+
* is a one-element `checks` array.
|
|
1745
|
+
*/
|
|
1739
1746
|
interface EvaluatePolicyOptions {
|
|
1740
1747
|
policy: Policy;
|
|
1741
|
-
|
|
1748
|
+
requestContext: Record<string, unknown>;
|
|
1749
|
+
checks: PolicyCheck[];
|
|
1742
1750
|
overrides?: Override[];
|
|
1743
1751
|
trace?: boolean;
|
|
1744
1752
|
}
|
|
@@ -1747,6 +1755,12 @@ interface PolicyResult {
|
|
|
1747
1755
|
effect: Effect;
|
|
1748
1756
|
explicit: boolean;
|
|
1749
1757
|
reason: PolicyReason;
|
|
1758
|
+
/**
|
|
1759
|
+
* Ids of passed, non-overridden ask statements, in statement order. Empty
|
|
1760
|
+
* unless `effect === "ask"`; always empty for v1/v2 (no statement ids) and
|
|
1761
|
+
* for an ask that came from the policy's ask defaultEffect.
|
|
1762
|
+
*/
|
|
1763
|
+
askRuleIds: string[];
|
|
1750
1764
|
statements: StatementTrace[];
|
|
1751
1765
|
/** Trace mode only. Present when no statement matched and an ask default was consulted (never attached for deny defaults). */
|
|
1752
1766
|
default?: DefaultTrace;
|
|
@@ -1762,8 +1776,38 @@ interface PolicyResultV4 {
|
|
|
1762
1776
|
effect: Effect;
|
|
1763
1777
|
explicit: boolean;
|
|
1764
1778
|
reason: PolicyReason;
|
|
1779
|
+
/** Ids of passed, non-overridden ask rules. Empty unless `effect === "ask"`. */
|
|
1780
|
+
askRuleIds: string[];
|
|
1765
1781
|
rules: RuleTrace[];
|
|
1766
1782
|
}
|
|
1783
|
+
/**
|
|
1784
|
+
* Result of `evaluatePolicy`: the combined decision plus one per-check result.
|
|
1785
|
+
* Every check is always evaluated, so on successful return `results` always
|
|
1786
|
+
* has one entry per input check, in `checks` order (`results[i]` corresponds
|
|
1787
|
+
* to `checks[i]`). A call can still throw for an invalid override (e.g. one
|
|
1788
|
+
* targeting a deny statement or default) even when an earlier check already
|
|
1789
|
+
* decided the call denies -- that override was invalid regardless of check
|
|
1790
|
+
* order; evaluating every check is what surfaces it.
|
|
1791
|
+
*
|
|
1792
|
+
* - Deny on any check wins the combined effect (a deny cannot be approved
|
|
1793
|
+
* around), and `askRuleIds` is empty -- but `results` still reports every
|
|
1794
|
+
* check that was evaluated.
|
|
1795
|
+
* - `askRuleIds` is the union of every asking check's non-overridden ask
|
|
1796
|
+
* statement/rule ids, deduplicated, first-appearance order. Empty
|
|
1797
|
+
* unless `effect === "ask"`.
|
|
1798
|
+
*
|
|
1799
|
+
* No combined `explicit`/`reason`: with multiple checks, which check's
|
|
1800
|
+
* explicit/reason "wins" is an artifact of check order rather than a
|
|
1801
|
+
* meaningful signal (e.g. an implicit deny on check[0] and an explicit deny
|
|
1802
|
+
* on check[1] would report differently depending on which check ran first,
|
|
1803
|
+
* even though the combined effect is deny either way). A caller that needs
|
|
1804
|
+
* explicit/reason must read the per-check `results` (ENT-2614 review).
|
|
1805
|
+
*/
|
|
1806
|
+
interface EvaluatePolicyResult<R extends PolicyResult | PolicyResultV4 = PolicyResult | PolicyResultV4> {
|
|
1807
|
+
effect: Effect;
|
|
1808
|
+
askRuleIds: string[];
|
|
1809
|
+
results: R[];
|
|
1810
|
+
}
|
|
1767
1811
|
interface ParsedUrl {
|
|
1768
1812
|
scheme: string;
|
|
1769
1813
|
host: string;
|
|
@@ -1800,4 +1844,4 @@ interface OpenApiSchema {
|
|
|
1800
1844
|
anyOf?: OpenApiSchema[];
|
|
1801
1845
|
}
|
|
1802
1846
|
|
|
1803
|
-
export { type ArrayOperator, ArrayOperatorSchema, type CanonicalHash, CanonicalHashSchema, type Condition, ConditionSchema, type ConditionTrace, type ConditionValue, ConditionValueSchema, type DefaultEffect, DefaultEffectSchema, type DefaultTrace, type Effect, type EvaluatePolicyOptions, ID_BASED_VERSIONS, type JsonValue, type OpenApiSchema, type Operator, OperatorSchema, type OtherOperator, OtherOperatorSchema, type Override, OverrideSchema, type OverrideTrace, type ParsedUrl, type Policy, type PolicyActionRequest, type PolicyHttpRequest, type PolicyId, PolicyIdSchema, type PolicyReason, type
|
|
1847
|
+
export { type ArrayOperator, ArrayOperatorSchema, type CanonicalHash, CanonicalHashSchema, type Condition, ConditionSchema, type ConditionTrace, type ConditionValue, ConditionValueSchema, type DefaultEffect, DefaultEffectSchema, type DefaultTrace, type Effect, type EvaluatePolicyOptions, type EvaluatePolicyResult, ID_BASED_VERSIONS, type JsonValue, type OpenApiSchema, type Operator, OperatorSchema, type OtherOperator, OtherOperatorSchema, type Override, OverrideSchema, type OverrideTrace, type ParsedUrl, type Policy, type PolicyActionRequest, type PolicyCheck, type PolicyHttpRequest, type PolicyId, PolicyIdSchema, type PolicyReason, type PolicyResult, type PolicyResultV4, PolicySchema, RUBBERDUCK_POLICY_VERSION, type RangeValue, RangeValueSchema, type RuleId, RuleIdSchema, type RuleTrace, type ScalarOperator, ScalarOperatorSchema, type SizeValue, SizeValueSchema, type Statement, type StatementId, StatementIdSchema, StatementSchema, type StatementTrace, type UrlOperator, UrlOperatorSchema, V3_MAX_TIERS, V4_MAX_TIERS, VALID_EFFECTS, VALID_OPERATOR_LIST, VALID_VERSIONS, getOpenApiSchema };
|