@@ -108,11 +108,11 @@ export class PolicyFactory implements OnModuleInit {
108
108
}
109
109
}
110
110
111
- await this . defaultInterfacesFromImplementationsIntersection ( grants ) ;
112
- await this . defaultImplementationsFromInterfaces ( grants ) ;
113
- await this . defaultRelationEdgesToResourceLevel ( grants ) ;
111
+ this . defaultInterfacesFromImplementationsIntersection ( grants ) ;
112
+ this . defaultImplementationsFromInterfaces ( grants ) ;
113
+ this . defaultRelationEdgesToResourceLevel ( grants ) ;
114
114
115
- const powers = await this . determinePowers ( grants ) ;
115
+ const powers = this . determinePowers ( grants ) ;
116
116
117
117
const name = startCase ( discoveredClass . name . replace ( / P o l i c y $ / , '' ) ) ;
118
118
const policy : Policy = { name, roles, grants, powers } ;
@@ -125,17 +125,13 @@ export class PolicyFactory implements OnModuleInit {
125
125
* Declare permissions of missing interfaces based on the intersection of
126
126
* the permissions of its implementations
127
127
*/
128
- private async defaultInterfacesFromImplementationsIntersection (
128
+ private defaultInterfacesFromImplementationsIntersection (
129
129
grantMap : WritableGrants ,
130
130
) {
131
131
const interfaceCandidates = new Set (
132
- (
133
- await Promise . all (
134
- [ ...grantMap . keys ( ) ] . map ( ( res ) =>
135
- this . resourcesHost . getInterfaces ( res ) ,
136
- ) ,
137
- )
138
- ) . flat ( ) ,
132
+ [ ...grantMap . keys ( ) ]
133
+ . map ( ( res ) => this . resourcesHost . getInterfaces ( res ) )
134
+ . flat ( ) ,
139
135
) ;
140
136
141
137
const allKeysOf = ( list : Array < object | undefined > ) =>
@@ -156,7 +152,7 @@ export class PolicyFactory implements OnModuleInit {
156
152
continue ;
157
153
}
158
154
159
- const impls = await this . resourcesHost . getImplementations ( interfaceRes ) ;
155
+ const impls = this . resourcesHost . getImplementations ( interfaceRes ) ;
160
156
161
157
// Skip if policy doesn't specify all implementations of the interface
162
158
if ( ! ( impls . length > 0 && impls . every ( ( impl ) => grantMap . has ( impl ) ) ) ) {
@@ -213,18 +209,18 @@ export class PolicyFactory implements OnModuleInit {
213
209
}
214
210
}
215
211
216
- private async defaultImplementationsFromInterfaces ( grants : WritableGrants ) {
212
+ private defaultImplementationsFromInterfaces ( grants : WritableGrants ) {
217
213
for ( const resource of grants . keys ( ) ) {
218
- const impls = await this . resourcesHost . getImplementations ( resource ) ;
214
+ const impls = this . resourcesHost . getImplementations ( resource ) ;
219
215
for ( const impl of impls ) {
220
216
if ( grants . has ( impl ) ) {
221
217
continue ;
222
218
}
223
219
// If policy doesn't specify this implementation then use most specific
224
220
// interface given.
225
- const interfaceToApply = (
226
- await this . resourcesHost . getInterfaces ( impl )
227
- ) . find ( ( i ) => grants . has ( i ) ) ;
221
+ const interfaceToApply = this . resourcesHost
222
+ . getInterfaces ( impl )
223
+ . find ( ( i ) => grants . has ( i ) ) ;
228
224
const interfacePerms = interfaceToApply && grants . get ( interfaceToApply ) ;
229
225
if ( ! interfacePerms ) {
230
226
// Safety check, but this shouldn't ever happen, since we only got
@@ -236,7 +232,7 @@ export class PolicyFactory implements OnModuleInit {
236
232
}
237
233
}
238
234
239
- private async defaultRelationEdgesToResourceLevel ( grants : WritableGrants ) {
235
+ private defaultRelationEdgesToResourceLevel ( grants : WritableGrants ) {
240
236
for ( const [ resource , { childRelations } ] of grants . entries ( ) ) {
241
237
for ( const rel of resource . relations . values ( ) ) {
242
238
const type = rel . resource ;
@@ -297,7 +293,7 @@ export class PolicyFactory implements OnModuleInit {
297
293
return mergeConditions ( ...conditions ) ;
298
294
}
299
295
300
- private async determinePowers ( grants : Grants ) {
296
+ private determinePowers ( grants : Grants ) {
301
297
const powers = new Set < Power > ( ) ;
302
298
const pushPower = ( str : string ) => {
303
299
const power = `Create${ str } ` ;
@@ -313,7 +309,7 @@ export class PolicyFactory implements OnModuleInit {
313
309
}
314
310
pushPower ( res . name ) ;
315
311
316
- const implementations = await this . resourcesHost . getImplementations ( res ) ;
312
+ const implementations = this . resourcesHost . getImplementations ( res ) ;
317
313
for ( const implementation of implementations ) {
318
314
if ( grants . has ( implementation ) ) {
319
315
// If policy specifies this implementation then defer to its entry.
0 commit comments