Initial commit: add .gitignore and README
This commit is contained in:
28
packages/shared-auth/package.json
Normal file
28
packages/shared-auth/package.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "@dbis/shared-auth",
|
||||
"version": "1.0.0",
|
||||
"description": "Shared authentication utilities for DBIS projects",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "vitest",
|
||||
"lint": "eslint src",
|
||||
"type-check": "tsc --noEmit",
|
||||
"clean": "rm -rf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@workspace/shared-auth": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.5.4",
|
||||
"vitest": "^1.2.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "restricted"
|
||||
}
|
||||
}
|
||||
|
||||
19
packages/shared-auth/src/index.ts
Normal file
19
packages/shared-auth/src/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @dbis/shared-auth
|
||||
* Shared authentication utilities for DBIS projects
|
||||
*/
|
||||
|
||||
// Re-export workspace shared auth
|
||||
export * from '@workspace/shared-auth';
|
||||
|
||||
// DBIS-specific auth utilities
|
||||
export function hasDBISRole(user: { roles: string[] }, role: string): boolean {
|
||||
return user.roles.includes(role);
|
||||
}
|
||||
|
||||
export function requireDBISRole(user: { roles: string[] }, role: string): void {
|
||||
if (!hasDBISRole(user, role)) {
|
||||
throw new Error(`User does not have required role: ${role}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user