@@ -5,6 +5,7 @@ import { Redactable, RedactionPolicy, redactObject } from '../util/redaction'
5
5
import { SlimUser } from '../authentication'
6
6
import { AuthorizationBitmapsDTO , AuthorizationBitmapsKey , isAuthorizationBitmapsDTO } from '../models/authorization'
7
7
import { BufferUserPlanGuest } from '../models/user-bitmap.model'
8
+ import { OpenPermissions , bitmapsAlign as bitmapsAlignCheck } from '../util/bigint'
8
9
9
10
export type RedactCondition = ( context : HookContext < ImpressoApplication > , redactable ?: Redactable ) => boolean
10
11
@@ -103,19 +104,19 @@ export const bitmapsAlign = (
103
104
const userBitmap = user ?. bitmap ?? BufferUserPlanGuest
104
105
105
106
const contentBitmap =
106
- contentBitmapExtractor != null && redactable != null ? contentBitmapExtractor ( redactable ) : BigInt ( 0 )
107
+ contentBitmapExtractor != null && redactable != null ? contentBitmapExtractor ( redactable ) : OpenPermissions
107
108
108
- return ( contentBitmap & userBitmap ) != BigInt ( 0 )
109
+ return bitmapsAlignCheck ( contentBitmap , userBitmap )
109
110
}
110
111
111
112
export type { RedactionPolicy }
112
113
113
114
const authBitmapExtractor = ( redactable : Redactable , kind : keyof AuthorizationBitmapsDTO ) => {
114
115
const authorizationBitmapDto = redactable [ AuthorizationBitmapsKey ]
115
116
if ( isAuthorizationBitmapsDTO ( authorizationBitmapDto ) ) {
116
- return authorizationBitmapDto [ kind ] ?? BigInt ( 0 )
117
+ return authorizationBitmapDto [ kind ] ?? OpenPermissions
117
118
}
118
- return BigInt ( 0 )
119
+ return OpenPermissions
119
120
}
120
121
121
122
/**
@@ -137,7 +138,7 @@ const webappAuthBitmapExtractor = (redactable: Redactable, kind: keyof Authoriza
137
138
}
138
139
const actualKey = `bitmap${ kind . charAt ( 0 ) . toUpperCase ( ) + kind . slice ( 1 ) } `
139
140
const value = redactable [ actualKey ]
140
- return value != null ? BigInt ( value ) : BigInt ( 0 )
141
+ return value != null ? BigInt ( value ) : OpenPermissions
141
142
}
142
143
143
144
/**
0 commit comments