@navirondynamics/accord 1.1.0 β†’ 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +161 -81
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,22 +1,64 @@
1
1
  # Accord
2
2
 
3
- **Accord** is a policy-first identity and access engine designed to unify identity representation, context resolution, and authorization under a single, declarative model.
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/@navirondynamics/accord">
5
+ <img src="https://img.shields.io/npm/v/@navirondynamics/accord.svg" alt="npm version" />
6
+ </a>
7
+ <a href="https://www.npmjs.com/package/@navirondynamics/accord">
8
+ <img src="https://img.shields.io/npm/dm/@navirondynamics/accord.svg" alt="npm downloads" />
9
+ </a>
10
+ <a href="https://github.com/bsen-alt/Accord">
11
+ <img src="https://img.shields.io/github/license/bsen-alt/Accord" alt="license" />
12
+ </a>
13
+ </p>
4
14
 
5
- It treats access not as scattered checks embedded in application code, but as a **formal agreement** between identities, systems, and resources.
15
+ Accord is a **policy-first identity and access engine for Node.js**.
6
16
 
7
- ## 🧠 The System of Agreement
17
+ It treats access not as scattered application logic, but as a formal agreement between identities, systems, and resources - evaluated through declarative, versioned policies.
8
18
 
9
- Modern authorization is often fragmented:
19
+ **New in v1.1:** Observability, YAML configuration, hot reload, and native NestJS support.
10
20
 
11
- - Authentication handled in one service.
12
- - Roles defined in another.
13
- - Access logic scattered across codebases.
21
+ ---
14
22
 
15
- **Accord** reframes this as a governance layer. Instead of embedding `if (user.admin)` checks, Accord externalizes rules into explicit, versioned policies.
23
+ ## Table of Contents
16
24
 
17
- - **Explicit:** Access rules are defined before execution.
18
- - **Inspectable:** Every decision returns a reason.
19
- - **Centralized:** One source of truth for multiple services.
25
+ - [Why Accord](#-why-accord)
26
+ - [Key Features](#key-features)
27
+ - [Installation](#-installation)
28
+ - [Quick Start](#-quick-start-v11)
29
+ - [Framework Integration](#-framework-integration)
30
+ - [CLI Tool](#-cli-tool)
31
+ - [Documentation](#-documentation)
32
+ - [Roadmap](#-roadmap)
33
+ - [Contributing](#-contributing)
34
+ - [License](#-license)
35
+
36
+ ---
37
+
38
+ ## πŸš€ Why Accord?
39
+
40
+ Modern authorization is fragmented:
41
+
42
+ - Authentication in one service
43
+ - Roles in another
44
+ - Access logic scattered across microservices
45
+
46
+ Accord centralizes authorization into a single **governance layer**, acting as the _System of Record_ for access control across your platform.
47
+
48
+ Instead of embedding authorization logic throughout your codebase, Accord externalizes it into auditable, inspectable, and versioned policy definitions.
49
+
50
+ ---
51
+
52
+ ## Key Features
53
+
54
+ - πŸ” **Observability** – Built-in audit logging (console & file)
55
+ - πŸ“ **Policy as Code** – JSON and YAML configuration support
56
+ - πŸ›‘οΈ **Reliability** – Zod-based schema validation to prevent invalid policies
57
+ - πŸ”„ **Zero-Downtime Updates** – Hot reload policies without restarting services
58
+ - 🧩 **Framework Adapters** – Express, NestJS, and Fastify integrations
59
+ - πŸ“¦ **CLI Tooling** – Validate and simulate access decisions locally
60
+
61
+ ---
20
62
 
21
63
  ## πŸ“¦ Installation
22
64
 
@@ -24,89 +66,93 @@ Modern authorization is often fragmented:
24
66
  npm install @navirondynamics/accord
25
67
  ```
26
68
 
27
- ## πŸš€ Quick Start
69
+ ---
28
70
 
29
- ### 1. Define Your Configuration
71
+ ## πŸ› οΈ Quick Start (v1.1)
30
72
 
31
- Create a `config` folder in your project root.
73
+ ### 1. Define Policies (YAML supported)
32
74
 
33
- **`config/policies.json`**
75
+ Create `config/policies.yaml`:
34
76
 
35
- ```json
36
- [
37
- {
38
- "id": "policy-admin",
39
- "version": "1.0",
40
- "effect": "allow",
41
- "subject": {
42
- "type": "user",
43
- "attributes": { "role": "admin" }
44
- },
45
- "action": ["delete"],
46
- "resource": { "type": "booking" }
47
- }
48
- ]
77
+ ```yaml
78
+ - id: 'admin-delete'
79
+ version: '1.1'
80
+ effect: 'allow'
81
+ subject:
82
+ type: 'user'
83
+ attributes:
84
+ role: 'admin'
85
+ action: ['delete']
86
+ resource:
87
+ type: 'booking'
49
88
  ```
50
89
 
51
- **`config/identities.json`**
90
+ ---
52
91
 
53
- ```json
54
- [
55
- {
56
- "id": "alice",
57
- "type": "user",
58
- "status": "active",
59
- "attributes": { "role": "admin" }
60
- }
61
- ]
62
- ```
63
-
64
- ### 2. Use in Your Code
92
+ ### 2. Initialize Accord
65
93
 
66
94
  ```javascript
67
- const { Accord } = require('@navirondynamics/accord');
95
+ const { Accord, ConsoleAuditLogger } = require('@navirondynamics/accord');
68
96
 
69
- // 1. Initialize the Engine
70
97
  const accord = new Accord({
71
- policyPath: './config/policies.json',
98
+ policyPath: './config/policies.yaml',
72
99
  identityPath: './config/identities.json',
100
+ logger: new ConsoleAuditLogger(),
73
101
  });
102
+ ```
74
103
 
75
- async function deleteBooking(bookingId, userId) {
76
- // 2. Check Access
104
+ ---
105
+
106
+ ### 3. Check Access
107
+
108
+ ```javascript
109
+ async function deleteUser(userId) {
77
110
  const decision = await accord.check(userId, 'delete', {
78
- type: 'booking',
79
- id: bookingId,
111
+ type: 'user',
112
+ id: userId,
80
113
  });
81
114
 
82
- // 3. Enforce Decision
83
115
  if (decision.decision === 'allow') {
84
- console.log('Access Granted');
85
- // Perform delete...
116
+ console.log('Permission Granted');
117
+ // Perform deletion...
86
118
  } else {
87
119
  console.log('Access Denied:', decision.reason);
88
120
  }
89
121
  }
122
+ ```
123
+
124
+ ---
125
+
126
+ ## πŸ›‘οΈ Framework Integration
127
+
128
+ ### NestJS
129
+
130
+ ```typescript
131
+ import { AccordGuard } from '@navirondynamics/accord/adapters/nest';
90
132
 
91
- deleteBooking('b1', 'alice');
133
+ @Controller('bookings')
134
+ export class BookingController {
135
+ @UseGuards(
136
+ new AccordGuard({
137
+ accordInstance: accord,
138
+ action: 'delete',
139
+ resourceType: 'booking',
140
+ })
141
+ )
142
+ @Delete(':id')
143
+ deleteBooking(@Param('id') id: string) {
144
+ // Only authorized users reach here
145
+ }
146
+ }
92
147
  ```
93
148
 
94
- ## πŸ›‘οΈ Express Middleware
149
+ ---
95
150
 
96
- Protect your routes without cluttering your controller logic.
151
+ ### Express
97
152
 
98
153
  ```javascript
99
- const express = require('express');
100
- const { Accord } = require('@navirondynamics/accord');
101
154
  const { protect } = require('@navirondynamics/accord/adapters/express');
102
155
 
103
- const app = express();
104
- const accord = new Accord({
105
- policyPath: './config/policies.json',
106
- identityPath: './config/identities.json',
107
- });
108
-
109
- // Protect this route
110
156
  app.delete(
111
157
  '/bookings/:id',
112
158
  protect({
@@ -115,36 +161,70 @@ app.delete(
115
161
  resourceType: 'booking',
116
162
  }),
117
163
  (req, res) => {
118
- // Only allowed users reach here
119
- res.send('Booking deleted');
164
+ res.send('Deleted');
120
165
  }
121
166
  );
122
-
123
- app.listen(3000);
124
167
  ```
125
168
 
126
- ## πŸ› οΈ CLI Tool
169
+ Fastify support and advanced usage are available in the adapters documentation.
170
+
171
+ ---
127
172
 
128
- Validate policies and test access logic from your terminal.
173
+ ## πŸ”§ CLI Tool
129
174
 
130
- **Validate Configuration:**
175
+ Validate policies or simulate access decisions directly from your terminal.
131
176
 
132
177
  ```bash
133
- npx @navirondynamics/accord validate ./config/policies.json
178
+ # Validate policy syntax
179
+ npx @navirondynamics/accord validate ./config/policies.yaml
180
+
181
+ # Test access logic
182
+ npx @navirondynamics/accord eval -i user_123 -a delete -r booking
134
183
  ```
135
184
 
136
- **Dry-Run Access Check:**
185
+ ---
137
186
 
138
- ```bash
139
- npx @navirondynamics/accord eval -i alice -a delete -r booking
140
- ```
187
+ ## πŸ“š Documentation
188
+
189
+ - **Getting Started** – Installation and core concepts
190
+ - **Configuration Guide** – Identities, policies, JSON vs YAML
191
+ - **Observability & Auditing** – Production logging setup
192
+ - **Framework Adapters** – Express, NestJS, Fastify usage
193
+ - **CLI Reference** – Full command list
194
+
195
+ ---
196
+
197
+ ## πŸ—ΊοΈ Roadmap
198
+
199
+ Planned improvements:
200
+
201
+ - Policy versioning & rollback
202
+ - Database-backed policy storage
203
+ - Web-based policy editor
204
+ - Decision caching
205
+ - OpenTelemetry tracing
206
+ - Distributed policy synchronization
207
+
208
+ ---
209
+
210
+ ## 🀝 Contributing
211
+
212
+ Contributions are welcome.
213
+
214
+ 1. Fork the repository
215
+ 2. Create a feature branch
216
+
217
+ ```bash
218
+ git checkout -b feature/my-feature
219
+ ```
220
+
221
+ 3. Commit your changes
222
+ 4. Push to your fork
223
+ 5. Open a Pull Request
141
224
 
142
- ## βš™οΈ Core Concepts
225
+ Please ensure tests pass and documentation is updated.
143
226
 
144
- - **Identity:** Represents who is acting (User, Service, Agent). Includes a `status` (active/suspended) allowing for a "Kill Switch".
145
- - **Resource:** Represents what is being accessed.
146
- - **Policy:** The agreement linking Identity, Action, and Resource. Supports RBAC (Roles) and ABAC (Attributes).
147
- - **Decision:** The output (`allow`/`deny`) including a `reason` for auditing.
227
+ ---
148
228
 
149
229
  ## πŸ“œ License
150
230
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navirondynamics/accord",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "A policy-first identity and access engine for modular systems.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",