🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

@bondsports/permissions

Package Overview
Dependencies
Maintainers
12
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bondsports/permissions

Bondsports internal permissions strings package

latest
Source
npmnpm
Version
0.2.21-a-2
Version published
Weekly downloads
1.2K
41.36%
Maintainers
12
Weekly downloads
 
Created
Source

Permissions Package

This package centralizes and organizes all permissions used across the application into well-structured modules. It ensures consistency between frontend and backend implementations, and will hopefully make it easier to find and use permissions.

Features

  • Modular Organization: Permissions are grouped into modules based on their functional domains (e.g., calendar, commerce).
  • Strong Typing: Permissions are defined as constant objects with TypeScript support for type safety.
  • Centralized Access: All modules are aggregated in a single permissions object for convenient access.

Installation

npm install @bond-sports/permissions

Usage

All permissions are aggregated in a central permissions object, which can be imported for global access:

import permissions from '@bond-sports/permissions';

console.log(permissions.calendar.reservation.create); // Output: "calendar.reservation.create"
console.log(permissions.commerce.kiosk.view);         // Output: "commerce.kiosk.view"

Adding New Permissions

To add new permissions:

  • Create or update the corresponding module file (e.g., calendar.ts for calendar-related permissions).
  • Follow the structure:
const CalendarPermissions = {
	reservation: {
		create: 'calendar.reservation.create',
		edit: 'calendar.reservation.edit',
	},
	slots: {
		sessions: {
			checkIn: 'calendar.slots.sessions.checkIn',
		},
	},
} as const;

export default CalendarPermissions;
  • Ensure the index.ts file imports the new module and updates the permissions object.

Example: Usage in Backend

Use permissions in backend services for access control:

import permissions from '@bond-sports/permissions';

// Example: Checking user permissions in a middleware
function hasPermission(userPermissions: string[], requiredPermission: string): boolean {
	return userPermissions.includes(requiredPermission);
}

const userPermissions = ['calendar.reservation.create'];
const requiredPermission = permissions.calendar.reservation.create;

if (hasPermission(userPermissions, requiredPermission)) {
	console.log('Permission granted');
} else {
	console.log('Permission denied');
}

Example: Usage in Frontend

Control UI components based on user permissions:

import permissions from '@bond-sports/permissions';

function PermissionsWrapper({ requiredPermission, children, userPermissions }) {
  if (userPermissions.includes(requiredPermission)) {
    return <>{children}</>;
  }
  return null;
}

// Usage in a React component
<PermissionsWrapper
  requiredPermission={permissions.commerce.kiosk.view}
  userPermissions={['commerce.kiosk.view']}
>
  <button>Access Kiosk</button>
</PermissionsWrapper>;

Contributing

  • Clone the repository and install dependencies:
git clone git@github.com:Bond-Sports/permissions.git
  • Install the project dependencies:
npm install
  • Add or modify permissions in the appropriate module files.

  • Commit and push your changes:

git commit -m "Add new permissions for [feature]"
git push

Publishing

This package is automatically published when updates are pushed to specific branches (e.g., develop, staging, master) via GitHub Actions.

FAQs

Package last updated on 19 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts