@authup/access 1.0.0-beta.36 → 1.0.0-beta.38

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.mts CHANGED
@@ -119,7 +119,9 @@ declare function definePolicyIssueItem(input: Omit<PolicyIssueItem, 'type'>): Po
119
119
  declare function definePolicyIssueGroup(input: Omit<PolicyIssueGroup, 'type'>): PolicyIssueGroup;
120
120
  //#endregion
121
121
  //#region src/policy/error/module.d.ts
122
+ declare function isPolicyError(value: unknown): value is PolicyError;
122
123
  declare class PolicyError extends AuthupError {
124
+ readonly '@instanceof': symbol;
123
125
  constructor(message?: string, code?: string | null);
124
126
  addIssue(data: PolicyIssue): void;
125
127
  addIssues(data: PolicyIssue[]): void;
@@ -418,6 +420,9 @@ declare const SystemPolicyName: {
418
420
  readonly REALM_MATCH: "system.realm-match";
419
421
  readonly REALM_BOUND: "system.realm-bound";
420
422
  readonly REALM_OR_GLOBAL: "system.realm-or-global";
423
+ readonly CLIENT_NAMES_SELF_MANAGE: "system.client-names-self-manage";
424
+ readonly ROBOT_NAMES_SELF_MANAGE: "system.robot-names-self-manage";
425
+ readonly USER_NAMES_SELF_MANAGE: "system.user-names-self-manage";
421
426
  };
422
427
  //#endregion
423
428
  //#region src/policy/built-in/types.d.ts
@@ -543,5 +548,5 @@ declare class PermissionEvaluator implements IPermissionEvaluator {
543
548
  preEvaluateOneOf(ctx: PermissionEvaluationContext): Promise<void>;
544
549
  }
545
550
  //#endregion
546
- export { AttributeNamesPolicy, AttributeNamesPolicyEvaluator, AttributeNamesPolicyValidator, AttributesPolicy, AttributesPolicyEvaluator, AttributesPolicyQuery, AttributesPolicyValidator, BasePermission, BasePolicy, BuiltInPolicies, BuiltInPolicyType, BuiltInPolicyTypeMap, CompositePolicy, CompositePolicyEvaluator, CompositePolicyValidator, DatePolicy, DatePolicyEvaluator, DatePolicyValidator, DecisionStrategy, IPermissionEvaluator, IPermissionProvider, IPolicyData, IPolicyEngine, IPolicyEvaluator, IdentityPolicy, IdentityPolicyData, IdentityPolicyEvaluator, IdentityPolicyValidator, PermissionBindingPolicy, PermissionBindingPolicyEvaluator, PermissionBindingPolicyValidator, PermissionError, PermissionEvaluationContext, PermissionEvaluationOptions, PermissionEvaluator, PermissionEvaluatorOptions, PermissionGetOptions, PermissionMemoryProvider, PermissionPolicyBinding, PolicyData, PolicyDefaultEvaluators, PolicyEngine, PolicyError, PolicyEvaluationContext, PolicyEvaluationContextInput, PolicyEvaluationResult, PolicyEvaluators, PolicyIssue, PolicyIssueCode, PolicyIssueGroup, PolicyIssueItem, PolicyIssueSeverity, PolicyWithType, RealmMatchPolicy, RealmMatchPolicyEvaluator, RealmMatchPolicyValidator, SystemPolicyName, TimePolicy, TimePolicyEvaluator, TimePolicyInterval, TimePolicyValidator, buildPermissionKey, defineAttributesPolicy, definePolicyEvaluationContext, definePolicyIssueGroup, definePolicyIssueItem, definePolicyWithType, isCompositePolicy, isIntervalForDayOfMonth, isIntervalForDayOfWeek, isIntervalForDayOfYear, isPermissionPolicyBindingEqual, maybeInvertPolicyOutcome, mergePermissionPolicyBindings };
551
+ export { AttributeNamesPolicy, AttributeNamesPolicyEvaluator, AttributeNamesPolicyValidator, AttributesPolicy, AttributesPolicyEvaluator, AttributesPolicyQuery, AttributesPolicyValidator, BasePermission, BasePolicy, BuiltInPolicies, BuiltInPolicyType, BuiltInPolicyTypeMap, CompositePolicy, CompositePolicyEvaluator, CompositePolicyValidator, DatePolicy, DatePolicyEvaluator, DatePolicyValidator, DecisionStrategy, IPermissionEvaluator, IPermissionProvider, IPolicyData, IPolicyEngine, IPolicyEvaluator, IdentityPolicy, IdentityPolicyData, IdentityPolicyEvaluator, IdentityPolicyValidator, PermissionBindingPolicy, PermissionBindingPolicyEvaluator, PermissionBindingPolicyValidator, PermissionError, PermissionEvaluationContext, PermissionEvaluationOptions, PermissionEvaluator, PermissionEvaluatorOptions, PermissionGetOptions, PermissionMemoryProvider, PermissionPolicyBinding, PolicyData, PolicyDefaultEvaluators, PolicyEngine, PolicyError, PolicyEvaluationContext, PolicyEvaluationContextInput, PolicyEvaluationResult, PolicyEvaluators, PolicyIssue, PolicyIssueCode, PolicyIssueGroup, PolicyIssueItem, PolicyIssueSeverity, PolicyWithType, RealmMatchPolicy, RealmMatchPolicyEvaluator, RealmMatchPolicyValidator, SystemPolicyName, TimePolicy, TimePolicyEvaluator, TimePolicyInterval, TimePolicyValidator, buildPermissionKey, defineAttributesPolicy, definePolicyEvaluationContext, definePolicyIssueGroup, definePolicyIssueItem, definePolicyWithType, isCompositePolicy, isIntervalForDayOfMonth, isIntervalForDayOfWeek, isIntervalForDayOfYear, isPermissionPolicyBindingEqual, isPolicyError, maybeInvertPolicyOutcome, mergePermissionPolicyBindings };
547
552
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/policy/data.ts","../src/policy/evaluation/context/types.ts","../src/policy/evaluation/context/define.ts","../src/policy/evaluation/types.ts","../src/policy/types.ts","../src/policy/engine/types.ts","../src/policy/engine/module.ts","../src/policy/issue/constants.ts","../src/policy/issue/types.ts","../src/policy/issue/define.ts","../src/policy/error/module.ts","../src/policy/helpers/invert.ts","../src/policy/built-in/attribute-names/types.ts","../src/policy/built-in/attribute-names/validator.ts","../src/policy/built-in/attributes/types.ts","../src/policy/built-in/attributes/define.ts","../src/policy/built-in/attributes/validator.ts","../src/policy/built-in/attributes/evaluator.ts","../src/policy/built-in/attribute-names/evaluator.ts","../src/policy/built-in/composite/types.ts","../src/policy/built-in/composite/validator.ts","../src/policy/built-in/composite/evaluator.ts","../src/policy/built-in/composite/helper.ts","../src/policy/built-in/date/types.ts","../src/policy/built-in/date/validator.ts","../src/policy/built-in/date/evaluator.ts","../src/policy/built-in/identity/types.ts","../src/policy/built-in/identity/data/validator.ts","../src/policy/built-in/identity/validator.ts","../src/policy/built-in/identity/evaluator.ts","../src/policy/built-in/permission-binding/types.ts","../src/policy/built-in/permission-binding/validator.ts","../src/policy/built-in/permission-binding/module.ts","../src/policy/built-in/realm-match/types.ts","../src/policy/built-in/realm-match/validator.ts","../src/policy/built-in/realm-match/evaluator.ts","../src/policy/built-in/time/constants.ts","../src/policy/built-in/time/types.ts","../src/policy/built-in/time/validator.ts","../src/policy/built-in/time/evaluator.ts","../src/policy/built-in/time/helpers.ts","../src/policy/built-in/constants.ts","../src/policy/built-in/types.ts","../src/policy/built-in/define.ts","../src/policy/constants.ts","../src/permission/error/module.ts","../src/permission/types.ts","../src/permission/helpers/equal.ts","../src/permission/helpers/key.ts","../src/permission/helpers/merge.ts","../src/permission/provider/types.ts","../src/permission/provider/memory.ts","../src/permission/evaluator/types.ts","../src/permission/evaluator/module.ts"],"mappings":";;;;;;UAOiB,WAAA;EACb,GAAA,CAAI,GAAA,UAAa,KAAA;EACjB,GAAA,CAAI,GAAA;EACJ,GAAA,cAAiB,GAAA,WAAe,CAAA;EAEhC,WAAA,CAAY,GAAA;EACZ,YAAA,CAAa,GAAA;EAEb,KAAA,IAAU,WAAA;AAAA;AAAA,cAGD,UAAA,YAAsB,WAAA;EAAA,UACrB,IAAA,EAAM,MAAA;EAAA,UAEN,SAAA,EAAY,GAAA;cAGlB,IAAA,GAAM,MAAA,eACN,SAAA,GAAW,GAAA;EAMf,GAAA,aAAA,CAAiB,GAAA,UAAa,KAAA,EAAO,CAAA;EAKrC,GAAA,aAAA,CAAiB,GAAA,WAAe,CAAA;EAQhC,GAAA,CAAI,GAAA;EAIJ,YAAA,CAAa,GAAA;EAIb,WAAA,CAAY,GAAA;EAIZ,KAAA,CAAA,GAAK,UAAA;AAAA;;;KC/CG,uBAAA;EAAA,SACC,UAAA,EAAY,MAAA,SAAe,gBAAA;EAAA,SAC3B,IAAA;EAAA,SACA,OAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA,EAAM,UAAA;AAAA;AAAA,KAGP,4BAAA,GAA+B,OAAA,CAAQ,uBAAA;;;iBCPnC,6BAAA,CACZ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A,CAAiB,GAAA,EAAK,2BAAA,GAA+B,OAAA;AAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/policy/data.ts","../src/policy/evaluation/context/types.ts","../src/policy/evaluation/context/define.ts","../src/policy/evaluation/types.ts","../src/policy/types.ts","../src/policy/engine/types.ts","../src/policy/engine/module.ts","../src/policy/issue/constants.ts","../src/policy/issue/types.ts","../src/policy/issue/define.ts","../src/policy/error/module.ts","../src/policy/helpers/invert.ts","../src/policy/built-in/attribute-names/types.ts","../src/policy/built-in/attribute-names/validator.ts","../src/policy/built-in/attributes/types.ts","../src/policy/built-in/attributes/define.ts","../src/policy/built-in/attributes/validator.ts","../src/policy/built-in/attributes/evaluator.ts","../src/policy/built-in/attribute-names/evaluator.ts","../src/policy/built-in/composite/types.ts","../src/policy/built-in/composite/validator.ts","../src/policy/built-in/composite/evaluator.ts","../src/policy/built-in/composite/helper.ts","../src/policy/built-in/date/types.ts","../src/policy/built-in/date/validator.ts","../src/policy/built-in/date/evaluator.ts","../src/policy/built-in/identity/types.ts","../src/policy/built-in/identity/data/validator.ts","../src/policy/built-in/identity/validator.ts","../src/policy/built-in/identity/evaluator.ts","../src/policy/built-in/permission-binding/types.ts","../src/policy/built-in/permission-binding/validator.ts","../src/policy/built-in/permission-binding/module.ts","../src/policy/built-in/realm-match/types.ts","../src/policy/built-in/realm-match/validator.ts","../src/policy/built-in/realm-match/evaluator.ts","../src/policy/built-in/time/constants.ts","../src/policy/built-in/time/types.ts","../src/policy/built-in/time/validator.ts","../src/policy/built-in/time/evaluator.ts","../src/policy/built-in/time/helpers.ts","../src/policy/built-in/constants.ts","../src/policy/built-in/types.ts","../src/policy/built-in/define.ts","../src/policy/constants.ts","../src/permission/error/module.ts","../src/permission/types.ts","../src/permission/helpers/equal.ts","../src/permission/helpers/key.ts","../src/permission/helpers/merge.ts","../src/permission/provider/types.ts","../src/permission/provider/memory.ts","../src/permission/evaluator/types.ts","../src/permission/evaluator/module.ts"],"mappings":";;;;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AAA,GAA8B,OAAA;EAEjD,WAAA,CAAY,GAAA,EAAK,2BAAA,GAA8B,OAAA;EAE/C,gBAAA,CAAiB,GAAA,EAAK,2BAAA,GAA8B,OAAA;AAAA;AAAA,KAG5C,0BAAA;EACR,QAAA,EAAU,mBAAA;EACV,YAAA,GAAe,aAAA;EACf,OAAA;EACA,QAAA;AAAA;AAAA,KAGQ,2BAAA;EACR,gBAAA,MAAsB,gBAAA;EACtB,gBAAA;EACA,gBAAA;AAAA;AAAA,KAGQ,2BAAA;EACR,IAAA;EACA,OAAA;EACA,QAAA;EACA,KAAA,GAAQ,UAAA;EACR,OAAA,GAAU,2BAAA;AAAA;;;cCbD,mBAAA,YAA+B,oBAAA;EAAA,UAC9B,QAAA,EAAW,mBAAA;EAAA,UAEX,YAAA,EAAe,aAAA;EAAA,UAEf,QAAA;EAAA,UAEA,OAAA;cAIE,OAAA,EAAS,0BAAA;EAAA,UAeL,OAAA,CACZ,KAAA,UACA,SAAA;IACI,OAAA;IACA,QAAA;EAAA,IAEJ,OAAA,CAAQ,uBAAA;EAUN,QAAA,CAAS,GAAA,EAAK,2BAAA,GAA+B,OAAA;EA8G7C,aAAA,CAAc,GAAA,EAAK,2BAAA,GAA+B,OAAA;EAYlD,WAAA,CAAY,GAAA,EAAK,2BAAA,GAA+B,OAAA;EAchD,gBAAA,CAAiB,GAAA,EAAK,2BAAA,GAA+B,OAAA;AAAA"}
package/dist/index.mjs CHANGED
@@ -134,16 +134,13 @@ var PermissionMemoryProvider = class {
134
134
  }
135
135
  };
136
136
  //#endregion
137
- //#region src/policy/helpers/invert.ts
138
- function maybeInvertPolicyOutcome(outcome, invert) {
139
- if (typeof invert === "undefined") return outcome;
140
- if (typeof invert === "function") return invert(outcome);
141
- if (!invert) return outcome;
142
- return !outcome;
143
- }
144
- //#endregion
145
137
  //#region src/policy/error/module.ts
138
+ const POLICY_ERROR_INSTANCE = Symbol.for("@authup/access/PolicyError");
139
+ function isPolicyError(value) {
140
+ return typeof value === "object" && value !== null && value["@instanceof"] === POLICY_ERROR_INSTANCE;
141
+ }
146
142
  var PolicyError = class PolicyError extends AuthupError {
143
+ "@instanceof" = POLICY_ERROR_INSTANCE;
147
144
  constructor(message, code) {
148
145
  super({
149
146
  message,
@@ -168,6 +165,10 @@ var PolicyError = class PolicyError extends AuthupError {
168
165
  };
169
166
  //#endregion
170
167
  //#region src/policy/engine/module.ts
168
+ function errorMessage(value) {
169
+ if (typeof value === "object" && value !== null && "message" in value && typeof value.message === "string") return value.message;
170
+ return String(value);
171
+ }
171
172
  /**
172
173
  * The policy engine is a component that interprets defined policies and makes decisions
173
174
  * on whether to allow or deny a particular access.
@@ -190,15 +191,15 @@ var PolicyEngine = class {
190
191
  */
191
192
  async evaluate(policy, ctx) {
192
193
  if (!policy.type) return {
193
- success: maybeInvertPolicyOutcome(false, policy.invert),
194
+ success: false,
194
195
  issues: [defineIssueItem({
195
196
  path: [],
196
197
  message: "The policy can not be handled by any evaluator.",
197
198
  code: ErrorCode.POLICY_EVALUATOR_NOT_FOUND
198
199
  })]
199
200
  };
200
- if (ctx.exclude && ctx.exclude.length > 0 && ctx.exclude.includes(policy.type)) return { success: maybeInvertPolicyOutcome(true, policy.invert) };
201
- if (ctx.include && ctx.include.length > 0 && !ctx.include.includes(policy.type)) return { success: maybeInvertPolicyOutcome(true, policy.invert) };
201
+ if (ctx.exclude && ctx.exclude.length > 0 && ctx.exclude.includes(policy.type)) return { success: true };
202
+ if (ctx.include && ctx.include.length > 0 && !ctx.include.includes(policy.type)) return { success: true };
202
203
  const issues = [];
203
204
  const evaluator = this.evaluators[policy.type];
204
205
  if (!evaluator) {
@@ -208,7 +209,7 @@ var PolicyEngine = class {
208
209
  code: ErrorCode.POLICY_EVALUATOR_NOT_FOUND
209
210
  }));
210
211
  return {
211
- success: maybeInvertPolicyOutcome(false, policy.invert),
212
+ success: false,
212
213
  issues
213
214
  };
214
215
  }
@@ -220,14 +221,14 @@ var PolicyEngine = class {
220
221
  ...ctx.evaluators || {}
221
222
  }
222
223
  });
223
- } catch {
224
+ } catch (e) {
224
225
  issues.push(defineIssueItem({
225
226
  path: [policy.type],
226
- message: `The ${policy.type} evaluator can not process the policy specification.`,
227
+ message: `The ${policy.type} evaluator threw: ${errorMessage(e)}`,
227
228
  code: ErrorCode.POLICY_EVALUATOR_NOT_PROCESSABLE
228
229
  }));
229
230
  return {
230
- success: maybeInvertPolicyOutcome(false, policy.invert),
231
+ success: false,
231
232
  issues
232
233
  };
233
234
  }
@@ -239,7 +240,12 @@ var PolicyEngine = class {
239
240
  if (outcome.success) return;
240
241
  if (outcome.issues) issues.push(...outcome.issues);
241
242
  } catch (e) {
242
- if (e instanceof PolicyError) throw e;
243
+ if (isPolicyError(e)) throw e;
244
+ issues.push(defineIssueItem({
245
+ path: policy.type ? [policy.type] : [],
246
+ message: errorMessage(e),
247
+ code: ErrorCode.POLICY_EVALUATOR_NOT_PROCESSABLE
248
+ }));
243
249
  }
244
250
  const error = new PolicyError(`The policy ${policy.type} evaluation failed.`);
245
251
  error.addIssues(issues);
@@ -320,6 +326,14 @@ function definePolicyIssueGroup(input) {
320
326
  return defineIssueGroup(input);
321
327
  }
322
328
  //#endregion
329
+ //#region src/policy/helpers/invert.ts
330
+ function maybeInvertPolicyOutcome(outcome, invert) {
331
+ if (typeof invert === "undefined") return outcome;
332
+ if (typeof invert === "function") return invert(outcome);
333
+ if (!invert) return outcome;
334
+ return !outcome;
335
+ }
336
+ //#endregion
323
337
  //#region src/policy/built-in/attribute-names/validator.ts
324
338
  var AttributeNamesPolicyValidator = class extends Container {
325
339
  initialize() {
@@ -376,7 +390,10 @@ const SystemPolicyName = {
376
390
  PERMISSION_BINDING: "system.permission-binding",
377
391
  REALM_MATCH: "system.realm-match",
378
392
  REALM_BOUND: "system.realm-bound",
379
- REALM_OR_GLOBAL: "system.realm-or-global"
393
+ REALM_OR_GLOBAL: "system.realm-or-global",
394
+ CLIENT_NAMES_SELF_MANAGE: "system.client-names-self-manage",
395
+ ROBOT_NAMES_SELF_MANAGE: "system.robot-names-self-manage",
396
+ USER_NAMES_SELF_MANAGE: "system.user-names-self-manage"
380
397
  };
381
398
  //#endregion
382
399
  //#region src/policy/built-in/attributes/validator.ts
@@ -460,13 +477,16 @@ var AttributeNamesPolicyEvaluator = class {
460
477
  const attributes = flattenObject(data);
461
478
  const keys = Object.keys(attributes);
462
479
  const issues = [];
463
- for (const key of keys) if (policy.names.indexOf(key) === -1) issues.push(definePolicyIssueItem({
464
- code: "EVALUATION_DENIED",
465
- message: `The attribute ${key} is not included`,
466
- path: [...ctx.path, key]
467
- }));
480
+ for (const key of keys) {
481
+ const inList = policy.names.includes(key);
482
+ if (policy.invert ? inList : !inList) issues.push(definePolicyIssueItem({
483
+ code: "EVALUATION_DENIED",
484
+ message: policy.invert ? `The attribute ${key} is denied` : `The attribute ${key} is not included`,
485
+ path: [...ctx.path, key]
486
+ }));
487
+ }
468
488
  return {
469
- success: maybeInvertPolicyOutcome(issues.length === 0, policy.invert),
489
+ success: issues.length === 0,
470
490
  issues
471
491
  };
472
492
  }
@@ -512,21 +532,25 @@ var CompositePolicyEvaluator = class {
512
532
  issues: outcome.issues || [],
513
533
  path
514
534
  }));
515
- if (decision_strategy === DecisionStrategy.UNANIMOUS) return {
516
- success: maybeInvertPolicyOutcome(false, policy.invert),
517
- issues: [defineIssueGroup({
518
- message: `The evaluation of composite policy failed (${DecisionStrategy.UNANIMOUS})`,
519
- issues,
520
- path: ctx.path
521
- })]
522
- };
535
+ if (decision_strategy === DecisionStrategy.UNANIMOUS) {
536
+ const success = maybeInvertPolicyOutcome(false, policy.invert);
537
+ return {
538
+ success,
539
+ issues: success ? [] : [defineIssueGroup({
540
+ message: `The evaluation of composite policy failed (${DecisionStrategy.UNANIMOUS})`,
541
+ issues,
542
+ path: ctx.path
543
+ })]
544
+ };
545
+ }
523
546
  count--;
524
547
  }
525
548
  }
526
549
  if (count > 0) return { success: maybeInvertPolicyOutcome(true, policy.invert) };
550
+ const success = maybeInvertPolicyOutcome(false, policy.invert);
527
551
  return {
528
- success: maybeInvertPolicyOutcome(false, policy.invert),
529
- issues: [defineIssueGroup({
552
+ success,
553
+ issues: success ? [] : [defineIssueGroup({
530
554
  message: `The evaluation of composite policy failed (${DecisionStrategy.CONSENSUS})`,
531
555
  issues: issues || [],
532
556
  path: ctx.path
@@ -633,7 +657,7 @@ var IdentityPolicyEvaluator = class {
633
657
  path: ctx.path
634
658
  })]
635
659
  };
636
- if (!policy.types || policy.types.length === 0) return { success: maybeInvertPolicyOutcome(true, policy.invert) };
660
+ if (!policy.types || policy.types.length === 0) return { success: true };
637
661
  const typeAllowed = policy.types.includes(data.type);
638
662
  if (typeAllowed) return { success: maybeInvertPolicyOutcome(typeAllowed, policy.invert) };
639
663
  return {
@@ -706,7 +730,7 @@ var RealmMatchPolicyEvaluator = class {
706
730
  path: ctx.path
707
731
  })]
708
732
  };
709
- if ((policy.identity_master_match_all ?? true) && identity.realmName && identity.realmName === "master") return { success: maybeInvertPolicyOutcome(true, policy.invert) };
733
+ if ((policy.identity_master_match_all ?? true) && identity.realmName && identity.realmName === "master") return { success: true };
710
734
  let keys;
711
735
  if (policy.attribute_name) if (Array.isArray(policy.attribute_name)) keys = policy.attribute_name;
712
736
  else keys = [policy.attribute_name];
@@ -749,7 +773,7 @@ var RealmMatchPolicyEvaluator = class {
749
773
  count--;
750
774
  }
751
775
  }
752
- if (!evaluated) return { success: maybeInvertPolicyOutcome(true, policy.invert) };
776
+ if (!evaluated) return { success: true };
753
777
  return { success: maybeInvertPolicyOutcome(count > 0, policy.invert) };
754
778
  }
755
779
  };
@@ -1001,6 +1025,6 @@ var PermissionEvaluator = class {
1001
1025
  }
1002
1026
  };
1003
1027
  //#endregion
1004
- export { AttributeNamesPolicyEvaluator, AttributeNamesPolicyValidator, AttributesPolicyEvaluator, AttributesPolicyValidator, BuiltInPolicyType, CompositePolicyEvaluator, CompositePolicyValidator, DatePolicyEvaluator, DatePolicyValidator, DecisionStrategy, IdentityPolicyEvaluator, IdentityPolicyValidator, PermissionBindingPolicyEvaluator, PermissionBindingPolicyValidator, PermissionError, PermissionEvaluator, PermissionMemoryProvider, PolicyData, PolicyDefaultEvaluators, PolicyEngine, PolicyError, PolicyIssueCode, PolicyIssueSeverity, RealmMatchPolicyEvaluator, RealmMatchPolicyValidator, SystemPolicyName, TimePolicyEvaluator, TimePolicyInterval, TimePolicyValidator, buildPermissionKey, defineAttributesPolicy, definePolicyEvaluationContext, definePolicyIssueGroup, definePolicyIssueItem, definePolicyWithType, isCompositePolicy, isIntervalForDayOfMonth, isIntervalForDayOfWeek, isIntervalForDayOfYear, isPermissionPolicyBindingEqual, maybeInvertPolicyOutcome, mergePermissionPolicyBindings };
1028
+ export { AttributeNamesPolicyEvaluator, AttributeNamesPolicyValidator, AttributesPolicyEvaluator, AttributesPolicyValidator, BuiltInPolicyType, CompositePolicyEvaluator, CompositePolicyValidator, DatePolicyEvaluator, DatePolicyValidator, DecisionStrategy, IdentityPolicyEvaluator, IdentityPolicyValidator, PermissionBindingPolicyEvaluator, PermissionBindingPolicyValidator, PermissionError, PermissionEvaluator, PermissionMemoryProvider, PolicyData, PolicyDefaultEvaluators, PolicyEngine, PolicyError, PolicyIssueCode, PolicyIssueSeverity, RealmMatchPolicyEvaluator, RealmMatchPolicyValidator, SystemPolicyName, TimePolicyEvaluator, TimePolicyInterval, TimePolicyValidator, buildPermissionKey, defineAttributesPolicy, definePolicyEvaluationContext, definePolicyIssueGroup, definePolicyIssueItem, definePolicyWithType, isCompositePolicy, isIntervalForDayOfMonth, isIntervalForDayOfWeek, isIntervalForDayOfYear, isPermissionPolicyBindingEqual, isPolicyError, maybeInvertPolicyOutcome, mergePermissionPolicyBindings };
1005
1029
 
1006
1030
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["DecisionStrategy","normalizeDate","toDate"],"sources":["../src/permission/error/module.ts","../src/permission/helpers/equal.ts","../src/permission/helpers/key.ts","../src/permission/helpers/merge.ts","../src/permission/provider/memory.ts","../src/policy/helpers/invert.ts","../src/policy/error/module.ts","../src/policy/engine/module.ts","../src/policy/data.ts","../src/policy/evaluation/context/define.ts","../src/policy/issue/constants.ts","../src/policy/issue/define.ts","../src/policy/built-in/attribute-names/validator.ts","../src/policy/built-in/attributes/define.ts","../src/policy/built-in/constants.ts","../src/policy/built-in/attributes/validator.ts","../src/policy/built-in/attributes/evaluator.ts","../src/policy/built-in/attribute-names/evaluator.ts","../src/policy/built-in/composite/validator.ts","../src/policy/built-in/composite/evaluator.ts","../src/policy/built-in/composite/helper.ts","../src/policy/built-in/date/validator.ts","../src/policy/built-in/date/evaluator.ts","../src/policy/built-in/identity/data/validator.ts","../src/policy/built-in/identity/validator.ts","../src/policy/built-in/identity/evaluator.ts","../src/policy/built-in/permission-binding/validator.ts","../src/policy/built-in/permission-binding/module.ts","../src/policy/built-in/realm-match/validator.ts","../src/policy/built-in/realm-match/evaluator.ts","../src/policy/built-in/time/constants.ts","../src/policy/built-in/time/helpers.ts","../src/policy/built-in/time/validator.ts","../src/policy/built-in/time/evaluator.ts","../src/policy/built-in/define.ts","../src/policy/constants.ts","../src/permission/evaluator/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { AuthupErrorOptions } from '@authup/errors';\nimport { AuthupError, ErrorCode } from '@authup/errors';\nimport type { PolicyIssue } from '../../policy';\n\nexport class PermissionError extends AuthupError {\n constructor(options: AuthupErrorOptions = {}) {\n super({\n ...options,\n message: options.message || 'A permission error occurred.',\n statusCode: options.statusCode || 403,\n });\n }\n\n addIssue(data: PolicyIssue) {\n this.issues.push(data);\n }\n\n addIssues(data: PolicyIssue[]) {\n this.issues.push(...data);\n }\n\n static notFound(name: string) {\n return new PermissionError({\n message: `The permission ${name} was not found.`,\n code: ErrorCode.PERMISSION_NOT_FOUND,\n });\n }\n\n static denied(name: string) {\n return new PermissionError({\n message: `The permission ${name} has not been granted.`,\n code: ErrorCode.PERMISSION_DENIED,\n });\n }\n\n static deniedAll(names: string[]) {\n return new PermissionError({\n message: `None of the permissions ${names.join(', ')} has been granted.`,\n code: ErrorCode.PERMISSION_DENIED,\n });\n }\n\n static evaluationFailed(name: string | string[]) {\n if (Array.isArray(name)) {\n return new PermissionError({\n message: `The evaluation of permissions ${name.join(', ')} failed`,\n code: ErrorCode.PERMISSION_EVALUATION_FAILED,\n });\n }\n\n return new PermissionError({\n message: `The evaluation of permission ${name} failed`,\n code: ErrorCode.PERMISSION_EVALUATION_FAILED,\n });\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { PermissionPolicyBinding } from '../types';\n\nexport function isPermissionPolicyBindingEqual(a: PermissionPolicyBinding, b: PermissionPolicyBinding): boolean {\n if (a.permission.name !== b.permission.name) {\n return false;\n }\n\n if ((a.permission.realm_id ?? null) !== (b.permission.realm_id ?? null)) {\n return false;\n }\n\n if ((a.permission.client_id ?? null) !== (b.permission.client_id ?? null)) {\n return false;\n }\n\n return true;\n}\n","/*\n * Copyright (c) 2025-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n\nimport type { BasePermission } from '../types.ts';\n\nfunction formatKeySegment(value?: string | null): string {\n return value || '*';\n}\n\nexport function buildPermissionKey(\n input: BasePermission,\n) {\n return `${formatKeySegment(input.realm_id)}/${formatKeySegment(input.client_id)}/${input.name}`;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { DecisionStrategy } from '@authup/kit';\nimport type { BasePolicy } from '../../policy';\nimport type { PermissionPolicyBinding } from '../types';\nimport { buildPermissionKey } from './key';\n\ntype CompositePolicy = BasePolicy & {\n decision_strategy?: `${DecisionStrategy}`,\n children: BasePolicy[],\n};\n\nexport function mergePermissionPolicyBindings(input: PermissionPolicyBinding[]) : PermissionPolicyBinding[] {\n const grouped : Record<string, PermissionPolicyBinding[]> = input\n .reduce((previous, current) => {\n const key = buildPermissionKey(current.permission);\n if (!previous[key]) {\n previous[key] = [];\n }\n\n previous[key].push(current);\n\n return previous;\n }, {} as Record<string, PermissionPolicyBinding[]>);\n\n const output : PermissionPolicyBinding[] = [];\n const keys = Object.keys(grouped);\n for (const key of keys) {\n const group = grouped[key]!;\n const first = group[0]!;\n\n if (group.length === 1) {\n output.push(first);\n continue;\n }\n\n const children : BasePolicy[] = [];\n\n for (const element of group) {\n if (!element.policies || element.policies.length === 0) {\n continue;\n }\n\n const policy: CompositePolicy = {\n type: 'composite',\n decision_strategy: element.permission.decision_strategy || DecisionStrategy.UNANIMOUS,\n children: element.policies,\n };\n\n children.push(policy);\n }\n\n let mergedPolicies: BasePolicy[] | undefined;\n\n if (\n children.length > 0 &&\n children.length === group.length\n ) {\n const policy: CompositePolicy = {\n type: 'composite',\n decision_strategy: DecisionStrategy.AFFIRMATIVE,\n children,\n };\n\n mergedPolicies = [policy];\n }\n\n output.push({\n permission: {\n ...first.permission,\n decision_strategy: DecisionStrategy.AFFIRMATIVE,\n },\n policies: mergedPolicies,\n });\n }\n\n return output;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { buildPermissionKey, mergePermissionPolicyBindings } from '../helpers';\nimport type { PermissionPolicyBinding } from '../types';\nimport type { IPermissionProvider, PermissionGetOptions } from './types';\n\nexport class PermissionMemoryProvider implements IPermissionProvider {\n protected items : Record<string, PermissionPolicyBinding> = {};\n\n constructor(items: PermissionPolicyBinding[] = []) {\n this.setMany(items);\n }\n\n async findOne(\n options: PermissionGetOptions,\n ): Promise<PermissionPolicyBinding | null> {\n const key = buildPermissionKey({\n name: options.name,\n client_id: options.clientId,\n realm_id: options.realmId,\n });\n\n const entry = this.items[key];\n if (entry) {\n return entry;\n }\n\n return null;\n }\n\n setMany(input: PermissionPolicyBinding[]) {\n this.items = mergePermissionPolicyBindings(input)\n .reduce((prev, current) => {\n const key = buildPermissionKey(current.permission);\n prev[key] = current;\n return prev;\n }, {} as Record<string, PermissionPolicyBinding>);\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\ntype InvertFn = (input: boolean) => boolean;\n\nexport function maybeInvertPolicyOutcome(\n outcome: boolean,\n invert?: boolean | InvertFn,\n) {\n if (typeof invert === 'undefined') {\n return outcome;\n }\n\n if (typeof invert === 'function') {\n return invert(outcome);\n }\n\n if (!invert) {\n return outcome;\n }\n\n return !outcome;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { AuthupError, ErrorCode } from '@authup/errors';\nimport type { PolicyIssue } from '../issue';\n\nexport class PolicyError extends AuthupError {\n constructor(message?: string, code?: string | null) {\n super({\n message,\n code, \n });\n }\n\n addIssue(data: PolicyIssue) {\n this.issues.push(data);\n }\n\n addIssues(data: PolicyIssue[]) {\n this.issues.push(...data);\n }\n\n static evaluatorNotFound(type: string) {\n return new PolicyError(\n `No evaluator is registered to handle the policy: ${type}`,\n ErrorCode.POLICY_EVALUATOR_NOT_FOUND,\n );\n }\n\n static evaluatorNotProcessable() {\n return new PolicyError(\n 'The evaluator can not process the policy.',\n ErrorCode.POLICY_EVALUATOR_NOT_PROCESSABLE,\n );\n }\n\n static evaluatorContextInvalid() {\n return new PolicyError(\n 'The evaluator context is not valid.',\n ErrorCode.POLICY_EVALUATOR_CONTEXT_INVALID,\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '@authup/errors';\nimport { defineIssueItem } from 'validup';\nimport type {\n IPolicyEvaluator,\n PolicyEvaluationContext,\n PolicyEvaluationResult,\n PolicyEvaluators,\n} from '../evaluation';\nimport { maybeInvertPolicyOutcome } from '../helpers';\nimport type { PolicyIssue } from '../issue';\nimport type { IPolicyEngine } from './types.ts';\nimport { PolicyError } from '../error';\nimport type { BasePolicy } from '../types.ts';\n\n/**\n * The policy engine is a component that interprets defined policies and makes decisions\n * on whether to allow or deny a particular access.\n */\nexport class PolicyEngine implements IPolicyEngine {\n protected evaluators : Record<string, IPolicyEvaluator>;\n\n constructor(evaluators: PolicyEvaluators = {}) {\n this.evaluators = evaluators;\n }\n\n public registerEvaluator(\n type: string,\n evaluator: IPolicyEvaluator,\n ) : void {\n this.evaluators[type] = evaluator;\n }\n\n public registerEvaluators(evaluators: PolicyEvaluators) {\n const keys = Object.keys(evaluators);\n for (const key of keys) {\n this.registerEvaluator(key, evaluators[key]!);\n }\n }\n\n /**\n * @param policy\n * @param ctx\n */\n async evaluate(policy: BasePolicy, ctx: PolicyEvaluationContext) : Promise<PolicyEvaluationResult> {\n if (!policy.type) {\n return {\n success: maybeInvertPolicyOutcome(false, policy.invert),\n issues: [\n defineIssueItem({\n path: [],\n message: 'The policy can not be handled by any evaluator.',\n code: ErrorCode.POLICY_EVALUATOR_NOT_FOUND,\n }),\n ],\n };\n }\n if (\n ctx.exclude &&\n ctx.exclude.length > 0 &&\n ctx.exclude.includes(policy.type)\n ) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n if (\n ctx.include &&\n ctx.include.length > 0 &&\n !ctx.include.includes(policy.type)\n ) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n const issues : PolicyIssue[] = [];\n\n const evaluator = this.evaluators[policy.type];\n if (!evaluator) {\n // todo: add issue here instead + return false ?\n issues.push(defineIssueItem({\n path: [policy.type],\n message: `The policy ${policy.type} can not be handled by any evaluator.`,\n code: ErrorCode.POLICY_EVALUATOR_NOT_FOUND,\n }));\n\n return {\n success: maybeInvertPolicyOutcome(false, policy.invert),\n issues,\n };\n }\n\n try {\n return await evaluator.evaluate(policy, {\n ...ctx,\n evaluators: {\n ...this.evaluators,\n ...(ctx.evaluators || {}),\n },\n });\n } catch {\n issues.push(defineIssueItem({\n path: [policy.type],\n message: `The ${policy.type} evaluator can not process the policy specification.`,\n code: ErrorCode.POLICY_EVALUATOR_NOT_PROCESSABLE,\n }));\n\n return {\n success: maybeInvertPolicyOutcome(false, policy.invert),\n issues,\n };\n }\n }\n\n async evaluateOrFail(policy: BasePolicy, ctx: PolicyEvaluationContext) : Promise<void> {\n const issues : PolicyIssue[] = [];\n\n try {\n const outcome = await this.evaluate(policy, ctx);\n if (outcome.success) {\n return;\n }\n\n if (outcome.issues) {\n issues.push(...outcome.issues);\n }\n } catch (e) {\n if (e instanceof PolicyError) {\n throw e;\n }\n }\n\n const error = new PolicyError(`The policy ${policy.type} evaluation failed.`);\n error.addIssues(issues);\n\n throw error;\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport interface IPolicyData {\n set(key: string, value: unknown) : void;\n has(key: string): boolean;\n get<T = unknown>(key: string) : T;\n\n isValidated(key: string): boolean;\n setValidated(key: string) : void;\n\n clone() : IPolicyData\n}\n\nexport class PolicyData implements IPolicyData {\n protected data: Record<string, any>;\n\n protected validated : Set<string>;\n\n constructor(\n data: Record<string, any> = {},\n validated: Set<string> = new Set(),\n ) {\n this.data = data;\n this.validated = validated;\n }\n\n set<T = unknown>(key: string, value: T) : void {\n this.data[key] = value;\n this.validated.delete(key);\n }\n\n get<T = unknown>(key: string) : T {\n if (key in this.data) {\n return this.data[key];\n }\n\n throw new Error(`Policy data item ${key} does not exist.`);\n }\n\n has(key: string): boolean {\n return key in this.data;\n }\n\n setValidated(key: string) : void {\n this.validated.add(key);\n }\n\n isValidated(key: string) : boolean {\n return this.validated.has(key);\n }\n\n clone() {\n return new PolicyData({ ...this.data }, new Set(this.validated));\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { PolicyEvaluationContext, PolicyEvaluationContextInput } from './types.ts';\nimport { PolicyData } from '../../data.ts';\n\nexport function definePolicyEvaluationContext(\n input: PolicyEvaluationContextInput = {},\n) : PolicyEvaluationContext {\n return {\n evaluators: input.evaluators || {},\n path: input.path || [],\n data: input.data || new PolicyData(),\n include: input.include || [],\n exclude: input.exclude || [],\n };\n}\n","/*\n * Copyright (c) 2026-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum PolicyIssueSeverity {\n WARNING = 'warning',\n ERROR = 'error',\n}\n\nexport enum PolicyIssueCode {\n // Data/Input\n DATA_MISSING = 'DATA_MISSING',\n DATA_INVALID = 'DATA_INVALID',\n\n // Policy Spec / Config\n INVALID = 'INVALID',\n TYPE_UNKNOWN = 'TYPE_UNKNOWN',\n FIELD_MISSING = 'FIELD_MISSING',\n FIELD_INVALID = 'FIELD_INVALID',\n\n // Composite / Tree evaluation\n CHILD_INVALID = 'CHILD_INVALID',\n CHILD_EVALUATION_FAILED = 'CHILD_EVALUATION_FAILED',\n\n // Engine / Evaluator registry\n EVALUATION_DENIED = 'EVALUATION_DENIED',\n EVALUATOR_NOT_FOUND = 'EVALUATOR_NOT_FOUND',\n EVALUATOR_ERROR = 'EVALUATOR_ERROR',\n\n // Execution control\n SKIPPED_EXCLUDED = 'SKIPPED_EXCLUDED',\n SKIPPED_NOT_INCLUDED = 'SKIPPED_NOT_INCLUDED',\n\n // Internal / unexpected\n INTERNAL_ERROR = 'INTERNAL_ERROR',\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { defineIssueGroup, defineIssueItem } from 'validup';\nimport type { PolicyIssueGroup, PolicyIssueItem } from './types.ts';\n\nexport function definePolicyIssueItem(input: Omit<PolicyIssueItem, 'type'>) : PolicyIssueItem {\n return defineIssueItem(input);\n}\n\nexport function definePolicyIssueGroup(input: Omit<PolicyIssueGroup, 'type'>) : PolicyIssueGroup {\n return defineIssueGroup(input);\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { AttributeNamesPolicy } from './types';\n\nexport class AttributeNamesPolicyValidator extends Container<AttributeNamesPolicy> {\n override initialize() {\n super.initialize();\n\n this.mount(\n 'names',\n createValidator(\n z.array(\n z.string()\n .min(3)\n .max(128),\n ),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { AttributesPolicy } from './types';\n\nexport function defineAttributesPolicy<\n T extends Record<string, any> = Record<string, any>,\n>(\n data: AttributesPolicy<T>,\n) : AttributesPolicy<T> {\n return data;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum BuiltInPolicyType {\n /**\n * Bundles different policies.\n */\n COMPOSITE = 'composite',\n /**\n * Date Based Access Control (DBAC)\n */\n DATE = 'date',\n /**\n * Time Based Access Control (TBAC)\n */\n TIME = 'time',\n /**\n * Attribute Name Based Access Control (ANBAC)\n */\n ATTRIBUTE_NAMES = 'attributeNames',\n /**\n * Attribute Based Access Control (ABAC)\n */\n ATTRIBUTES = 'attributes',\n /**\n * Realm of Identity is for attribute realm.\n */\n REALM_MATCH = 'realmMatch',\n\n /**\n * Restriction based on identity (type, id, ...)\n */\n IDENTITY = 'identity',\n\n /**\n * Restriction based on a binding between identity <-> permission\n */\n PERMISSION_BINDING = 'permissionBinding',\n\n // Location (LBAC)\n // Device (DBAC)\n}\n\nexport const SystemPolicyName = {\n DEFAULT: 'system.default',\n IDENTITY: 'system.identity',\n PERMISSION_BINDING: 'system.permission-binding',\n REALM_MATCH: 'system.realm-match',\n REALM_BOUND: 'system.realm-bound',\n REALM_OR_GLOBAL: 'system.realm-or-global',\n} as const;\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { AttributesPolicy } from './types';\n\nexport class AttributesPolicyValidator<\n T extends Record<string, any> = Record<string, any>,\n> extends Container<AttributesPolicy<T>> {\n override initialize() {\n super.initialize();\n\n this.mount(\n 'query',\n createValidator(\n z.looseObject({}),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { guard } from '@ucast/mongo2js';\nimport { isObject } from '@authup/kit';\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { PolicyIssueCode, definePolicyIssueItem } from '../../issue';\nimport { BuiltInPolicyType } from '../constants.ts';\nimport { AttributesPolicyValidator } from './validator';\n\nexport class AttributesPolicyEvaluator<\n T extends Record<string, any> = Record<string, any>,\n> implements IPolicyEvaluator {\n protected validator : AttributesPolicyValidator<T>;\n\n constructor() {\n this.validator = new AttributesPolicyValidator<T>();\n }\n\n async accessData(ctx: PolicyEvaluationContext) : Promise<T | null> {\n if (!ctx.data.has(BuiltInPolicyType.ATTRIBUTES)) {\n return null;\n }\n\n if (ctx.data.isValidated(BuiltInPolicyType.ATTRIBUTES)) {\n return ctx.data.get<T>(BuiltInPolicyType.ATTRIBUTES);\n }\n\n // todo: run validator on attributes (isObject ...)\n const data = ctx.data.get<T>(BuiltInPolicyType.ATTRIBUTES);\n\n ctx.data.set(BuiltInPolicyType.ATTRIBUTES, data);\n ctx.data.setValidated(BuiltInPolicyType.ATTRIBUTES);\n\n return data;\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n const data = await this.accessData(ctx);\n if (!data) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property attributes is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n this.fixQuery(policy.query);\n\n const testIt = guard<T>(policy.query);\n\n return { success: maybeInvertPolicyOutcome(testIt(data as T), policy.invert) };\n }\n\n protected fixQuery(\n query: unknown | unknown[],\n ) {\n if (Array.isArray(query)) {\n for (const element of query) {\n this.fixQuery(element);\n }\n\n return;\n }\n\n if (isObject(query)) {\n const keys = Object.keys(query);\n for (const key of keys) {\n const value = query[key];\n\n if (isObject(value) || Array.isArray(value)) {\n this.fixQuery(value);\n continue;\n }\n\n if (\n key === '$regex' &&\n typeof value === 'string'\n ) {\n const fragments = value.match(/\\/(.*?)\\/([a-z]*)?$/i);\n if (fragments && fragments[1] !== undefined) {\n query[key] = new RegExp(fragments[1], fragments[2] || '');\n }\n }\n }\n }\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { flattenObject } from '@authup/kit';\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport type { PolicyIssue } from '../../issue';\nimport { PolicyIssueCode, definePolicyIssueItem } from '../../issue';\nimport { AttributeNamesPolicyValidator } from './validator';\nimport { AttributesPolicyEvaluator } from '../attributes';\n\nexport class AttributeNamesPolicyEvaluator implements IPolicyEvaluator {\n protected validator : AttributeNamesPolicyValidator;\n\n protected attributesEvaluator : AttributesPolicyEvaluator;\n\n constructor() {\n this.validator = new AttributeNamesPolicyValidator();\n this.attributesEvaluator = new AttributesPolicyEvaluator();\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n const data = await this.attributesEvaluator.accessData(ctx);\n if (!data) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property attributes is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n const attributes = flattenObject(data);\n const keys = Object.keys(attributes);\n\n const issues : PolicyIssue[] = [];\n for (const key of keys) {\n const index = policy.names.indexOf(key);\n if (index === -1) {\n issues.push(definePolicyIssueItem({\n code: PolicyIssueCode.EVALUATION_DENIED,\n message: `The attribute ${key} is not included`,\n path: [...ctx.path, key],\n }));\n }\n }\n\n return {\n success: maybeInvertPolicyOutcome(issues.length === 0, policy.invert),\n issues,\n };\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport { DecisionStrategy } from '../../../constants';\nimport type { CompositePolicy } from './types';\n\nexport class CompositePolicyValidator extends Container<CompositePolicy> {\n override initialize() {\n super.initialize();\n\n this.mount(\n 'decision_strategy',\n createValidator(\n z.enum(DecisionStrategy)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'children',\n createValidator(\n z.array(z.looseObject({ type: z.string().min(3) })),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { defineIssueGroup } from 'validup';\nimport { DecisionStrategy } from '../../../constants';\nimport { PolicyEngine } from '../../engine';\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport type { PolicyIssue } from '../../issue';\nimport { CompositePolicyValidator } from './validator';\n\nexport class CompositePolicyEvaluator implements IPolicyEvaluator {\n protected validator : CompositePolicyValidator;\n\n constructor() {\n this.validator = new CompositePolicyValidator();\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n let count = 0;\n\n const decision_strategy = policy.decision_strategy ??\n DecisionStrategy.UNANIMOUS;\n\n const engine = new PolicyEngine(ctx.evaluators);\n const issues : PolicyIssue[] = [];\n\n for (const childPolicy of policy.children) {\n const path = [\n ...(ctx.path || []),\n ...(childPolicy.type ? [childPolicy.type] : []),\n ];\n\n const outcome = await engine.evaluate(childPolicy, {\n ...ctx,\n path,\n });\n\n if (outcome.success) {\n if (decision_strategy === DecisionStrategy.AFFIRMATIVE) {\n return {\n success: maybeInvertPolicyOutcome(true, policy.invert),\n issues: [],\n };\n }\n\n count++;\n } else {\n if (outcome.issues) {\n issues.push(defineIssueGroup({\n message: `The evaluation of child policy ${childPolicy.type} failed`,\n issues: outcome.issues || [],\n path,\n }));\n }\n\n if (decision_strategy === DecisionStrategy.UNANIMOUS) {\n return {\n success: maybeInvertPolicyOutcome(false, policy.invert),\n issues: [\n defineIssueGroup({\n message: `The evaluation of composite policy failed (${DecisionStrategy.UNANIMOUS})`,\n issues,\n path: ctx.path,\n }),\n ],\n };\n }\n\n count--;\n }\n }\n\n if (count > 0) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n return {\n success: maybeInvertPolicyOutcome(false, policy.invert),\n issues: [\n defineIssueGroup({\n message: `The evaluation of composite policy failed (${DecisionStrategy.CONSENSUS})`,\n issues: issues || [],\n path: ctx.path,\n }),\n ],\n };\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { PolicyWithType } from '../../types';\nimport { BuiltInPolicyType } from '../constants';\nimport type { CompositePolicy } from './types';\n\nexport function isCompositePolicy(\n input: PolicyWithType,\n) : input is PolicyWithType<CompositePolicy> {\n return input.type === BuiltInPolicyType.COMPOSITE;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { DatePolicy } from './types';\n\nexport class DatePolicyValidator extends Container<DatePolicy> {\n override initialize() {\n super.initialize();\n\n this.mount('start', createValidator(\n z.date()\n .or(z.iso.date())\n .or(z.number())\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n this.mount('end', createValidator(\n z.date()\n .or(z.iso.date())\n .or(z.number())\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n\n this.mount('invert', createValidator(\n z.boolean()\n .or(z.undefined())\n .or(z.null())\n .optional(),\n ));\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { BuiltInPolicyType } from '../constants.ts';\nimport { DatePolicyValidator } from './validator';\n\nfunction normalizeDate(input: Date) {\n return new Date(input.getFullYear(), input.getMonth(), input.getDate());\n}\n\nfunction toDate(input: Date | string | number) : Date {\n if (typeof input === 'string') {\n return new Date(input);\n }\n\n if (typeof input === 'number') {\n return new Date(input);\n }\n\n return input;\n}\n\nexport class DatePolicyEvaluator implements IPolicyEvaluator {\n protected validator : DatePolicyValidator;\n\n constructor() {\n this.validator = new DatePolicyValidator();\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n let now : Date;\n\n if (ctx.data.has(BuiltInPolicyType.DATE)) {\n if (ctx.data.isValidated(BuiltInPolicyType.DATE)) {\n now = ctx.data.get<Date>(BuiltInPolicyType.DATE);\n } else {\n // todo: run validator on attributes (isObject ...)\n now = normalizeDate(toDate(ctx.data.get(BuiltInPolicyType.DATE)));\n\n ctx.data.set(BuiltInPolicyType.DATE, now);\n ctx.data.setValidated(BuiltInPolicyType.DATE);\n }\n } else {\n now = normalizeDate(new Date());\n }\n\n if (policy.start) {\n const start = normalizeDate(toDate(policy.start));\n if (now < start) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n if (policy.end) {\n const end = normalizeDate(toDate(policy.end));\n if (now > end) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\n\nimport type { IdentityPolicyData } from '../types.ts';\n\nexport class PolicyIdentityDataValidator extends Container<IdentityPolicyData> {\n override initialize() {\n super.initialize();\n\n this.mount(\n 'type',\n createValidator(\n z.string().min(3).max(128),\n ),\n );\n\n this.mount(\n 'id',\n createValidator(\n z.uuid(),\n ),\n );\n\n this.mount(\n 'clientId',\n createValidator(\n z.uuid()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'realmId',\n createValidator(\n z.uuid()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'realmName',\n createValidator(\n z.string().min(3).max(128)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { IdentityPolicy } from './types';\n\nexport class IdentityPolicyValidator extends Container<IdentityPolicy> {\n override initialize() {\n this.mount(\n 'types',\n createValidator(\n z.array(z.string())\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { PolicyIssueCode, definePolicyIssueItem } from '../../issue';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { PolicyIdentityDataValidator } from './data';\nimport type { IdentityPolicyData } from './types';\nimport { IdentityPolicyValidator } from './validator';\n\nexport class IdentityPolicyEvaluator implements IPolicyEvaluator {\n protected validator : IdentityPolicyValidator;\n\n protected dataValidator : PolicyIdentityDataValidator;\n\n constructor() {\n this.validator = new IdentityPolicyValidator();\n this.dataValidator = new PolicyIdentityDataValidator();\n }\n\n async accessData(ctx: PolicyEvaluationContext) : Promise<IdentityPolicyData | null> {\n if (!ctx.data.has('identity')) {\n return null;\n }\n\n if (ctx.data.isValidated('identity')) {\n return ctx.data.get<IdentityPolicyData>('identity');\n }\n\n const data = await this.dataValidator.run(ctx.data.get('identity'));\n\n ctx.data.set('identity', data);\n ctx.data.setValidated('identity');\n\n return data;\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n const data = await this.accessData(ctx);\n if (!data) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property identity is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n if (!policy.types || policy.types.length === 0) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n const typeAllowed = policy.types.includes(data.type);\n if (typeAllowed) {\n return { success: maybeInvertPolicyOutcome(typeAllowed, policy.invert) };\n }\n\n return {\n success: maybeInvertPolicyOutcome(typeAllowed, policy.invert),\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.EVALUATION_DENIED,\n message: `The type ${data.type} is not covered by the policy configuration`,\n path: ctx.path,\n }),\n ],\n };\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Container } from 'validup';\nimport type { PermissionBindingPolicy } from './types';\n\nexport class PermissionBindingPolicyValidator extends Container<PermissionBindingPolicy> {\n override initialize() {\n\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IPolicyEvaluator, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { PermissionBindingPolicyValidator } from './validator';\n\nexport class PermissionBindingPolicyEvaluator implements IPolicyEvaluator {\n protected validator: PermissionBindingPolicyValidator;\n\n constructor() {\n this.validator = new PermissionBindingPolicyValidator();\n }\n\n async evaluate(value: Record<string, any>): Promise<PolicyEvaluationResult> {\n const policy = await this.validator.run(value);\n\n // todo: this must be changed when the permission-checker not only checks owned permissions.\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport { DecisionStrategy } from '../../../constants';\nimport type { RealmMatchPolicy } from './types';\n\nexport class RealmMatchPolicyValidator extends Container<RealmMatchPolicy> {\n override initialize() {\n super.initialize();\n\n this.mount(\n 'decision_strategy',\n createValidator(\n z.enum(DecisionStrategy)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'attribute_name',\n createValidator(\n z.string()\n .min(3)\n .or(z.array(z.string().min(3)))\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n this.mount(\n 'attribute_name_strict',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n this.mount(\n 'attribute_null_match_all',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'identity_master_match_all',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty } from '@authup/kit';\nimport { DecisionStrategy } from '../../../constants';\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { PolicyIssueCode, definePolicyIssueItem } from '../../issue';\nimport { AttributesPolicyEvaluator } from '../attributes';\nimport { IdentityPolicyEvaluator } from '../identity';\nimport { RealmMatchPolicyValidator } from './validator';\n\nexport class RealmMatchPolicyEvaluator implements IPolicyEvaluator {\n protected validator : RealmMatchPolicyValidator;\n\n protected identityEvaluator: IdentityPolicyEvaluator;\n\n protected attributesEvaluator : AttributesPolicyEvaluator;\n\n constructor() {\n this.validator = new RealmMatchPolicyValidator();\n this.identityEvaluator = new IdentityPolicyEvaluator();\n this.attributesEvaluator = new AttributesPolicyEvaluator();\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n const identity = await this.identityEvaluator.accessData(ctx);\n if (!identity) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property identity is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n const attributes = await this.attributesEvaluator.accessData(ctx);\n if (!attributes) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property attributes is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n const identityMasterMatchAll = policy.identity_master_match_all ?? true;\n if (\n identityMasterMatchAll &&\n identity.realmName &&\n identity.realmName === 'master'\n ) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n let keys : string[];\n if (policy.attribute_name) {\n if (Array.isArray(policy.attribute_name)) {\n keys = policy.attribute_name;\n } else {\n keys = [policy.attribute_name];\n }\n } else {\n keys = [\n 'realm_id',\n 'realm_name',\n 'realmId',\n 'realmName',\n ];\n\n policy.decision_strategy = DecisionStrategy.CONSENSUS;\n }\n\n const attribute_name_strict = policy.attribute_name_strict ?? true;\n if (!attribute_name_strict) {\n const resourceKeys = Object.keys(attributes);\n const keysToAdd : string[] = [];\n for (const resourceKey of resourceKeys) {\n let contains : boolean = false;\n\n for (const key of keys) {\n if (\n resourceKey !== key &&\n resourceKey.includes(key)\n ) {\n contains = true;\n break;\n }\n }\n\n if (contains) {\n keysToAdd.push(resourceKey);\n }\n }\n\n if (keysToAdd.length > 0) {\n keys.push(...keysToAdd);\n }\n }\n\n let count = 0;\n let evaluated = false;\n\n for (const key of keys) {\n if (!hasOwnProperty(attributes, key)) {\n continue;\n }\n\n evaluated = true;\n\n let outcome : boolean = false;\n\n const attributeValue = attributes[key];\n\n if (\n attributeValue === null &&\n policy.attribute_null_match_all\n ) {\n outcome = true;\n } else if (\n attributeValue === identity.realmId ||\n attributeValue === identity.realmName\n ) {\n outcome = true;\n }\n\n if (outcome) {\n if (policy.decision_strategy === DecisionStrategy.AFFIRMATIVE) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n count++;\n } else {\n if (policy.decision_strategy === DecisionStrategy.UNANIMOUS) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n\n count--;\n }\n }\n\n if (!evaluated) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n return { success: maybeInvertPolicyOutcome(count > 0, policy.invert) };\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum TimePolicyInterval {\n DAILY = 'daily',\n WEEKLY = 'weekly',\n MONTHLY = 'monthly',\n YEARLY = 'yearly',\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { TimePolicyInterval } from './constants';\n\nexport function isIntervalForDayOfWeek(\n interval: string,\n) {\n return interval === TimePolicyInterval.WEEKLY ||\n interval === TimePolicyInterval.MONTHLY ||\n interval === TimePolicyInterval.YEARLY;\n}\n\nexport function isIntervalForDayOfMonth(\n interval: string,\n) {\n return interval === TimePolicyInterval.MONTHLY ||\n interval === TimePolicyInterval.YEARLY;\n}\n\nexport function isIntervalForDayOfYear(\n interval: string,\n) {\n return interval === TimePolicyInterval.YEARLY;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { TimePolicy } from './types';\nimport { TimePolicyInterval } from './constants';\n\nexport class TimePolicyValidator extends Container<TimePolicy> {\n override initialize() {\n super.initialize();\n\n this.mount('day_of_week', createValidator(\n z.number()\n .min(0).max(6)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n this.mount('day_of_month', createValidator(\n z.number()\n .min(1)\n .max(31)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n this.mount('day_of_year', createValidator(\n z.number()\n .min(1)\n .max(365)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n\n this.mount('start', createValidator(\n z.date()\n .or(z.iso.datetime())\n .or(z.iso.time())\n .or(z.number())\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n this.mount('end', createValidator(\n z.date()\n .or(z.iso.datetime())\n .or(z.iso.time())\n .or(z.number())\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n\n this.mount(\n 'interval',\n createValidator(\n z.enum(TimePolicyInterval)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.undefined())\n .or(z.null())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { BuiltInPolicyType } from '../constants';\nimport { isIntervalForDayOfMonth, isIntervalForDayOfWeek, isIntervalForDayOfYear } from './helpers';\nimport { TimePolicyValidator } from './validator';\n\nconst timeRegex = /^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$/;\n\nfunction normalizeDate(input: Date, dateRef?: Date) {\n const date = dateRef ? new Date(dateRef) : new Date();\n date.setHours(input.getHours(), input.getMinutes());\n\n return date;\n}\n\nfunction toDate(\n input: Date | string | number,\n dateRef?: Date,\n) : Date {\n if (typeof input === 'string') {\n if (timeRegex.test(input)) {\n const parts = input.split(':');\n\n const startHours = Number(parts[0]);\n const startMinutes = Number(parts[1]);\n const startSeconds = parts[2] !== undefined ? Number(parts[2]) : 0;\n\n if (\n Number.isFinite(startHours) &&\n Number.isFinite(startMinutes) &&\n Number.isFinite(startSeconds)\n ) {\n const date = dateRef ? new Date(dateRef) : new Date();\n date.setHours(startHours, startMinutes, startSeconds, 0);\n\n return date;\n }\n }\n\n return new Date(input);\n }\n\n if (typeof input === 'number') {\n return new Date(input);\n }\n\n return input;\n}\n\nexport class TimePolicyEvaluator implements IPolicyEvaluator {\n protected validator : TimePolicyValidator;\n\n constructor() {\n this.validator = new TimePolicyValidator();\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n let now : Date;\n\n if (ctx.data.has(BuiltInPolicyType.TIME)) {\n if (ctx.data.isValidated(BuiltInPolicyType.TIME)) {\n now = ctx.data.get<Date>(BuiltInPolicyType.TIME);\n } else {\n // todo: run validator on attributes (isObject ...)\n now = toDate(ctx.data.get(BuiltInPolicyType.TIME));\n\n ctx.data.set(BuiltInPolicyType.TIME, now);\n ctx.data.setValidated(BuiltInPolicyType.TIME);\n }\n } else {\n now = new Date();\n }\n\n if (policy.start) {\n const start = normalizeDate(toDate(policy.start, now), now);\n if (now < start) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n if (policy.end) {\n const end = normalizeDate(toDate(policy.end, now), now);\n if (now > end) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n if (policy.interval) {\n if (\n isIntervalForDayOfWeek(policy.interval) &&\n policy.day_of_week\n ) {\n if (now.getDay() !== policy.day_of_week) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n if (\n isIntervalForDayOfMonth(policy.interval) &&\n policy.day_of_month\n ) {\n if (now.getDate() !== policy.day_of_month) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n if (\n isIntervalForDayOfYear(policy.interval) &&\n policy.day_of_year\n ) {\n const start = new Date(now.getFullYear(), 0, 0);\n const diff = (now.getTime() - start.getTime()) +\n ((start.getTimezoneOffset() - now.getTimezoneOffset()) * 60 * 1000);\n\n const oneDay = 1000 * 60 * 60 * 24;\n const dayOfYear = Math.floor(diff / oneDay);\n\n if (dayOfYear !== policy.day_of_year) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n }\n\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { PolicyWithType } from '../types';\nimport type { BuiltInPolicyTypeMap } from './types';\n\nexport function definePolicyWithType<\n K extends keyof BuiltInPolicyTypeMap,\n D extends BuiltInPolicyTypeMap<any>[K],\n>(\n type: K,\n data: D,\n) : PolicyWithType<D, K> {\n return {\n ...data,\n type,\n };\n}\n","/*\n * Copyright (c) 2026-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport {\n AttributeNamesPolicyEvaluator,\n AttributesPolicyEvaluator,\n BuiltInPolicyType,\n CompositePolicyEvaluator,\n DatePolicyEvaluator,\n IdentityPolicyEvaluator,\n PermissionBindingPolicyEvaluator,\n RealmMatchPolicyEvaluator,\n TimePolicyEvaluator,\n} from './built-in';\n\nexport const PolicyDefaultEvaluators = {\n [BuiltInPolicyType.COMPOSITE]: new CompositePolicyEvaluator(),\n [BuiltInPolicyType.ATTRIBUTES]: new AttributesPolicyEvaluator(),\n [BuiltInPolicyType.ATTRIBUTE_NAMES]: new AttributeNamesPolicyEvaluator(),\n [BuiltInPolicyType.DATE]: new DatePolicyEvaluator(),\n [BuiltInPolicyType.IDENTITY]: new IdentityPolicyEvaluator(),\n [BuiltInPolicyType.PERMISSION_BINDING]: new PermissionBindingPolicyEvaluator(),\n [BuiltInPolicyType.REALM_MATCH]: new RealmMatchPolicyEvaluator(),\n [BuiltInPolicyType.TIME]: new TimePolicyEvaluator(),\n} as const;\n","/*\n * Copyright (c) 2021-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '@authup/errors';\nimport type { Issue } from 'validup';\nimport { defineIssueItem } from 'validup';\nimport { DecisionStrategy } from '../../constants.ts';\nimport type { CompositePolicy, IPolicyEngine } from '../../policy';\nimport {\n BuiltInPolicyType,\n PolicyData,\n PolicyDefaultEvaluators,\n PolicyEngine,\n definePolicyEvaluationContext,\n definePolicyIssueGroup,\n} from '../../policy';\nimport { PermissionError } from '../error';\nimport type { IPermissionProvider } from '../provider';\n\nimport type { PermissionPolicyBinding } from '../types.ts';\nimport type { IPermissionEvaluator, PermissionEvaluationContext, PermissionEvaluatorOptions } from './types.ts';\n\nexport class PermissionEvaluator implements IPermissionEvaluator {\n protected provider : IPermissionProvider;\n\n protected policyEngine : IPolicyEngine;\n\n protected clientId?: string | null;\n\n protected realmId?: string | null;\n\n // ----------------------------------------------\n\n constructor(options: PermissionEvaluatorOptions) {\n this.provider = options.provider;\n\n this.clientId = options.clientId || null;\n this.realmId = options.realmId || null;\n\n if (options.policyEngine) {\n this.policyEngine = options.policyEngine;\n } else {\n this.policyEngine = new PolicyEngine(PolicyDefaultEvaluators);\n }\n }\n\n // ----------------------------------------------\n\n protected async findOne(\n input: string,\n overrides: {\n realmId?: string | null,\n clientId?: string | null\n } = {},\n ) : Promise<PermissionPolicyBinding | null> {\n return this.provider.findOne({\n name: input,\n clientId: overrides.clientId ?? this.clientId,\n realmId: overrides.realmId ?? this.realmId,\n });\n }\n\n // ----------------------------------------------\n\n async evaluate(ctx: PermissionEvaluationContext) : Promise<void> {\n if (!Array.isArray(ctx.name)) {\n await this.evaluate({\n ...ctx,\n name: [ctx.name],\n });\n return;\n }\n\n const { options = {} } = ctx;\n\n const decisionStrategy = options.decisionStrategy ??\n DecisionStrategy.UNANIMOUS;\n\n const issues : Issue[] = [];\n\n let count = 0;\n\n const dataBase = ctx.input || new PolicyData();\n\n for (const name of ctx.name) {\n const binding = await this.findOne(name, {\n realmId: ctx.realmId,\n clientId: ctx.clientId,\n });\n if (!binding) {\n issues.push(defineIssueItem({\n code: ErrorCode.PERMISSION_NOT_FOUND,\n message: `The ${name} permission could not be resolved`,\n path: [name],\n }));\n\n if (decisionStrategy === DecisionStrategy.UNANIMOUS) {\n const error = PermissionError.evaluationFailed(ctx.name);\n error.addIssues(issues);\n throw error;\n }\n\n continue;\n }\n\n const policies = binding.policies ?? [];\n if (policies.length === 0) {\n if (decisionStrategy === DecisionStrategy.AFFIRMATIVE) {\n return;\n }\n\n count++;\n\n continue;\n }\n\n const data = dataBase.clone();\n data.set(BuiltInPolicyType.PERMISSION_BINDING, binding);\n\n const policyDecisionStrategy = binding.permission.decision_strategy ??\n DecisionStrategy.UNANIMOUS;\n\n const compositePolicy : CompositePolicy = {\n type: BuiltInPolicyType.COMPOSITE,\n decision_strategy: policyDecisionStrategy,\n children: policies,\n };\n\n const evaluationResult = await this.policyEngine.evaluate(\n compositePolicy,\n definePolicyEvaluationContext({\n include: options.policiesIncluded,\n exclude: options.policiesExcluded,\n data,\n }),\n );\n\n if (evaluationResult.success) {\n if (decisionStrategy === DecisionStrategy.AFFIRMATIVE) {\n return;\n }\n\n count++;\n } else {\n issues.push(definePolicyIssueGroup({\n code: ErrorCode.PERMISSION_EVALUATION_FAILED,\n issues: evaluationResult.issues || [],\n message: `The ${binding.permission.name} permissions policy evaluation failed`,\n path: [binding.permission.name],\n }));\n\n if (decisionStrategy === DecisionStrategy.UNANIMOUS) {\n const error = PermissionError.evaluationFailed(binding.permission.name);\n error.addIssues(issues);\n throw error;\n }\n\n count--;\n }\n }\n\n if (count > 0) {\n return;\n }\n\n if (issues.length === 0) {\n throw PermissionError.deniedAll(ctx.name);\n } else {\n const error = PermissionError.evaluationFailed(ctx.name);\n error.addIssues(issues);\n throw error;\n }\n }\n\n async evaluateOneOf(ctx: PermissionEvaluationContext) : Promise<void> {\n return this.evaluate({\n ...ctx,\n options: {\n ...(ctx.options || {}),\n decisionStrategy: DecisionStrategy.AFFIRMATIVE,\n },\n });\n }\n\n // ----------------------------------------------\n\n async preEvaluate(ctx: PermissionEvaluationContext) : Promise<void> {\n return this.evaluate({\n ...ctx,\n options: {\n ...(ctx.options || {}),\n policiesExcluded: [\n BuiltInPolicyType.ATTRIBUTES,\n BuiltInPolicyType.ATTRIBUTE_NAMES,\n BuiltInPolicyType.REALM_MATCH,\n ],\n },\n });\n }\n\n async preEvaluateOneOf(ctx: PermissionEvaluationContext) : Promise<void> {\n return this.preEvaluate({\n ...ctx,\n options: {\n ...(ctx.options || {}),\n decisionStrategy: DecisionStrategy.AFFIRMATIVE,\n },\n });\n }\n}\n"],"mappings":";;;;;;;AAWA,IAAa,kBAAb,MAAa,wBAAwB,YAAY;CAC7C,YAAY,UAA8B,EAAE,EAAE;AAC1C,QAAM;GACF,GAAG;GACH,SAAS,QAAQ,WAAW;GAC5B,YAAY,QAAQ,cAAc;GACrC,CAAC;;CAGN,SAAS,MAAmB;AACxB,OAAK,OAAO,KAAK,KAAK;;CAG1B,UAAU,MAAqB;AAC3B,OAAK,OAAO,KAAK,GAAG,KAAK;;CAG7B,OAAO,SAAS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,gBAAgB,iBAAiB,IAAI,KAAK;AACxD,SAAM,UAAU,OAAO;AACvB,SAAM;;;CAId,MAAM,cAAc,KAAkD;AAClE,SAAO,KAAK,SAAS;GACjB,GAAG;GACH,SAAS;IACL,GAAI,IAAI,WAAW,EAAE;IACrB,kBAAkB,iBAAiB;IACtC;GACJ,CAAC;;CAKN,MAAM,YAAY,KAAkD;AAChE,SAAO,KAAK,SAAS;GACjB,GAAG;GACH,SAAS;IACL,GAAI,IAAI,WAAW,EAAE;IACrB,kBAAkB;;;;KAIjB;IACJ;GACJ,CAAC;;CAGN,MAAM,iBAAiB,KAAkD;AACrE,SAAO,KAAK,YAAY;GACpB,GAAG;GACH,SAAS;IACL,GAAI,IAAI,WAAW,EAAE;IACrB,kBAAkB,iBAAiB;IACtC;GACJ,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["DecisionStrategy","normalizeDate","toDate"],"sources":["../src/permission/error/module.ts","../src/permission/helpers/equal.ts","../src/permission/helpers/key.ts","../src/permission/helpers/merge.ts","../src/permission/provider/memory.ts","../src/policy/error/module.ts","../src/policy/engine/module.ts","../src/policy/data.ts","../src/policy/evaluation/context/define.ts","../src/policy/issue/constants.ts","../src/policy/issue/define.ts","../src/policy/helpers/invert.ts","../src/policy/built-in/attribute-names/validator.ts","../src/policy/built-in/attributes/define.ts","../src/policy/built-in/constants.ts","../src/policy/built-in/attributes/validator.ts","../src/policy/built-in/attributes/evaluator.ts","../src/policy/built-in/attribute-names/evaluator.ts","../src/policy/built-in/composite/validator.ts","../src/policy/built-in/composite/evaluator.ts","../src/policy/built-in/composite/helper.ts","../src/policy/built-in/date/validator.ts","../src/policy/built-in/date/evaluator.ts","../src/policy/built-in/identity/data/validator.ts","../src/policy/built-in/identity/validator.ts","../src/policy/built-in/identity/evaluator.ts","../src/policy/built-in/permission-binding/validator.ts","../src/policy/built-in/permission-binding/module.ts","../src/policy/built-in/realm-match/validator.ts","../src/policy/built-in/realm-match/evaluator.ts","../src/policy/built-in/time/constants.ts","../src/policy/built-in/time/helpers.ts","../src/policy/built-in/time/validator.ts","../src/policy/built-in/time/evaluator.ts","../src/policy/built-in/define.ts","../src/policy/constants.ts","../src/permission/evaluator/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { AuthupErrorOptions } from '@authup/errors';\nimport { AuthupError, ErrorCode } from '@authup/errors';\nimport type { PolicyIssue } from '../../policy';\n\nexport class PermissionError extends AuthupError {\n constructor(options: AuthupErrorOptions = {}) {\n super({\n ...options,\n message: options.message || 'A permission error occurred.',\n statusCode: options.statusCode || 403,\n });\n }\n\n addIssue(data: PolicyIssue) {\n this.issues.push(data);\n }\n\n addIssues(data: PolicyIssue[]) {\n this.issues.push(...data);\n }\n\n static notFound(name: string) {\n return new PermissionError({\n message: `The permission ${name} was not found.`,\n code: ErrorCode.PERMISSION_NOT_FOUND,\n });\n }\n\n static denied(name: string) {\n return new PermissionError({\n message: `The permission ${name} has not been granted.`,\n code: ErrorCode.PERMISSION_DENIED,\n });\n }\n\n static deniedAll(names: string[]) {\n return new PermissionError({\n message: `None of the permissions ${names.join(', ')} has been granted.`,\n code: ErrorCode.PERMISSION_DENIED,\n });\n }\n\n static evaluationFailed(name: string | string[]) {\n if (Array.isArray(name)) {\n return new PermissionError({\n message: `The evaluation of permissions ${name.join(', ')} failed`,\n code: ErrorCode.PERMISSION_EVALUATION_FAILED,\n });\n }\n\n return new PermissionError({\n message: `The evaluation of permission ${name} failed`,\n code: ErrorCode.PERMISSION_EVALUATION_FAILED,\n });\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { PermissionPolicyBinding } from '../types';\n\nexport function isPermissionPolicyBindingEqual(a: PermissionPolicyBinding, b: PermissionPolicyBinding): boolean {\n if (a.permission.name !== b.permission.name) {\n return false;\n }\n\n if ((a.permission.realm_id ?? null) !== (b.permission.realm_id ?? null)) {\n return false;\n }\n\n if ((a.permission.client_id ?? null) !== (b.permission.client_id ?? null)) {\n return false;\n }\n\n return true;\n}\n","/*\n * Copyright (c) 2025-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n\nimport type { BasePermission } from '../types.ts';\n\nfunction formatKeySegment(value?: string | null): string {\n return value || '*';\n}\n\nexport function buildPermissionKey(\n input: BasePermission,\n) {\n return `${formatKeySegment(input.realm_id)}/${formatKeySegment(input.client_id)}/${input.name}`;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { DecisionStrategy } from '@authup/kit';\nimport type { BasePolicy } from '../../policy';\nimport type { PermissionPolicyBinding } from '../types';\nimport { buildPermissionKey } from './key';\n\ntype CompositePolicy = BasePolicy & {\n decision_strategy?: `${DecisionStrategy}`,\n children: BasePolicy[],\n};\n\nexport function mergePermissionPolicyBindings(input: PermissionPolicyBinding[]) : PermissionPolicyBinding[] {\n const grouped : Record<string, PermissionPolicyBinding[]> = input\n .reduce((previous, current) => {\n const key = buildPermissionKey(current.permission);\n if (!previous[key]) {\n previous[key] = [];\n }\n\n previous[key].push(current);\n\n return previous;\n }, {} as Record<string, PermissionPolicyBinding[]>);\n\n const output : PermissionPolicyBinding[] = [];\n const keys = Object.keys(grouped);\n for (const key of keys) {\n const group = grouped[key]!;\n const first = group[0]!;\n\n if (group.length === 1) {\n output.push(first);\n continue;\n }\n\n const children : BasePolicy[] = [];\n\n for (const element of group) {\n if (!element.policies || element.policies.length === 0) {\n continue;\n }\n\n const policy: CompositePolicy = {\n type: 'composite',\n decision_strategy: element.permission.decision_strategy || DecisionStrategy.UNANIMOUS,\n children: element.policies,\n };\n\n children.push(policy);\n }\n\n let mergedPolicies: BasePolicy[] | undefined;\n\n if (\n children.length > 0 &&\n children.length === group.length\n ) {\n const policy: CompositePolicy = {\n type: 'composite',\n decision_strategy: DecisionStrategy.AFFIRMATIVE,\n children,\n };\n\n mergedPolicies = [policy];\n }\n\n output.push({\n permission: {\n ...first.permission,\n decision_strategy: DecisionStrategy.AFFIRMATIVE,\n },\n policies: mergedPolicies,\n });\n }\n\n return output;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { buildPermissionKey, mergePermissionPolicyBindings } from '../helpers';\nimport type { PermissionPolicyBinding } from '../types';\nimport type { IPermissionProvider, PermissionGetOptions } from './types';\n\nexport class PermissionMemoryProvider implements IPermissionProvider {\n protected items : Record<string, PermissionPolicyBinding> = {};\n\n constructor(items: PermissionPolicyBinding[] = []) {\n this.setMany(items);\n }\n\n async findOne(\n options: PermissionGetOptions,\n ): Promise<PermissionPolicyBinding | null> {\n const key = buildPermissionKey({\n name: options.name,\n client_id: options.clientId,\n realm_id: options.realmId,\n });\n\n const entry = this.items[key];\n if (entry) {\n return entry;\n }\n\n return null;\n }\n\n setMany(input: PermissionPolicyBinding[]) {\n this.items = mergePermissionPolicyBindings(input)\n .reduce((prev, current) => {\n const key = buildPermissionKey(current.permission);\n prev[key] = current;\n return prev;\n }, {} as Record<string, PermissionPolicyBinding>);\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { AuthupError, ErrorCode } from '@authup/errors';\nimport type { PolicyIssue } from '../issue';\n\n// Symbol used by `isPolicyError` for duck-type detection across realm/bundler\n// boundaries where `instanceof` is unreliable. Mirrors the routup convention:\n// instances carry an `@instanceof` property pointing to this symbol.\nconst POLICY_ERROR_INSTANCE = Symbol.for('@authup/access/PolicyError');\n\nexport function isPolicyError(value: unknown): value is PolicyError {\n return typeof value === 'object' &&\n value !== null &&\n (value as Record<string, unknown>)['@instanceof'] === POLICY_ERROR_INSTANCE;\n}\n\nexport class PolicyError extends AuthupError {\n readonly '@instanceof' = POLICY_ERROR_INSTANCE;\n\n constructor(message?: string, code?: string | null) {\n super({\n message,\n code,\n });\n }\n\n addIssue(data: PolicyIssue) {\n this.issues.push(data);\n }\n\n addIssues(data: PolicyIssue[]) {\n this.issues.push(...data);\n }\n\n static evaluatorNotFound(type: string) {\n return new PolicyError(\n `No evaluator is registered to handle the policy: ${type}`,\n ErrorCode.POLICY_EVALUATOR_NOT_FOUND,\n );\n }\n\n static evaluatorNotProcessable() {\n return new PolicyError(\n 'The evaluator can not process the policy.',\n ErrorCode.POLICY_EVALUATOR_NOT_PROCESSABLE,\n );\n }\n\n static evaluatorContextInvalid() {\n return new PolicyError(\n 'The evaluator context is not valid.',\n ErrorCode.POLICY_EVALUATOR_CONTEXT_INVALID,\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '@authup/errors';\nimport { defineIssueItem } from 'validup';\nimport type {\n IPolicyEvaluator,\n PolicyEvaluationContext,\n PolicyEvaluationResult,\n PolicyEvaluators,\n} from '../evaluation';\nimport type { PolicyIssue } from '../issue';\nimport type { IPolicyEngine } from './types.ts';\nimport { PolicyError, isPolicyError } from '../error';\nimport type { BasePolicy } from '../types.ts';\n\n// Cross-realm-safe extraction of an error message from an unknown thrown\n// value. `instanceof Error` is unreliable across module boundaries (different\n// realms, dual-bundled packages), so we duck-type on the `message` shape.\nfunction errorMessage(value: unknown): string {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'message' in value &&\n typeof (value as { message: unknown }).message === 'string'\n ) {\n return (value as { message: string }).message;\n }\n return String(value);\n}\n\n/**\n * The policy engine is a component that interprets defined policies and makes decisions\n * on whether to allow or deny a particular access.\n */\nexport class PolicyEngine implements IPolicyEngine {\n protected evaluators : Record<string, IPolicyEvaluator>;\n\n constructor(evaluators: PolicyEvaluators = {}) {\n this.evaluators = evaluators;\n }\n\n public registerEvaluator(\n type: string,\n evaluator: IPolicyEvaluator,\n ) : void {\n this.evaluators[type] = evaluator;\n }\n\n public registerEvaluators(evaluators: PolicyEvaluators) {\n const keys = Object.keys(evaluators);\n for (const key of keys) {\n this.registerEvaluator(key, evaluators[key]!);\n }\n }\n\n /**\n * @param policy\n * @param ctx\n */\n async evaluate(policy: BasePolicy, ctx: PolicyEvaluationContext) : Promise<PolicyEvaluationResult> {\n // Infrastructure errors (no type, no evaluator, evaluator threw) MUST\n // fail closed regardless of `policy.invert`. Inverting an error path\n // would silently grant access on misconfiguration — with `invert: true`\n // an unregistered policy type would return success: true.\n if (!policy.type) {\n return {\n success: false,\n issues: [\n defineIssueItem({\n path: [],\n message: 'The policy can not be handled by any evaluator.',\n code: ErrorCode.POLICY_EVALUATOR_NOT_FOUND,\n }),\n ],\n };\n }\n // When a policy is filtered out via include/exclude, treat it as a\n // neutral pass — do NOT apply `invert`. Inversion only makes sense\n // for an actual evaluation outcome; skipping a policy because it's\n // outside the current context's scope is not an outcome.\n if (\n ctx.exclude &&\n ctx.exclude.length > 0 &&\n ctx.exclude.includes(policy.type)\n ) {\n return { success: true };\n }\n\n if (\n ctx.include &&\n ctx.include.length > 0 &&\n !ctx.include.includes(policy.type)\n ) {\n return { success: true };\n }\n\n const issues : PolicyIssue[] = [];\n\n const evaluator = this.evaluators[policy.type];\n if (!evaluator) {\n issues.push(defineIssueItem({\n path: [policy.type],\n message: `The policy ${policy.type} can not be handled by any evaluator.`,\n code: ErrorCode.POLICY_EVALUATOR_NOT_FOUND,\n }));\n\n return {\n success: false,\n issues,\n };\n }\n\n try {\n return await evaluator.evaluate(policy, {\n ...ctx,\n evaluators: {\n ...this.evaluators,\n ...(ctx.evaluators || {}),\n },\n });\n } catch (e) {\n issues.push(defineIssueItem({\n path: [policy.type],\n message: `The ${policy.type} evaluator threw: ${errorMessage(e)}`,\n code: ErrorCode.POLICY_EVALUATOR_NOT_PROCESSABLE,\n }));\n\n return {\n success: false,\n issues,\n };\n }\n }\n\n async evaluateOrFail(policy: BasePolicy, ctx: PolicyEvaluationContext) : Promise<void> {\n const issues : PolicyIssue[] = [];\n\n try {\n const outcome = await this.evaluate(policy, ctx);\n if (outcome.success) {\n return;\n }\n\n if (outcome.issues) {\n issues.push(...outcome.issues);\n }\n } catch (e) {\n if (isPolicyError(e)) {\n throw e;\n }\n\n // Surface non-PolicyError throws (DB failures, validator crashes, etc.)\n // as issues so the root cause is visible instead of being swallowed\n // behind a generic policy failure.\n issues.push(defineIssueItem({\n path: policy.type ? [policy.type] : [],\n message: errorMessage(e),\n code: ErrorCode.POLICY_EVALUATOR_NOT_PROCESSABLE,\n }));\n }\n\n const error = new PolicyError(`The policy ${policy.type} evaluation failed.`);\n error.addIssues(issues);\n\n throw error;\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport interface IPolicyData {\n set(key: string, value: unknown) : void;\n has(key: string): boolean;\n get<T = unknown>(key: string) : T;\n\n isValidated(key: string): boolean;\n setValidated(key: string) : void;\n\n clone() : IPolicyData\n}\n\nexport class PolicyData implements IPolicyData {\n protected data: Record<string, any>;\n\n protected validated : Set<string>;\n\n constructor(\n data: Record<string, any> = {},\n validated: Set<string> = new Set(),\n ) {\n this.data = data;\n this.validated = validated;\n }\n\n set<T = unknown>(key: string, value: T) : void {\n this.data[key] = value;\n this.validated.delete(key);\n }\n\n get<T = unknown>(key: string) : T {\n if (key in this.data) {\n return this.data[key];\n }\n\n throw new Error(`Policy data item ${key} does not exist.`);\n }\n\n has(key: string): boolean {\n return key in this.data;\n }\n\n setValidated(key: string) : void {\n this.validated.add(key);\n }\n\n isValidated(key: string) : boolean {\n return this.validated.has(key);\n }\n\n clone() {\n return new PolicyData({ ...this.data }, new Set(this.validated));\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { PolicyEvaluationContext, PolicyEvaluationContextInput } from './types.ts';\nimport { PolicyData } from '../../data.ts';\n\nexport function definePolicyEvaluationContext(\n input: PolicyEvaluationContextInput = {},\n) : PolicyEvaluationContext {\n return {\n evaluators: input.evaluators || {},\n path: input.path || [],\n data: input.data || new PolicyData(),\n include: input.include || [],\n exclude: input.exclude || [],\n };\n}\n","/*\n * Copyright (c) 2026-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum PolicyIssueSeverity {\n WARNING = 'warning',\n ERROR = 'error',\n}\n\nexport enum PolicyIssueCode {\n // Data/Input\n DATA_MISSING = 'DATA_MISSING',\n DATA_INVALID = 'DATA_INVALID',\n\n // Policy Spec / Config\n INVALID = 'INVALID',\n TYPE_UNKNOWN = 'TYPE_UNKNOWN',\n FIELD_MISSING = 'FIELD_MISSING',\n FIELD_INVALID = 'FIELD_INVALID',\n\n // Composite / Tree evaluation\n CHILD_INVALID = 'CHILD_INVALID',\n CHILD_EVALUATION_FAILED = 'CHILD_EVALUATION_FAILED',\n\n // Engine / Evaluator registry\n EVALUATION_DENIED = 'EVALUATION_DENIED',\n EVALUATOR_NOT_FOUND = 'EVALUATOR_NOT_FOUND',\n EVALUATOR_ERROR = 'EVALUATOR_ERROR',\n\n // Execution control\n SKIPPED_EXCLUDED = 'SKIPPED_EXCLUDED',\n SKIPPED_NOT_INCLUDED = 'SKIPPED_NOT_INCLUDED',\n\n // Internal / unexpected\n INTERNAL_ERROR = 'INTERNAL_ERROR',\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { defineIssueGroup, defineIssueItem } from 'validup';\nimport type { PolicyIssueGroup, PolicyIssueItem } from './types.ts';\n\nexport function definePolicyIssueItem(input: Omit<PolicyIssueItem, 'type'>) : PolicyIssueItem {\n return defineIssueItem(input);\n}\n\nexport function definePolicyIssueGroup(input: Omit<PolicyIssueGroup, 'type'>) : PolicyIssueGroup {\n return defineIssueGroup(input);\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\ntype InvertFn = (input: boolean) => boolean;\n\nexport function maybeInvertPolicyOutcome(\n outcome: boolean,\n invert?: boolean | InvertFn,\n) {\n if (typeof invert === 'undefined') {\n return outcome;\n }\n\n if (typeof invert === 'function') {\n return invert(outcome);\n }\n\n if (!invert) {\n return outcome;\n }\n\n return !outcome;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { AttributeNamesPolicy } from './types';\n\nexport class AttributeNamesPolicyValidator extends Container<AttributeNamesPolicy> {\n override initialize() {\n super.initialize();\n\n this.mount(\n 'names',\n createValidator(\n z.array(\n z.string()\n .min(3)\n .max(128),\n ),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { AttributesPolicy } from './types';\n\nexport function defineAttributesPolicy<\n T extends Record<string, any> = Record<string, any>,\n>(\n data: AttributesPolicy<T>,\n) : AttributesPolicy<T> {\n return data;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum BuiltInPolicyType {\n /**\n * Bundles different policies.\n */\n COMPOSITE = 'composite',\n /**\n * Date Based Access Control (DBAC)\n */\n DATE = 'date',\n /**\n * Time Based Access Control (TBAC)\n */\n TIME = 'time',\n /**\n * Attribute Name Based Access Control (ANBAC)\n */\n ATTRIBUTE_NAMES = 'attributeNames',\n /**\n * Attribute Based Access Control (ABAC)\n */\n ATTRIBUTES = 'attributes',\n /**\n * Realm of Identity is for attribute realm.\n */\n REALM_MATCH = 'realmMatch',\n\n /**\n * Restriction based on identity (type, id, ...)\n */\n IDENTITY = 'identity',\n\n /**\n * Restriction based on a binding between identity <-> permission\n */\n PERMISSION_BINDING = 'permissionBinding',\n\n // Location (LBAC)\n // Device (DBAC)\n}\n\nexport const SystemPolicyName = {\n DEFAULT: 'system.default',\n IDENTITY: 'system.identity',\n PERMISSION_BINDING: 'system.permission-binding',\n REALM_MATCH: 'system.realm-match',\n REALM_BOUND: 'system.realm-bound',\n REALM_OR_GLOBAL: 'system.realm-or-global',\n CLIENT_NAMES_SELF_MANAGE: 'system.client-names-self-manage',\n ROBOT_NAMES_SELF_MANAGE: 'system.robot-names-self-manage',\n USER_NAMES_SELF_MANAGE: 'system.user-names-self-manage',\n} as const;\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { AttributesPolicy } from './types';\n\nexport class AttributesPolicyValidator<\n T extends Record<string, any> = Record<string, any>,\n> extends Container<AttributesPolicy<T>> {\n override initialize() {\n super.initialize();\n\n this.mount(\n 'query',\n createValidator(\n z.looseObject({}),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { guard } from '@ucast/mongo2js';\nimport { isObject } from '@authup/kit';\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { PolicyIssueCode, definePolicyIssueItem } from '../../issue';\nimport { BuiltInPolicyType } from '../constants.ts';\nimport { AttributesPolicyValidator } from './validator';\n\nexport class AttributesPolicyEvaluator<\n T extends Record<string, any> = Record<string, any>,\n> implements IPolicyEvaluator {\n protected validator : AttributesPolicyValidator<T>;\n\n constructor() {\n this.validator = new AttributesPolicyValidator<T>();\n }\n\n async accessData(ctx: PolicyEvaluationContext) : Promise<T | null> {\n if (!ctx.data.has(BuiltInPolicyType.ATTRIBUTES)) {\n return null;\n }\n\n if (ctx.data.isValidated(BuiltInPolicyType.ATTRIBUTES)) {\n return ctx.data.get<T>(BuiltInPolicyType.ATTRIBUTES);\n }\n\n // todo: run validator on attributes (isObject ...)\n const data = ctx.data.get<T>(BuiltInPolicyType.ATTRIBUTES);\n\n ctx.data.set(BuiltInPolicyType.ATTRIBUTES, data);\n ctx.data.setValidated(BuiltInPolicyType.ATTRIBUTES);\n\n return data;\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n const data = await this.accessData(ctx);\n if (!data) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property attributes is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n this.fixQuery(policy.query);\n\n const testIt = guard<T>(policy.query);\n\n return { success: maybeInvertPolicyOutcome(testIt(data as T), policy.invert) };\n }\n\n protected fixQuery(\n query: unknown | unknown[],\n ) {\n if (Array.isArray(query)) {\n for (const element of query) {\n this.fixQuery(element);\n }\n\n return;\n }\n\n if (isObject(query)) {\n const keys = Object.keys(query);\n for (const key of keys) {\n const value = query[key];\n\n if (isObject(value) || Array.isArray(value)) {\n this.fixQuery(value);\n continue;\n }\n\n if (\n key === '$regex' &&\n typeof value === 'string'\n ) {\n const fragments = value.match(/\\/(.*?)\\/([a-z]*)?$/i);\n if (fragments && fragments[1] !== undefined) {\n query[key] = new RegExp(fragments[1], fragments[2] || '');\n }\n }\n }\n }\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { flattenObject } from '@authup/kit';\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport type { PolicyIssue } from '../../issue';\nimport { PolicyIssueCode, definePolicyIssueItem } from '../../issue';\nimport { AttributeNamesPolicyValidator } from './validator';\nimport { AttributesPolicyEvaluator } from '../attributes';\n\nexport class AttributeNamesPolicyEvaluator implements IPolicyEvaluator {\n protected validator : AttributeNamesPolicyValidator;\n\n protected attributesEvaluator : AttributesPolicyEvaluator;\n\n constructor() {\n this.validator = new AttributeNamesPolicyValidator();\n this.attributesEvaluator = new AttributesPolicyEvaluator();\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n const data = await this.attributesEvaluator.accessData(ctx);\n if (!data) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property attributes is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n // Nested paths are a deliberate feature: an attribute object like\n // `{user: {name: 'x'}}` flattens to `{'user.name': 'x'}` and is matched\n // against `names` entries with dotted notation. Allowlists/denylists\n // that need to govern nested fields must use the dotted-path form\n // (e.g. `'user.realm_id'`); a top-level entry like `'realm_id'` will\n // NOT catch a nested `user.realm_id` write — that's by design, the\n // policy is precise about which path it covers.\n const attributes = flattenObject(data);\n const keys = Object.keys(attributes);\n\n // `invert` is consumed per-key, NOT at the result level:\n // - allowlist (default): a key NOT in `names` is denied\n // - denylist (invert: true): a key IN `names` is denied\n // Result-level inversion would break the empty-input case (a request\n // with no validated attributes would flip success → fail), and would\n // produce nonsensical \"deny iff all keys are in the list\" semantics\n // for partial inputs.\n const issues : PolicyIssue[] = [];\n for (const key of keys) {\n const inList = policy.names.includes(key);\n const denied = policy.invert ? inList : !inList;\n if (denied) {\n issues.push(definePolicyIssueItem({\n code: PolicyIssueCode.EVALUATION_DENIED,\n message: policy.invert ?\n `The attribute ${key} is denied` :\n `The attribute ${key} is not included`,\n path: [...ctx.path, key],\n }));\n }\n }\n\n return {\n success: issues.length === 0,\n issues,\n };\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport { DecisionStrategy } from '../../../constants';\nimport type { CompositePolicy } from './types';\n\nexport class CompositePolicyValidator extends Container<CompositePolicy> {\n override initialize() {\n super.initialize();\n\n this.mount(\n 'decision_strategy',\n createValidator(\n z.enum(DecisionStrategy)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'children',\n createValidator(\n z.array(z.looseObject({ type: z.string().min(3) })),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { defineIssueGroup } from 'validup';\nimport { DecisionStrategy } from '../../../constants';\nimport { PolicyEngine } from '../../engine';\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport type { PolicyIssue } from '../../issue';\nimport { CompositePolicyValidator } from './validator';\n\nexport class CompositePolicyEvaluator implements IPolicyEvaluator {\n protected validator : CompositePolicyValidator;\n\n constructor() {\n this.validator = new CompositePolicyValidator();\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n let count = 0;\n\n const decision_strategy = policy.decision_strategy ??\n DecisionStrategy.UNANIMOUS;\n\n const engine = new PolicyEngine(ctx.evaluators);\n const issues : PolicyIssue[] = [];\n\n for (const childPolicy of policy.children) {\n const path = [\n ...(ctx.path || []),\n ...(childPolicy.type ? [childPolicy.type] : []),\n ];\n\n const outcome = await engine.evaluate(childPolicy, {\n ...ctx,\n path,\n });\n\n if (outcome.success) {\n if (decision_strategy === DecisionStrategy.AFFIRMATIVE) {\n return {\n success: maybeInvertPolicyOutcome(true, policy.invert),\n issues: [],\n };\n }\n\n count++;\n } else {\n if (outcome.issues) {\n issues.push(defineIssueGroup({\n message: `The evaluation of child policy ${childPolicy.type} failed`,\n issues: outcome.issues || [],\n path,\n }));\n }\n\n if (decision_strategy === DecisionStrategy.UNANIMOUS) {\n const success = maybeInvertPolicyOutcome(false, policy.invert);\n return {\n success,\n // When `invert` flips a child-failure into success,\n // suppress the issue list — surfacing failure issues\n // alongside `success: true` is misleading.\n issues: success ? [] : [\n defineIssueGroup({\n message: `The evaluation of composite policy failed (${DecisionStrategy.UNANIMOUS})`,\n issues,\n path: ctx.path,\n }),\n ],\n };\n }\n\n count--;\n }\n }\n\n if (count > 0) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n const success = maybeInvertPolicyOutcome(false, policy.invert);\n return {\n success,\n issues: success ? [] : [\n defineIssueGroup({\n message: `The evaluation of composite policy failed (${DecisionStrategy.CONSENSUS})`,\n issues: issues || [],\n path: ctx.path,\n }),\n ],\n };\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { PolicyWithType } from '../../types';\nimport { BuiltInPolicyType } from '../constants';\nimport type { CompositePolicy } from './types';\n\nexport function isCompositePolicy(\n input: PolicyWithType,\n) : input is PolicyWithType<CompositePolicy> {\n return input.type === BuiltInPolicyType.COMPOSITE;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { DatePolicy } from './types';\n\nexport class DatePolicyValidator extends Container<DatePolicy> {\n override initialize() {\n super.initialize();\n\n this.mount('start', createValidator(\n z.date()\n .or(z.iso.date())\n .or(z.number())\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n this.mount('end', createValidator(\n z.date()\n .or(z.iso.date())\n .or(z.number())\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n\n this.mount('invert', createValidator(\n z.boolean()\n .or(z.undefined())\n .or(z.null())\n .optional(),\n ));\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { BuiltInPolicyType } from '../constants.ts';\nimport { DatePolicyValidator } from './validator';\n\nfunction normalizeDate(input: Date) {\n return new Date(input.getFullYear(), input.getMonth(), input.getDate());\n}\n\nfunction toDate(input: Date | string | number) : Date {\n if (typeof input === 'string') {\n return new Date(input);\n }\n\n if (typeof input === 'number') {\n return new Date(input);\n }\n\n return input;\n}\n\nexport class DatePolicyEvaluator implements IPolicyEvaluator {\n protected validator : DatePolicyValidator;\n\n constructor() {\n this.validator = new DatePolicyValidator();\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n let now : Date;\n\n if (ctx.data.has(BuiltInPolicyType.DATE)) {\n if (ctx.data.isValidated(BuiltInPolicyType.DATE)) {\n now = ctx.data.get<Date>(BuiltInPolicyType.DATE);\n } else {\n // todo: run validator on attributes (isObject ...)\n now = normalizeDate(toDate(ctx.data.get(BuiltInPolicyType.DATE)));\n\n ctx.data.set(BuiltInPolicyType.DATE, now);\n ctx.data.setValidated(BuiltInPolicyType.DATE);\n }\n } else {\n now = normalizeDate(new Date());\n }\n\n if (policy.start) {\n const start = normalizeDate(toDate(policy.start));\n if (now < start) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n if (policy.end) {\n const end = normalizeDate(toDate(policy.end));\n if (now > end) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\n\nimport type { IdentityPolicyData } from '../types.ts';\n\nexport class PolicyIdentityDataValidator extends Container<IdentityPolicyData> {\n override initialize() {\n super.initialize();\n\n this.mount(\n 'type',\n createValidator(\n z.string().min(3).max(128),\n ),\n );\n\n this.mount(\n 'id',\n createValidator(\n z.uuid(),\n ),\n );\n\n this.mount(\n 'clientId',\n createValidator(\n z.uuid()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'realmId',\n createValidator(\n z.uuid()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'realmName',\n createValidator(\n z.string().min(3).max(128)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { IdentityPolicy } from './types';\n\nexport class IdentityPolicyValidator extends Container<IdentityPolicy> {\n override initialize() {\n this.mount(\n 'types',\n createValidator(\n z.array(z.string())\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { PolicyIssueCode, definePolicyIssueItem } from '../../issue';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { PolicyIdentityDataValidator } from './data';\nimport type { IdentityPolicyData } from './types';\nimport { IdentityPolicyValidator } from './validator';\n\nexport class IdentityPolicyEvaluator implements IPolicyEvaluator {\n protected validator : IdentityPolicyValidator;\n\n protected dataValidator : PolicyIdentityDataValidator;\n\n constructor() {\n this.validator = new IdentityPolicyValidator();\n this.dataValidator = new PolicyIdentityDataValidator();\n }\n\n async accessData(ctx: PolicyEvaluationContext) : Promise<IdentityPolicyData | null> {\n if (!ctx.data.has('identity')) {\n return null;\n }\n\n if (ctx.data.isValidated('identity')) {\n return ctx.data.get<IdentityPolicyData>('identity');\n }\n\n const data = await this.dataValidator.run(ctx.data.get('identity'));\n\n ctx.data.set('identity', data);\n ctx.data.setValidated('identity');\n\n return data;\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n const data = await this.accessData(ctx);\n if (!data) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property identity is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n if (!policy.types || policy.types.length === 0) {\n // Empty types is a configuration shorthand for \"no type\n // restriction\" — every identity passes. Do NOT apply `invert`;\n // inverting an empty config would silently deny all identities,\n // which is almost never the user's intent.\n return { success: true };\n }\n\n const typeAllowed = policy.types.includes(data.type);\n if (typeAllowed) {\n return { success: maybeInvertPolicyOutcome(typeAllowed, policy.invert) };\n }\n\n return {\n success: maybeInvertPolicyOutcome(typeAllowed, policy.invert),\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.EVALUATION_DENIED,\n message: `The type ${data.type} is not covered by the policy configuration`,\n path: ctx.path,\n }),\n ],\n };\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Container } from 'validup';\nimport type { PermissionBindingPolicy } from './types';\n\nexport class PermissionBindingPolicyValidator extends Container<PermissionBindingPolicy> {\n override initialize() {\n\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IPolicyEvaluator, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { PermissionBindingPolicyValidator } from './validator';\n\nexport class PermissionBindingPolicyEvaluator implements IPolicyEvaluator {\n protected validator: PermissionBindingPolicyValidator;\n\n constructor() {\n this.validator = new PermissionBindingPolicyValidator();\n }\n\n async evaluate(value: Record<string, any>): Promise<PolicyEvaluationResult> {\n const policy = await this.validator.run(value);\n\n // todo: this must be changed when the permission-checker not only checks owned permissions.\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport { DecisionStrategy } from '../../../constants';\nimport type { RealmMatchPolicy } from './types';\n\nexport class RealmMatchPolicyValidator extends Container<RealmMatchPolicy> {\n override initialize() {\n super.initialize();\n\n this.mount(\n 'decision_strategy',\n createValidator(\n z.enum(DecisionStrategy)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'attribute_name',\n createValidator(\n z.string()\n .min(3)\n .or(z.array(z.string().min(3)))\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n this.mount(\n 'attribute_name_strict',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n this.mount(\n 'attribute_null_match_all',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'identity_master_match_all',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty } from '@authup/kit';\nimport { DecisionStrategy } from '../../../constants';\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { PolicyIssueCode, definePolicyIssueItem } from '../../issue';\nimport { AttributesPolicyEvaluator } from '../attributes';\nimport { IdentityPolicyEvaluator } from '../identity';\nimport { RealmMatchPolicyValidator } from './validator';\n\nexport class RealmMatchPolicyEvaluator implements IPolicyEvaluator {\n protected validator : RealmMatchPolicyValidator;\n\n protected identityEvaluator: IdentityPolicyEvaluator;\n\n protected attributesEvaluator : AttributesPolicyEvaluator;\n\n constructor() {\n this.validator = new RealmMatchPolicyValidator();\n this.identityEvaluator = new IdentityPolicyEvaluator();\n this.attributesEvaluator = new AttributesPolicyEvaluator();\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n const identity = await this.identityEvaluator.accessData(ctx);\n if (!identity) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property identity is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n const attributes = await this.attributesEvaluator.accessData(ctx);\n if (!attributes) {\n return {\n success: false,\n issues: [\n definePolicyIssueItem({\n code: PolicyIssueCode.DATA_MISSING,\n message: 'The data property attributes is missing',\n path: ctx.path,\n }),\n ],\n };\n }\n\n const identityMasterMatchAll = policy.identity_master_match_all ?? true;\n if (\n identityMasterMatchAll &&\n identity.realmName &&\n identity.realmName === 'master'\n ) {\n // Master-match-all is a privileged-actor override — do NOT apply\n // `invert`. Inverting would deny master access whenever the policy\n // is configured as a denylist, which is the opposite of the flag's\n // intent.\n return { success: true };\n }\n\n let keys : string[];\n if (policy.attribute_name) {\n if (Array.isArray(policy.attribute_name)) {\n keys = policy.attribute_name;\n } else {\n keys = [policy.attribute_name];\n }\n } else {\n keys = [\n 'realm_id',\n 'realm_name',\n 'realmId',\n 'realmName',\n ];\n\n policy.decision_strategy = DecisionStrategy.CONSENSUS;\n }\n\n const attribute_name_strict = policy.attribute_name_strict ?? true;\n if (!attribute_name_strict) {\n const resourceKeys = Object.keys(attributes);\n const keysToAdd : string[] = [];\n for (const resourceKey of resourceKeys) {\n let contains : boolean = false;\n\n for (const key of keys) {\n if (\n resourceKey !== key &&\n resourceKey.includes(key)\n ) {\n contains = true;\n break;\n }\n }\n\n if (contains) {\n keysToAdd.push(resourceKey);\n }\n }\n\n if (keysToAdd.length > 0) {\n keys.push(...keysToAdd);\n }\n }\n\n let count = 0;\n let evaluated = false;\n\n for (const key of keys) {\n if (!hasOwnProperty(attributes, key)) {\n continue;\n }\n\n evaluated = true;\n\n let outcome : boolean = false;\n\n const attributeValue = attributes[key];\n\n if (\n attributeValue === null &&\n policy.attribute_null_match_all\n ) {\n outcome = true;\n } else if (\n attributeValue === identity.realmId ||\n attributeValue === identity.realmName\n ) {\n outcome = true;\n }\n\n if (outcome) {\n if (policy.decision_strategy === DecisionStrategy.AFFIRMATIVE) {\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n\n count++;\n } else {\n if (policy.decision_strategy === DecisionStrategy.UNANIMOUS) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n\n count--;\n }\n }\n\n if (!evaluated) {\n // No realm key found in attributes — the policy's match logic\n // didn't run. This is a \"non-evaluation\", not an outcome; treat\n // as a neutral pass without applying `invert`. Inverting here\n // would conflate \"policy doesn't apply\" with \"policy denies\".\n return { success: true };\n }\n\n return { success: maybeInvertPolicyOutcome(count > 0, policy.invert) };\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum TimePolicyInterval {\n DAILY = 'daily',\n WEEKLY = 'weekly',\n MONTHLY = 'monthly',\n YEARLY = 'yearly',\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { TimePolicyInterval } from './constants';\n\nexport function isIntervalForDayOfWeek(\n interval: string,\n) {\n return interval === TimePolicyInterval.WEEKLY ||\n interval === TimePolicyInterval.MONTHLY ||\n interval === TimePolicyInterval.YEARLY;\n}\n\nexport function isIntervalForDayOfMonth(\n interval: string,\n) {\n return interval === TimePolicyInterval.MONTHLY ||\n interval === TimePolicyInterval.YEARLY;\n}\n\nexport function isIntervalForDayOfYear(\n interval: string,\n) {\n return interval === TimePolicyInterval.YEARLY;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createValidator } from '@validup/adapter-zod';\nimport { Container } from 'validup';\nimport { z } from 'zod';\nimport type { TimePolicy } from './types';\nimport { TimePolicyInterval } from './constants';\n\nexport class TimePolicyValidator extends Container<TimePolicy> {\n override initialize() {\n super.initialize();\n\n this.mount('day_of_week', createValidator(\n z.number()\n .min(0).max(6)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n this.mount('day_of_month', createValidator(\n z.number()\n .min(1)\n .max(31)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n this.mount('day_of_year', createValidator(\n z.number()\n .min(1)\n .max(365)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n\n this.mount('start', createValidator(\n z.date()\n .or(z.iso.datetime())\n .or(z.iso.time())\n .or(z.number())\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n this.mount('end', createValidator(\n z.date()\n .or(z.iso.datetime())\n .or(z.iso.time())\n .or(z.number())\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ));\n\n this.mount(\n 'interval',\n createValidator(\n z.enum(TimePolicyInterval)\n .or(z.null())\n .or(z.undefined())\n .optional(),\n ),\n );\n\n this.mount(\n 'invert',\n createValidator(\n z.boolean()\n .or(z.undefined())\n .or(z.null())\n .optional(),\n ),\n );\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IPolicyEvaluator, PolicyEvaluationContext, PolicyEvaluationResult } from '../../evaluation';\nimport { maybeInvertPolicyOutcome } from '../../helpers';\nimport { BuiltInPolicyType } from '../constants';\nimport { isIntervalForDayOfMonth, isIntervalForDayOfWeek, isIntervalForDayOfYear } from './helpers';\nimport { TimePolicyValidator } from './validator';\n\nconst timeRegex = /^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$/;\n\nfunction normalizeDate(input: Date, dateRef?: Date) {\n const date = dateRef ? new Date(dateRef) : new Date();\n date.setHours(input.getHours(), input.getMinutes());\n\n return date;\n}\n\nfunction toDate(\n input: Date | string | number,\n dateRef?: Date,\n) : Date {\n if (typeof input === 'string') {\n if (timeRegex.test(input)) {\n const parts = input.split(':');\n\n const startHours = Number(parts[0]);\n const startMinutes = Number(parts[1]);\n const startSeconds = parts[2] !== undefined ? Number(parts[2]) : 0;\n\n if (\n Number.isFinite(startHours) &&\n Number.isFinite(startMinutes) &&\n Number.isFinite(startSeconds)\n ) {\n const date = dateRef ? new Date(dateRef) : new Date();\n date.setHours(startHours, startMinutes, startSeconds, 0);\n\n return date;\n }\n }\n\n return new Date(input);\n }\n\n if (typeof input === 'number') {\n return new Date(input);\n }\n\n return input;\n}\n\nexport class TimePolicyEvaluator implements IPolicyEvaluator {\n protected validator : TimePolicyValidator;\n\n constructor() {\n this.validator = new TimePolicyValidator();\n }\n\n async evaluate(value: Record<string, any>, ctx: PolicyEvaluationContext): Promise<PolicyEvaluationResult> {\n // todo: catch errors + transform to issue(s)\n const policy = await this.validator.run(value);\n\n let now : Date;\n\n if (ctx.data.has(BuiltInPolicyType.TIME)) {\n if (ctx.data.isValidated(BuiltInPolicyType.TIME)) {\n now = ctx.data.get<Date>(BuiltInPolicyType.TIME);\n } else {\n // todo: run validator on attributes (isObject ...)\n now = toDate(ctx.data.get(BuiltInPolicyType.TIME));\n\n ctx.data.set(BuiltInPolicyType.TIME, now);\n ctx.data.setValidated(BuiltInPolicyType.TIME);\n }\n } else {\n now = new Date();\n }\n\n if (policy.start) {\n const start = normalizeDate(toDate(policy.start, now), now);\n if (now < start) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n if (policy.end) {\n const end = normalizeDate(toDate(policy.end, now), now);\n if (now > end) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n if (policy.interval) {\n if (\n isIntervalForDayOfWeek(policy.interval) &&\n policy.day_of_week\n ) {\n if (now.getDay() !== policy.day_of_week) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n if (\n isIntervalForDayOfMonth(policy.interval) &&\n policy.day_of_month\n ) {\n if (now.getDate() !== policy.day_of_month) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n\n if (\n isIntervalForDayOfYear(policy.interval) &&\n policy.day_of_year\n ) {\n const start = new Date(now.getFullYear(), 0, 0);\n const diff = (now.getTime() - start.getTime()) +\n ((start.getTimezoneOffset() - now.getTimezoneOffset()) * 60 * 1000);\n\n const oneDay = 1000 * 60 * 60 * 24;\n const dayOfYear = Math.floor(diff / oneDay);\n\n if (dayOfYear !== policy.day_of_year) {\n return { success: maybeInvertPolicyOutcome(false, policy.invert) };\n }\n }\n }\n\n return { success: maybeInvertPolicyOutcome(true, policy.invert) };\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { PolicyWithType } from '../types';\nimport type { BuiltInPolicyTypeMap } from './types';\n\nexport function definePolicyWithType<\n K extends keyof BuiltInPolicyTypeMap,\n D extends BuiltInPolicyTypeMap<any>[K],\n>(\n type: K,\n data: D,\n) : PolicyWithType<D, K> {\n return {\n ...data,\n type,\n };\n}\n","/*\n * Copyright (c) 2026-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport {\n AttributeNamesPolicyEvaluator,\n AttributesPolicyEvaluator,\n BuiltInPolicyType,\n CompositePolicyEvaluator,\n DatePolicyEvaluator,\n IdentityPolicyEvaluator,\n PermissionBindingPolicyEvaluator,\n RealmMatchPolicyEvaluator,\n TimePolicyEvaluator,\n} from './built-in';\n\nexport const PolicyDefaultEvaluators = {\n [BuiltInPolicyType.COMPOSITE]: new CompositePolicyEvaluator(),\n [BuiltInPolicyType.ATTRIBUTES]: new AttributesPolicyEvaluator(),\n [BuiltInPolicyType.ATTRIBUTE_NAMES]: new AttributeNamesPolicyEvaluator(),\n [BuiltInPolicyType.DATE]: new DatePolicyEvaluator(),\n [BuiltInPolicyType.IDENTITY]: new IdentityPolicyEvaluator(),\n [BuiltInPolicyType.PERMISSION_BINDING]: new PermissionBindingPolicyEvaluator(),\n [BuiltInPolicyType.REALM_MATCH]: new RealmMatchPolicyEvaluator(),\n [BuiltInPolicyType.TIME]: new TimePolicyEvaluator(),\n} as const;\n","/*\n * Copyright (c) 2021-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '@authup/errors';\nimport type { Issue } from 'validup';\nimport { defineIssueItem } from 'validup';\nimport { DecisionStrategy } from '../../constants.ts';\nimport type { CompositePolicy, IPolicyEngine } from '../../policy';\nimport {\n BuiltInPolicyType,\n PolicyData,\n PolicyDefaultEvaluators,\n PolicyEngine,\n definePolicyEvaluationContext,\n definePolicyIssueGroup,\n} from '../../policy';\nimport { PermissionError } from '../error';\nimport type { IPermissionProvider } from '../provider';\n\nimport type { PermissionPolicyBinding } from '../types.ts';\nimport type { IPermissionEvaluator, PermissionEvaluationContext, PermissionEvaluatorOptions } from './types.ts';\n\nexport class PermissionEvaluator implements IPermissionEvaluator {\n protected provider : IPermissionProvider;\n\n protected policyEngine : IPolicyEngine;\n\n protected clientId?: string | null;\n\n protected realmId?: string | null;\n\n // ----------------------------------------------\n\n constructor(options: PermissionEvaluatorOptions) {\n this.provider = options.provider;\n\n this.clientId = options.clientId || null;\n this.realmId = options.realmId || null;\n\n if (options.policyEngine) {\n this.policyEngine = options.policyEngine;\n } else {\n this.policyEngine = new PolicyEngine(PolicyDefaultEvaluators);\n }\n }\n\n // ----------------------------------------------\n\n protected async findOne(\n input: string,\n overrides: {\n realmId?: string | null,\n clientId?: string | null\n } = {},\n ) : Promise<PermissionPolicyBinding | null> {\n return this.provider.findOne({\n name: input,\n clientId: overrides.clientId ?? this.clientId,\n realmId: overrides.realmId ?? this.realmId,\n });\n }\n\n // ----------------------------------------------\n\n async evaluate(ctx: PermissionEvaluationContext) : Promise<void> {\n if (!Array.isArray(ctx.name)) {\n await this.evaluate({\n ...ctx,\n name: [ctx.name],\n });\n return;\n }\n\n const { options = {} } = ctx;\n\n const decisionStrategy = options.decisionStrategy ??\n DecisionStrategy.UNANIMOUS;\n\n const issues : Issue[] = [];\n\n let count = 0;\n\n const dataBase = ctx.input || new PolicyData();\n\n for (const name of ctx.name) {\n const binding = await this.findOne(name, {\n realmId: ctx.realmId,\n clientId: ctx.clientId,\n });\n if (!binding) {\n issues.push(defineIssueItem({\n code: ErrorCode.PERMISSION_NOT_FOUND,\n message: `The ${name} permission could not be resolved`,\n path: [name],\n }));\n\n if (decisionStrategy === DecisionStrategy.UNANIMOUS) {\n const error = PermissionError.evaluationFailed(ctx.name);\n error.addIssues(issues);\n throw error;\n }\n\n continue;\n }\n\n const policies = binding.policies ?? [];\n if (policies.length === 0) {\n if (decisionStrategy === DecisionStrategy.AFFIRMATIVE) {\n return;\n }\n\n count++;\n\n continue;\n }\n\n const data = dataBase.clone();\n data.set(BuiltInPolicyType.PERMISSION_BINDING, binding);\n\n const policyDecisionStrategy = binding.permission.decision_strategy ??\n DecisionStrategy.UNANIMOUS;\n\n const compositePolicy : CompositePolicy = {\n type: BuiltInPolicyType.COMPOSITE,\n decision_strategy: policyDecisionStrategy,\n children: policies,\n };\n\n const evaluationResult = await this.policyEngine.evaluate(\n compositePolicy,\n definePolicyEvaluationContext({\n include: options.policiesIncluded,\n exclude: options.policiesExcluded,\n data,\n }),\n );\n\n if (evaluationResult.success) {\n if (decisionStrategy === DecisionStrategy.AFFIRMATIVE) {\n return;\n }\n\n count++;\n } else {\n issues.push(definePolicyIssueGroup({\n code: ErrorCode.PERMISSION_EVALUATION_FAILED,\n issues: evaluationResult.issues || [],\n message: `The ${binding.permission.name} permissions policy evaluation failed`,\n path: [binding.permission.name],\n }));\n\n if (decisionStrategy === DecisionStrategy.UNANIMOUS) {\n const error = PermissionError.evaluationFailed(binding.permission.name);\n error.addIssues(issues);\n throw error;\n }\n\n count--;\n }\n }\n\n if (count > 0) {\n return;\n }\n\n if (issues.length === 0) {\n throw PermissionError.deniedAll(ctx.name);\n } else {\n const error = PermissionError.evaluationFailed(ctx.name);\n error.addIssues(issues);\n throw error;\n }\n }\n\n async evaluateOneOf(ctx: PermissionEvaluationContext) : Promise<void> {\n return this.evaluate({\n ...ctx,\n options: {\n ...(ctx.options || {}),\n decisionStrategy: DecisionStrategy.AFFIRMATIVE,\n },\n });\n }\n\n // ----------------------------------------------\n\n async preEvaluate(ctx: PermissionEvaluationContext) : Promise<void> {\n return this.evaluate({\n ...ctx,\n options: {\n ...(ctx.options || {}),\n policiesExcluded: [\n BuiltInPolicyType.ATTRIBUTES,\n BuiltInPolicyType.ATTRIBUTE_NAMES,\n BuiltInPolicyType.REALM_MATCH,\n ],\n },\n });\n }\n\n async preEvaluateOneOf(ctx: PermissionEvaluationContext) : Promise<void> {\n return this.preEvaluate({\n ...ctx,\n options: {\n ...(ctx.options || {}),\n decisionStrategy: DecisionStrategy.AFFIRMATIVE,\n },\n });\n }\n}\n"],"mappings":";;;;;;;AAWA,IAAa,kBAAb,MAAa,wBAAwB,YAAY;CAC7C,YAAY,UAA8B,EAAE,EAAE;AAC1C,QAAM;GACF,GAAG;GACH,SAAS,QAAQ,WAAW;GAC5B,YAAY,QAAQ,cAAc;GACrC,CAAC;;CAGN,SAAS,MAAmB;AACxB,OAAK,OAAO,KAAK,KAAK;;CAG1B,UAAU,MAAqB;AAC3B,OAAK,OAAO,KAAK,GAAG,KAAK;;CAG7B,OAAO,SAAS,MAAc;AAC1B,SAAO,IAAI,gBAAgB;GACvB,SAAS,kBAAkB,KAAK;GAChC,MAAM,UAAU;GACnB,CAAC;;CAGN,OAAO,OAAO,MAAc;AACxB,SAAO,IAAI,gBAAgB;GACvB,SAAS,kBAAkB,KAAK;GAChC,MAAM,UAAU;GACnB,CAAC;;CAGN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,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAsC5G"}
1
+ {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/attribute-names/evaluator.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1G,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,qBAAa,6BAA8B,YAAW,gBAAgB;IAClE,SAAS,CAAC,SAAS,EAAG,6BAA6B,CAAC;IAEpD,SAAS,CAAC,mBAAmB,EAAG,yBAAyB,CAAC;;IAOpD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAuD5G"}
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/composite/evaluator.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,qBAAa,wBAAyB,YAAW,gBAAgB;IAC7D,SAAS,CAAC,SAAS,EAAG,wBAAwB,CAAC;;IAMzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAyE5G"}
1
+ {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/composite/evaluator.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,qBAAa,wBAAyB,YAAW,gBAAgB;IAC7D,SAAS,CAAC,SAAS,EAAG,wBAAwB,CAAC;;IAMzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CA8E5G"}
@@ -39,5 +39,8 @@ export declare const SystemPolicyName: {
39
39
  readonly REALM_MATCH: "system.realm-match";
40
40
  readonly REALM_BOUND: "system.realm-bound";
41
41
  readonly REALM_OR_GLOBAL: "system.realm-or-global";
42
+ readonly CLIENT_NAMES_SELF_MANAGE: "system.client-names-self-manage";
43
+ readonly ROBOT_NAMES_SELF_MANAGE: "system.robot-names-self-manage";
44
+ readonly USER_NAMES_SELF_MANAGE: "system.user-names-self-manage";
42
45
  };
43
46
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/policy/built-in/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,iBAAiB;IACzB;;OAEG;IACH,SAAS,cAAc;IACvB;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,eAAe,mBAAmB;IAClC;;OAEG;IACH,UAAU,eAAe;IACzB;;OAEG;IACH,WAAW,eAAe;IAE1B;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,kBAAkB,sBAAsB;CAI3C;AAED,eAAO,MAAM,gBAAgB;;;;;;;CAOnB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/policy/built-in/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,iBAAiB;IACzB;;OAEG;IACH,SAAS,cAAc;IACvB;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,eAAe,mBAAmB;IAClC;;OAEG;IACH,UAAU,eAAe;IACzB;;OAEG;IACH,WAAW,eAAe;IAE1B;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,kBAAkB,sBAAsB;CAI3C;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;CAUnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/identity/evaluator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1G,OAAO,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,qBAAa,uBAAwB,YAAW,gBAAgB;IAC5D,SAAS,CAAC,SAAS,EAAG,uBAAuB,CAAC;IAE9C,SAAS,CAAC,aAAa,EAAG,2BAA2B,CAAC;;IAOhD,UAAU,CAAC,GAAG,EAAE,uBAAuB,GAAI,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAiB7E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAsC5G"}
1
+ {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/identity/evaluator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1G,OAAO,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,qBAAa,uBAAwB,YAAW,gBAAgB;IAC5D,SAAS,CAAC,SAAS,EAAG,uBAAuB,CAAC;IAE9C,SAAS,CAAC,aAAa,EAAG,2BAA2B,CAAC;;IAOhD,UAAU,CAAC,GAAG,EAAE,uBAAuB,GAAI,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAiB7E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CA0C5G"}
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/realm-match/evaluator.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1G,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD,qBAAa,yBAA0B,YAAW,gBAAgB;IAC9D,SAAS,CAAC,SAAS,EAAG,yBAAyB,CAAC;IAEhD,SAAS,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;IAErD,SAAS,CAAC,mBAAmB,EAAG,yBAAyB,CAAC;;IAQpD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAqI5G"}
1
+ {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../../src/policy/built-in/realm-match/evaluator.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1G,OAAO,EAAE,yBAAyB,EAAE,MAAM,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.ts","sourceRoot":"","sources":["../../../src/policy/engine/module.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACR,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAiB9C;;;GAGG;AACH,qBAAa,YAAa,YAAW,aAAa;IAC9C,SAAS,CAAC,UAAU,EAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;gBAE5C,UAAU,GAAE,gBAAqB;IAItC,iBAAiB,CACpB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,gBAAgB,GAC3B,IAAI;IAID,kBAAkB,CAAC,UAAU,EAAE,gBAAgB;IAOtD;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,uBAAuB,GAAI,OAAO,CAAC,sBAAsB,CAAC;IA2E5F,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,uBAAuB,GAAI,OAAO,CAAC,IAAI,CAAC;CAgCzF"}
@@ -1,6 +1,8 @@
1
1
  import { AuthupError } from '@authup/errors';
2
2
  import type { PolicyIssue } from '../issue';
3
+ export declare function isPolicyError(value: unknown): value is PolicyError;
3
4
  export declare class PolicyError extends AuthupError {
5
+ readonly '@instanceof': symbol;
4
6
  constructor(message?: string, code?: string | null);
5
7
  addIssue(data: PolicyIssue): void;
6
8
  addIssues(data: PolicyIssue[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/policy/error/module.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAa,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,qBAAa,WAAY,SAAQ,WAAW;gBAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAOlD,QAAQ,CAAC,IAAI,EAAE,WAAW;IAI1B,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE;IAI7B,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM;IAOrC,MAAM,CAAC,uBAAuB;IAO9B,MAAM,CAAC,uBAAuB;CAMjC"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/policy/error/module.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAa,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAO5C,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAIlE;AAED,qBAAa,WAAY,SAAQ,WAAW;IACxC,QAAQ,CAAC,aAAa,SAAyB;gBAEnC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAOlD,QAAQ,CAAC,IAAI,EAAE,WAAW;IAI1B,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE;IAI7B,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM;IAOrC,MAAM,CAAC,uBAAuB;IAO9B,MAAM,CAAC,uBAAuB;CAMjC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@authup/access",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.36",
4
+ "version": "1.0.0-beta.38",
5
5
  "description": "A library for evaluating permissions and policies.",
6
6
  "license": "Apache-2.0",
7
7
  "exports": {
@@ -60,14 +60,14 @@
60
60
  "zod": "^4.3.6"
61
61
  },
62
62
  "devDependencies": {
63
- "@authup/errors": "^1.0.0-beta.36",
64
- "@authup/kit": "^1.0.0-beta.36",
63
+ "@authup/errors": "^1.0.0-beta.38",
64
+ "@authup/kit": "^1.0.0-beta.38",
65
65
  "unplugin-swc": "^1.5.9",
66
66
  "vitest": "^4.0.14"
67
67
  },
68
68
  "peerDependencies": {
69
- "@authup/errors": "^1.0.0-beta.36",
70
- "@authup/kit": "^1.0.0-beta.36"
69
+ "@authup/errors": "^1.0.0-beta.38",
70
+ "@authup/kit": "^1.0.0-beta.38"
71
71
  },
72
72
  "publishConfig": {
73
73
  "access": "public"