43596e4509
* refactor(server authz): refactor authz module to TypeScript * improved roles types * Update packages/server/modules/shared/errors/base.ts Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com> * refactor(server authz): fix PR comments Co-authored-by: Fabians <fabis94@live.com>
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import _ from 'lodash'
|
|
|
|
/**
|
|
* Speckle role constants
|
|
* - Stream - user roles in the context of a specific stream
|
|
* - Server - user roles in the context of the entire server
|
|
*/
|
|
export const Roles = Object.freeze(<const>{
|
|
Stream: {
|
|
Owner: 'stream:owner',
|
|
Contributor: 'stream:contributor',
|
|
Reviewer: 'stream:reviewer'
|
|
},
|
|
Server: {
|
|
Admin: 'server:admin',
|
|
User: 'server:user',
|
|
ArchivedUser: 'server:archived-user'
|
|
}
|
|
})
|
|
|
|
export type ServerRoles = typeof Roles['Server'][keyof typeof Roles['Server']]
|
|
export type StreamRoles = typeof Roles['Stream'][keyof typeof Roles['Stream']]
|
|
|
|
/**
|
|
* Speckle scope constants
|
|
* - Scopes define what kind of access has a user approved for a specific access token
|
|
*/
|
|
export const Scopes = Object.freeze(<const>{
|
|
Streams: {
|
|
Read: 'streams:read',
|
|
Write: 'streams:write'
|
|
},
|
|
Profile: {
|
|
Read: 'profile:read',
|
|
Email: 'profile:email',
|
|
Delete: 'profile:delete'
|
|
},
|
|
Users: {
|
|
Read: 'users:read',
|
|
Email: 'users:email',
|
|
Invite: 'users:invite'
|
|
},
|
|
Server: {
|
|
Stats: 'server:stats',
|
|
Setup: 'server:setup'
|
|
},
|
|
Tokens: {
|
|
Read: 'tokens:read',
|
|
Write: 'tokens:write'
|
|
}
|
|
})
|
|
|
|
/**
|
|
* All scopes
|
|
* @type {string[]}
|
|
*/
|
|
export const AllScopes = _.flatMap(Scopes, (v) => Object.values(v))
|