@authup/access 1.0.0-beta.25 → 1.0.0-beta.27

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.
Files changed (30) hide show
  1. package/LICENSE +1 -1
  2. package/dist/index.cjs +131 -131
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.mjs +131 -131
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/permission/types.d.ts +2 -2
  7. package/dist/permission/types.d.ts.map +1 -1
  8. package/dist/policy/built-in/attribute-names/evaluator.d.ts +4 -4
  9. package/dist/policy/built-in/attribute-names/evaluator.d.ts.map +1 -1
  10. package/dist/policy/built-in/attributes/evaluator.d.ts +3 -3
  11. package/dist/policy/built-in/attributes/evaluator.d.ts.map +1 -1
  12. package/dist/policy/built-in/composite/evaluator.d.ts +3 -3
  13. package/dist/policy/built-in/composite/evaluator.d.ts.map +1 -1
  14. package/dist/policy/built-in/date/evaluator.d.ts +3 -3
  15. package/dist/policy/built-in/date/evaluator.d.ts.map +1 -1
  16. package/dist/policy/built-in/identity/evaluator.d.ts +3 -3
  17. package/dist/policy/built-in/identity/evaluator.d.ts.map +1 -1
  18. package/dist/policy/built-in/permission-binding/module.d.ts +4 -4
  19. package/dist/policy/built-in/permission-binding/module.d.ts.map +1 -1
  20. package/dist/policy/built-in/realm-match/evaluator.d.ts +3 -3
  21. package/dist/policy/built-in/realm-match/evaluator.d.ts.map +1 -1
  22. package/dist/policy/built-in/time/evaluator.d.ts +3 -3
  23. package/dist/policy/built-in/time/evaluator.d.ts.map +1 -1
  24. package/dist/policy/evaluator/data/validator.d.ts +2 -2
  25. package/dist/policy/evaluator/data/validator.d.ts.map +1 -1
  26. package/dist/policy/evaluator/types.d.ts +11 -11
  27. package/dist/policy/evaluator/types.d.ts.map +1 -1
  28. package/dist/policy/types.d.ts +1 -1
  29. package/dist/policy/types.d.ts.map +1 -1
  30. package/package.json +8 -8
package/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2021-2025 Peter Placzek
189
+ Copyright 2021-2025 Peter Placzek <peter.placzek1996@gmail.com>
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/dist/index.cjs CHANGED
@@ -86,30 +86,30 @@ class AttributeNamesPolicyValidator extends validup.Container {
86
86
 
87
87
  class AttributeNamesPolicyEvaluator {
88
88
  async can(ctx) {
89
- return ctx.spec.type === BuiltInPolicyType.ATTRIBUTE_NAMES;
89
+ return ctx.config.type === BuiltInPolicyType.ATTRIBUTE_NAMES;
90
90
  }
91
- async validateSpecification(ctx) {
92
- return this.validator.run(ctx.spec);
91
+ async validateConfig(ctx) {
92
+ return this.validator.run(ctx.config);
93
93
  }
94
- async validateData(ctx) {
95
- if (!kit.isObject(ctx.data.attributes)) {
94
+ async validateInput(ctx) {
95
+ if (!kit.isObject(ctx.input.attributes)) {
96
96
  throw PolicyError.evaluatorContextInvalid();
97
97
  }
98
- return ctx.data;
98
+ return ctx.input;
99
99
  }
100
100
  async evaluate(ctx) {
101
- if (!ctx.data.attributes) {
101
+ if (!ctx.input.attributes) {
102
102
  throw PolicyError.evaluatorContextInvalid();
103
103
  }
104
- const attributes = kit.flattenObject(ctx.data.attributes);
104
+ const attributes = kit.flattenObject(ctx.input.attributes);
105
105
  const keys = Object.keys(attributes);
106
106
  for(let i = 0; i < keys.length; i++){
107
- const index = ctx.spec.names.indexOf(keys[i]);
107
+ const index = ctx.config.names.indexOf(keys[i]);
108
108
  if (index === -1) {
109
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
109
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
110
110
  }
111
111
  }
112
- return maybeInvertPolicyOutcome(true, ctx.spec.invert);
112
+ return maybeInvertPolicyOutcome(true, ctx.config.invert);
113
113
  }
114
114
  constructor(){
115
115
  this.validator = new AttributeNamesPolicyValidator();
@@ -135,24 +135,24 @@ class AttributesPolicyValidator extends validup.Container {
135
135
 
136
136
  class AttributesPolicyEvaluator {
137
137
  async can(ctx) {
138
- return ctx.spec.type === BuiltInPolicyType.ATTRIBUTES;
138
+ return ctx.config.type === BuiltInPolicyType.ATTRIBUTES;
139
139
  }
140
- async validateSpecification(ctx) {
141
- return this.validator.run(ctx.spec);
140
+ async validateConfig(ctx) {
141
+ return this.validator.run(ctx.config);
142
142
  }
143
- async validateData(ctx) {
144
- if (!kit.isObject(ctx.data.attributes)) {
143
+ async validateInput(ctx) {
144
+ if (!kit.isObject(ctx.input.attributes)) {
145
145
  throw PolicyError.evaluatorContextInvalid();
146
146
  }
147
- return ctx.data;
147
+ return ctx.input;
148
148
  }
149
149
  async evaluate(ctx) {
150
- if (!ctx.data.attributes) {
150
+ if (!ctx.input.attributes) {
151
151
  throw PolicyError.evaluatorContextInvalid();
152
152
  }
153
- this.fixQuery(ctx.spec.query);
154
- const testIt = mongo2js.guard(ctx.spec.query);
155
- return maybeInvertPolicyOutcome(testIt(ctx.data.attributes), ctx.spec.invert);
153
+ this.fixQuery(ctx.config.query);
154
+ const testIt = mongo2js.guard(ctx.config.query);
155
+ return maybeInvertPolicyOutcome(testIt(ctx.input.attributes), ctx.config.invert);
156
156
  }
157
157
  fixQuery(query) {
158
158
  const keys = Object.keys(query);
@@ -240,31 +240,31 @@ class PolicyDataValidator extends validup.Container {
240
240
  }
241
241
 
242
242
  async function evaluatePolicy(ctx) {
243
- if (ctx.options.exclude && ctx.options.exclude.length > 0 && ctx.options.exclude.indexOf(ctx.spec.type) !== -1) {
244
- if (typeof ctx.spec.invert === 'boolean') {
245
- return maybeInvertPolicyOutcome(true, ctx.spec.invert);
243
+ if (ctx.options.exclude && ctx.options.exclude.length > 0 && ctx.options.exclude.indexOf(ctx.config.type) !== -1) {
244
+ if (typeof ctx.config.invert === 'boolean') {
245
+ return maybeInvertPolicyOutcome(true, ctx.config.invert);
246
246
  }
247
247
  return true;
248
248
  }
249
- if (ctx.options.include && ctx.options.include.length > 0 && ctx.options.include.indexOf(ctx.spec.type) === -1) {
250
- if (typeof ctx.spec.invert === 'boolean') {
251
- return maybeInvertPolicyOutcome(true, ctx.spec.invert);
249
+ if (ctx.options.include && ctx.options.include.length > 0 && ctx.options.include.indexOf(ctx.config.type) === -1) {
250
+ if (typeof ctx.config.invert === 'boolean') {
251
+ return maybeInvertPolicyOutcome(true, ctx.config.invert);
252
252
  }
253
253
  return true;
254
254
  }
255
- const evaluator = ctx.evaluators[ctx.spec.type];
255
+ const evaluator = ctx.evaluators[ctx.config.type];
256
256
  if (!evaluator) {
257
- throw PolicyError.evaluatorNotFound(ctx.spec.type);
257
+ throw PolicyError.evaluatorNotFound(ctx.config.type);
258
258
  }
259
259
  try {
260
260
  const canEvaluate = await evaluator.can(ctx);
261
261
  if (canEvaluate) {
262
- const spec = await evaluator.validateSpecification(ctx);
263
- const data = await evaluator.validateData(ctx);
262
+ const config = await evaluator.validateConfig(ctx);
263
+ const input = await evaluator.validateInput(ctx);
264
264
  return await evaluator.evaluate({
265
265
  ...ctx,
266
- data,
267
- spec
266
+ input,
267
+ config
268
268
  });
269
269
  }
270
270
  } catch (e) {
@@ -298,44 +298,44 @@ class CompositePolicyValidator extends validup.Container {
298
298
 
299
299
  class CompositePolicyEvaluator {
300
300
  async can(ctx) {
301
- return isCompositePolicy(ctx.spec);
301
+ return isCompositePolicy(ctx.config);
302
302
  }
303
- async validateSpecification(ctx) {
304
- return this.validator.run(ctx.spec);
303
+ async validateConfig(ctx) {
304
+ return this.validator.run(ctx.config);
305
305
  }
306
- async validateData(ctx) {
307
- return ctx.data;
306
+ async validateInput(ctx) {
307
+ return ctx.input;
308
308
  }
309
309
  async evaluate(ctx) {
310
310
  let count = 0;
311
- const decisionStrategy = ctx.spec.decisionStrategy ?? DecisionStrategy.UNANIMOUS;
312
- for(let i = 0; i < ctx.spec.children.length; i++){
313
- const childPolicy = ctx.spec.children[i];
311
+ const decisionStrategy = ctx.config.decisionStrategy ?? DecisionStrategy.UNANIMOUS;
312
+ for(let i = 0; i < ctx.config.children.length; i++){
313
+ const childPolicy = ctx.config.children[i];
314
314
  let outcome;
315
315
  if (isCompositePolicy(childPolicy)) {
316
316
  outcome = await this.evaluate({
317
317
  ...ctx,
318
- spec: childPolicy
318
+ config: childPolicy
319
319
  });
320
320
  } else {
321
321
  outcome = await evaluatePolicy({
322
322
  ...ctx,
323
- spec: childPolicy
323
+ config: childPolicy
324
324
  });
325
325
  }
326
326
  if (outcome) {
327
327
  if (decisionStrategy === DecisionStrategy.AFFIRMATIVE) {
328
- return maybeInvertPolicyOutcome(true, ctx.spec.invert);
328
+ return maybeInvertPolicyOutcome(true, ctx.config.invert);
329
329
  }
330
330
  count++;
331
331
  } else {
332
332
  if (decisionStrategy === DecisionStrategy.UNANIMOUS) {
333
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
333
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
334
334
  }
335
335
  count--;
336
336
  }
337
337
  }
338
- return maybeInvertPolicyOutcome(count > 0, ctx.spec.invert);
338
+ return maybeInvertPolicyOutcome(count > 0, ctx.config.invert);
339
339
  }
340
340
  constructor(){
341
341
  this.validator = new CompositePolicyValidator();
@@ -365,34 +365,34 @@ function toDate$1(input) {
365
365
  }
366
366
  class DatePolicyEvaluator {
367
367
  async can(ctx) {
368
- return ctx.spec.type === BuiltInPolicyType.DATE;
368
+ return ctx.config.type === BuiltInPolicyType.DATE;
369
369
  }
370
- async validateSpecification(ctx) {
371
- return this.validator.run(ctx.spec);
370
+ async validateConfig(ctx) {
371
+ return this.validator.run(ctx.config);
372
372
  }
373
- async validateData(ctx) {
374
- return ctx.data;
373
+ async validateInput(ctx) {
374
+ return ctx.input;
375
375
  }
376
376
  async evaluate(ctx) {
377
377
  let now;
378
- if (ctx.data.dateTime) {
379
- now = normalizeDate$1(toDate$1(ctx.data.dateTime));
378
+ if (ctx.input.dateTime) {
379
+ now = normalizeDate$1(toDate$1(ctx.input.dateTime));
380
380
  } else {
381
381
  now = normalizeDate$1(new Date());
382
382
  }
383
- if (ctx.spec.start) {
384
- const start = normalizeDate$1(toDate$1(ctx.spec.start));
383
+ if (ctx.config.start) {
384
+ const start = normalizeDate$1(toDate$1(ctx.config.start));
385
385
  if (now < start) {
386
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
386
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
387
387
  }
388
388
  }
389
- if (ctx.spec.end) {
390
- const end = normalizeDate$1(toDate$1(ctx.spec.end));
389
+ if (ctx.config.end) {
390
+ const end = normalizeDate$1(toDate$1(ctx.config.end));
391
391
  if (now > end) {
392
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
392
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
393
393
  }
394
394
  }
395
- return maybeInvertPolicyOutcome(true, ctx.spec.invert);
395
+ return maybeInvertPolicyOutcome(true, ctx.config.invert);
396
396
  }
397
397
  constructor(){
398
398
  this.validator = new DatePolicyValidator();
@@ -408,24 +408,24 @@ class IdentityPolicyValidator extends validup.Container {
408
408
 
409
409
  class IdentityPolicyEvaluator {
410
410
  async can(ctx) {
411
- return ctx.spec.type === BuiltInPolicyType.IDENTITY;
411
+ return ctx.config.type === BuiltInPolicyType.IDENTITY;
412
412
  }
413
- async validateSpecification(ctx) {
414
- return this.validator.run(ctx.spec);
413
+ async validateConfig(ctx) {
414
+ return this.validator.run(ctx.config);
415
415
  }
416
- async validateData(ctx) {
417
- return ctx.data;
416
+ async validateInput(ctx) {
417
+ return ctx.input;
418
418
  }
419
419
  async evaluate(ctx) {
420
- if (!kit.isObject(ctx.data.identity)) {
421
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
420
+ if (!kit.isObject(ctx.input.identity)) {
421
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
422
422
  }
423
- const types = ctx.spec.types || [];
423
+ const types = ctx.config.types || [];
424
424
  if (types.length === 0) {
425
- return maybeInvertPolicyOutcome(true, ctx.spec.invert);
425
+ return maybeInvertPolicyOutcome(true, ctx.config.invert);
426
426
  }
427
- const typeAllowed = types.indexOf(ctx.data.identity.type) !== -1;
428
- return maybeInvertPolicyOutcome(typeAllowed, ctx.spec.invert);
427
+ const typeAllowed = types.indexOf(ctx.input.identity.type) !== -1;
428
+ return maybeInvertPolicyOutcome(typeAllowed, ctx.config.invert);
429
429
  }
430
430
  constructor(){
431
431
  this.validator = new IdentityPolicyValidator();
@@ -438,20 +438,20 @@ class PermissionBindingPolicyValidator extends validup.Container {
438
438
 
439
439
  class PermissionBindingPolicyEvaluator {
440
440
  async can(ctx) {
441
- return ctx.spec.type === BuiltInPolicyType.PERMISSION_BINDING;
441
+ return ctx.config.type === BuiltInPolicyType.PERMISSION_BINDING;
442
442
  }
443
- async validateSpecification(ctx) {
444
- return this.validator.run(ctx.spec);
443
+ async validateConfig(ctx) {
444
+ return this.validator.run(ctx.config);
445
445
  }
446
- async validateData(ctx) {
447
- if (!kit.isObject(ctx.data.identity) && !kit.isObject(ctx.data.permission)) {
446
+ async validateInput(ctx) {
447
+ if (!kit.isObject(ctx.input.identity) && !kit.isObject(ctx.input.permission)) {
448
448
  throw PolicyError.evaluatorContextInvalid();
449
449
  }
450
- return ctx.data;
450
+ return ctx.input;
451
451
  }
452
452
  async evaluate(ctx) {
453
453
  // todo: this must be changed when the permission-checker not only checks owned permissions.
454
- return maybeInvertPolicyOutcome(true, ctx.spec.invert);
454
+ return maybeInvertPolicyOutcome(true, ctx.config.invert);
455
455
  }
456
456
  constructor(){
457
457
  this.validator = new PermissionBindingPolicyValidator();
@@ -472,32 +472,32 @@ class RealmMatchPolicyValidator extends validup.Container {
472
472
 
473
473
  class RealmMatchPolicyEvaluator {
474
474
  async can(ctx) {
475
- return ctx.spec.type === BuiltInPolicyType.REALM_MATCH;
475
+ return ctx.config.type === BuiltInPolicyType.REALM_MATCH;
476
476
  }
477
- async validateSpecification(ctx) {
478
- return this.validator.run(ctx.spec);
477
+ async validateConfig(ctx) {
478
+ return this.validator.run(ctx.config);
479
479
  }
480
- async validateData(ctx) {
481
- if (!kit.isObject(ctx.data.attributes) || !kit.isObject(ctx.data.identity)) {
480
+ async validateInput(ctx) {
481
+ if (!kit.isObject(ctx.input.attributes) || !kit.isObject(ctx.input.identity)) {
482
482
  throw PolicyError.evaluatorContextInvalid();
483
483
  }
484
- return ctx.data;
484
+ return ctx.input;
485
485
  }
486
486
  async evaluate(ctx) {
487
- if (!ctx.data.attributes || !ctx.data.identity) {
487
+ if (!ctx.input.attributes || !ctx.input.identity) {
488
488
  throw PolicyError.evaluatorContextInvalid();
489
489
  }
490
- const identityMasterMatchAll = ctx.spec.identityMasterMatchAll ?? true;
491
- if (identityMasterMatchAll && ctx.data.identity.realmName && ctx.data.identity.realmName === 'master') {
492
- return maybeInvertPolicyOutcome(true, ctx.spec.invert);
490
+ const identityMasterMatchAll = ctx.config.identityMasterMatchAll ?? true;
491
+ if (identityMasterMatchAll && ctx.input.identity.realmName && ctx.input.identity.realmName === 'master') {
492
+ return maybeInvertPolicyOutcome(true, ctx.config.invert);
493
493
  }
494
494
  let keys;
495
- if (ctx.spec.attributeName) {
496
- if (Array.isArray(ctx.spec.attributeName)) {
497
- keys = ctx.spec.attributeName;
495
+ if (ctx.config.attributeName) {
496
+ if (Array.isArray(ctx.config.attributeName)) {
497
+ keys = ctx.config.attributeName;
498
498
  } else {
499
499
  keys = [
500
- ctx.spec.attributeName
500
+ ctx.config.attributeName
501
501
  ];
502
502
  }
503
503
  } else {
@@ -507,11 +507,11 @@ class RealmMatchPolicyEvaluator {
507
507
  'realmId',
508
508
  'realmName'
509
509
  ];
510
- ctx.spec.decisionStrategy = DecisionStrategy.CONSENSUS;
510
+ ctx.config.decisionStrategy = DecisionStrategy.CONSENSUS;
511
511
  }
512
- const attributeNameStrict = ctx.spec.attributeNameStrict ?? true;
512
+ const attributeNameStrict = ctx.config.attributeNameStrict ?? true;
513
513
  if (!attributeNameStrict) {
514
- const resourceKeys = Object.keys(ctx.data.attributes);
514
+ const resourceKeys = Object.keys(ctx.input.attributes);
515
515
  const keysToAdd = [];
516
516
  for(let i = 0; i < resourceKeys.length; i++){
517
517
  let contains = false;
@@ -531,29 +531,29 @@ class RealmMatchPolicyEvaluator {
531
531
  }
532
532
  let count = 0;
533
533
  for(let i = 0; i < keys.length; i++){
534
- if (!kit.hasOwnProperty(ctx.data.attributes, keys[i])) {
534
+ if (!kit.hasOwnProperty(ctx.input.attributes, keys[i])) {
535
535
  continue;
536
536
  }
537
537
  let outcome = false;
538
- const attributeValue = ctx.data.attributes[keys[i]];
539
- if (attributeValue === null && ctx.spec.attributeNullMatchAll) {
538
+ const attributeValue = ctx.input.attributes[keys[i]];
539
+ if (attributeValue === null && ctx.config.attributeNullMatchAll) {
540
540
  outcome = true;
541
- } else if (attributeValue === ctx.data.identity.realmId || attributeValue === ctx.data.identity.realmName) {
541
+ } else if (attributeValue === ctx.input.identity.realmId || attributeValue === ctx.input.identity.realmName) {
542
542
  outcome = true;
543
543
  }
544
544
  if (outcome) {
545
- if (ctx.spec.decisionStrategy === DecisionStrategy.AFFIRMATIVE) {
546
- return maybeInvertPolicyOutcome(true, ctx.spec.invert);
545
+ if (ctx.config.decisionStrategy === DecisionStrategy.AFFIRMATIVE) {
546
+ return maybeInvertPolicyOutcome(true, ctx.config.invert);
547
547
  }
548
548
  count++;
549
549
  } else {
550
- if (ctx.spec.decisionStrategy === DecisionStrategy.UNANIMOUS) {
551
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
550
+ if (ctx.config.decisionStrategy === DecisionStrategy.UNANIMOUS) {
551
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
552
552
  }
553
553
  count--;
554
554
  }
555
555
  }
556
- return maybeInvertPolicyOutcome(count > 0, ctx.spec.invert);
556
+ return maybeInvertPolicyOutcome(count > 0, ctx.config.invert);
557
557
  }
558
558
  constructor(){
559
559
  this.validator = new RealmMatchPolicyValidator();
@@ -619,55 +619,55 @@ function toDate(input, dateRef) {
619
619
  }
620
620
  class TimePolicyEvaluator {
621
621
  async can(ctx) {
622
- return ctx.spec.type === BuiltInPolicyType.TIME;
622
+ return ctx.config.type === BuiltInPolicyType.TIME;
623
623
  }
624
- async validateSpecification(ctx) {
625
- return this.validator.run(ctx.spec);
624
+ async validateConfig(ctx) {
625
+ return this.validator.run(ctx.config);
626
626
  }
627
- async validateData(ctx) {
628
- return ctx.data;
627
+ async validateInput(ctx) {
628
+ return ctx.input;
629
629
  }
630
630
  async evaluate(ctx) {
631
631
  let now;
632
- if (ctx.data.dateTime) {
633
- now = toDate(ctx.data.dateTime);
632
+ if (ctx.input.dateTime) {
633
+ now = toDate(ctx.input.dateTime);
634
634
  } else {
635
635
  now = new Date();
636
636
  }
637
- if (ctx.spec.start) {
638
- const start = normalizeDate(toDate(ctx.spec.start, now), now);
637
+ if (ctx.config.start) {
638
+ const start = normalizeDate(toDate(ctx.config.start, now), now);
639
639
  if (now < start) {
640
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
640
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
641
641
  }
642
642
  }
643
- if (ctx.spec.end) {
644
- const end = normalizeDate(toDate(ctx.spec.end, now), now);
643
+ if (ctx.config.end) {
644
+ const end = normalizeDate(toDate(ctx.config.end, now), now);
645
645
  if (now > end) {
646
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
646
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
647
647
  }
648
648
  }
649
- if (ctx.spec.interval) {
650
- if (isIntervalForDayOfWeek(ctx.spec.interval) && ctx.spec.dayOfWeek) {
651
- if (now.getDay() !== ctx.spec.dayOfWeek) {
652
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
649
+ if (ctx.config.interval) {
650
+ if (isIntervalForDayOfWeek(ctx.config.interval) && ctx.config.dayOfWeek) {
651
+ if (now.getDay() !== ctx.config.dayOfWeek) {
652
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
653
653
  }
654
654
  }
655
- if (isIntervalForDayOfMonth(ctx.spec.interval) && ctx.spec.dayOfMonth) {
656
- if (now.getDate() !== ctx.spec.dayOfMonth) {
657
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
655
+ if (isIntervalForDayOfMonth(ctx.config.interval) && ctx.config.dayOfMonth) {
656
+ if (now.getDate() !== ctx.config.dayOfMonth) {
657
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
658
658
  }
659
659
  }
660
- if (isIntervalForDayOfYear(ctx.spec.interval) && ctx.spec.dayOfYear) {
660
+ if (isIntervalForDayOfYear(ctx.config.interval) && ctx.config.dayOfYear) {
661
661
  const start = new Date(now.getFullYear(), 0, 0);
662
662
  const diff = now.getTime() - start.getTime() + (start.getTimezoneOffset() - now.getTimezoneOffset()) * 60 * 1000;
663
663
  const oneDay = 1000 * 60 * 60 * 24;
664
664
  const dayOfYear = Math.floor(diff / oneDay);
665
- if (dayOfYear !== ctx.spec.dayOfYear) {
666
- return maybeInvertPolicyOutcome(false, ctx.spec.invert);
665
+ if (dayOfYear !== ctx.config.dayOfYear) {
666
+ return maybeInvertPolicyOutcome(false, ctx.config.invert);
667
667
  }
668
668
  }
669
669
  }
670
- return maybeInvertPolicyOutcome(true, ctx.spec.invert);
670
+ return maybeInvertPolicyOutcome(true, ctx.config.invert);
671
671
  }
672
672
  constructor(){
673
673
  this.validator = new TimePolicyValidator();
@@ -903,11 +903,11 @@ class PermissionChecker {
903
903
  let outcome;
904
904
  try {
905
905
  outcome = await this.policyEngine.evaluate({
906
- data: {
907
- ...ctx.data || {},
906
+ input: {
907
+ ...ctx.input || {},
908
908
  permission: entity
909
909
  },
910
- spec: entity.policy,
910
+ config: entity.policy,
911
911
  options: {
912
912
  include: options.policiesIncluded,
913
913
  exclude: options.policiesExcluded