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