import { ScopeContext } from '../../common/types' ; const aliasScopesClaims = { birth : [ 'birthplace' , 'birthcountry' ] , identite_pivot : [ 'birthcountry' , 'birthdate' , 'birthplace' , 'family_name' , 'gender' , 'given_name' , ] , openid : [ 'sub' ] , phone : [ 'phone_number' ] , profile : [ 'birthdate' , 'family_name' , 'gender' , 'given_name' , 'preferred_username' , ] , } ; const DEFAULT_SCOPE_TYPE = 'tous les scopes' ; param { ScopeContext [ ] } scopes param { string } type returns export const getScopeByType = ( scopes , type ) : ScopeContext => { const scopeContext = scopes . find ( ( scope ) => scope . type === type ) ; expect ( scopeContext , `No scope matches the type '${ type }'` ) . to . exist ; return scopeContext ; } ; param { ScopeContext [ ] } scopes returns export const getDefaultScope = ( scopes ) : ScopeContext => { return getScopeByType ( scopes , DEFAULT_SCOPE_TYPE ) ; } ; param scopeContext returns export const getClaims = ( scopeContext ) : string [ ] => { const { scopes } = scopeContext ; const claims = scopes . map ( ( scope ) : string => aliasScopesClaims [ scope ] ? aliasScopesClaims [ scope ] : scope ) . flat ( ) ; return [ ... new Set ( claims ) ] ; } ;