@enterprisestandard/esv 0.0.5-beta.20260114.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 (46) hide show
  1. package/README.md +203 -0
  2. package/dist/iam/index.d.ts +64 -0
  3. package/dist/iam/index.d.ts.map +1 -0
  4. package/dist/iam/index.js +5545 -0
  5. package/dist/iam/index.js.map +23 -0
  6. package/dist/index.d.ts +81 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +6558 -0
  9. package/dist/index.js.map +27 -0
  10. package/dist/runner.d.ts +37 -0
  11. package/dist/runner.d.ts.map +1 -0
  12. package/dist/runner.js +10909 -0
  13. package/dist/runner.js.map +33 -0
  14. package/dist/server/crypto.d.ts +46 -0
  15. package/dist/server/crypto.d.ts.map +1 -0
  16. package/dist/server/iam.d.ts +11 -0
  17. package/dist/server/iam.d.ts.map +1 -0
  18. package/dist/server/index.d.ts +31 -0
  19. package/dist/server/index.d.ts.map +1 -0
  20. package/dist/server/index.js +1380 -0
  21. package/dist/server/index.js.map +16 -0
  22. package/dist/server/server.d.ts +66 -0
  23. package/dist/server/server.d.ts.map +1 -0
  24. package/dist/server/sso.d.ts +11 -0
  25. package/dist/server/sso.d.ts.map +1 -0
  26. package/dist/server/state.d.ts +137 -0
  27. package/dist/server/state.d.ts.map +1 -0
  28. package/dist/server/vault.d.ts +11 -0
  29. package/dist/server/vault.d.ts.map +1 -0
  30. package/dist/server/workload.d.ts +19 -0
  31. package/dist/server/workload.d.ts.map +1 -0
  32. package/dist/sso/index.d.ts +24 -0
  33. package/dist/sso/index.d.ts.map +1 -0
  34. package/dist/sso/index.js +449 -0
  35. package/dist/sso/index.js.map +11 -0
  36. package/dist/tenant/index.d.ts +17 -0
  37. package/dist/tenant/index.d.ts.map +1 -0
  38. package/dist/types.d.ts +282 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/dist/utils.d.ts +75 -0
  41. package/dist/utils.d.ts.map +1 -0
  42. package/dist/workload/index.d.ts +17 -0
  43. package/dist/workload/index.d.ts.map +1 -0
  44. package/dist/workload/index.js +503 -0
  45. package/dist/workload/index.js.map +11 -0
  46. package/package.json +57 -0
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # Enterprise Standard Validator
2
+
3
+ The set of validators used to validate that an application correctly implements Enterprise Standards.
4
+
5
+ This package provides comprehensive validation tests for:
6
+
7
+ - **SSO (Single Sign-On)**: Validates OIDC login flows, session management, and logout
8
+ - **IAM (Identity and Access Management)**: Validates SCIM user and group provisioning
9
+ - **Workload Identity**: Validates service-to-service authentication
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ bun add @enterprisestandard/esv vitest
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ### With Vitest (Recommended)
20
+
21
+ Create a test file in your project (e.g., `tests/esv.test.ts`):
22
+
23
+ ```typescript
24
+ import { describe, it } from 'vitest';
25
+ import { createSSOTests, createWorkloadTests } from '@enterprisestandard/esv';
26
+
27
+ const BASE_URL = process.env.TEST_BASE_URL || 'http://localhost:3000';
28
+
29
+ describe('Enterprise Standard Validation', () => {
30
+ describe('SSO', () => {
31
+ const tests = createSSOTests({ baseUrl: BASE_URL });
32
+ tests.map(({name, fn}) => it(name, fn))
33
+ });
34
+
35
+ describe('Workload', () => {
36
+ const tests = createWorkloadTests({ baseUrl: BASE_URL });
37
+ tests.map(({name, fn}) => it(name, fn))
38
+ });
39
+ });
40
+ ```
41
+
42
+ Run with:
43
+ ```bash
44
+ bun run vitest run
45
+ ```
46
+
47
+ ### Programmatic Usage
48
+
49
+ ```typescript
50
+ import { validateAll, printReport } from '@enterprisestandard/esv';
51
+
52
+ async function runValidation() {
53
+ const report = await validateAll({
54
+ baseUrl: 'http://localhost:3000',
55
+ sso: {
56
+ loginPath: '/api/auth/login',
57
+ userPath: '/api/auth/user',
58
+ },
59
+ workload: {
60
+ tokenPath: '/api/workload/token',
61
+ },
62
+ });
63
+
64
+ printReport(report);
65
+
66
+ if (!report.passed) {
67
+ process.exit(1);
68
+ }
69
+ }
70
+
71
+ runValidation();
72
+ ```
73
+
74
+ **Handler configuration precedence:** Enterprise Standard handlers merge defaults provided at `enterpriseStandard` initialization with per-call overrides (per-call wins). Ensure your app exposes the tested routes (`/api/auth/*`, `/api/workload/*`, etc.) with either init-time defaults or per-call overrides matching the paths used in these tests.
75
+
76
+ ## Configuration
77
+
78
+ ### SSO Validation Config
79
+
80
+ ```typescript
81
+ interface SSOValidationConfig {
82
+ baseUrl: string;
83
+ loginPath?: string; // Default: '/api/auth/login'
84
+ callbackPath?: string; // Default: '/api/auth/callback'
85
+ userPath?: string; // Default: '/api/auth/user'
86
+ logoutPath?: string; // Default: '/api/auth/logout'
87
+ backChannelLogoutPath?: string; // Default: '/api/auth/logout/backchannel'
88
+ tokenPath?: string; // Default: '/api/auth/token'
89
+ refreshPath?: string; // Default: '/api/auth/refresh'
90
+ timeout?: number; // Default: 5000ms
91
+ expectedAuthorizationUrlPattern?: RegExp;
92
+ }
93
+ ```
94
+
95
+ ### IAM Validation Config
96
+
97
+ ```typescript
98
+ interface IAMValidationConfig {
99
+ baseUrl: string;
100
+ scimPath?: string; // Default: '/api/iam'
101
+ bearerToken?: string; // Required: Bearer token for SCIM API
102
+ getToken?: () => Promise<string>; // Alternative: Function to get token
103
+ testUser?: {
104
+ userName: string;
105
+ displayName: string;
106
+ emails: Array<{ value: string; primary?: boolean }>;
107
+ name?: { givenName?: string; familyName?: string };
108
+ };
109
+ testGroup?: {
110
+ displayName: string;
111
+ externalId?: string;
112
+ };
113
+ timeout?: number;
114
+ }
115
+ ```
116
+
117
+ ### Workload Validation Config
118
+
119
+ ```typescript
120
+ interface WorkloadValidationConfig {
121
+ baseUrl: string;
122
+ tokenPath?: string; // Default: '/api/workload/token'
123
+ validatePath?: string; // Default: '/api/workload/validate'
124
+ jwksPath?: string; // Default: '/api/workload/jwks'
125
+ refreshPath?: string; // Default: '/api/workload/refresh'
126
+ testScopes?: string;
127
+ validToken?: string; // Optional: Pre-acquired valid token
128
+ timeout?: number;
129
+ }
130
+ ```
131
+
132
+ ## CI/CD Integration
133
+
134
+ ### GitHub Actions
135
+
136
+ ```yaml
137
+ name: Enterprise Standard Validation
138
+ on: [push, pull_request]
139
+
140
+ jobs:
141
+ validate:
142
+ runs-on: ubuntu-latest
143
+ steps:
144
+ - uses: actions/checkout@v4
145
+ - uses: oven-sh/setup-bun@v2
146
+
147
+ - name: Install dependencies
148
+ run: bun install
149
+
150
+ - name: Start application
151
+ run: bun run dev &
152
+
153
+ - name: Wait for app to be ready
154
+ run: |
155
+ timeout 30 bash -c 'until curl -s http://localhost:3000 > /dev/null; do sleep 1; done'
156
+
157
+ - name: Run ESV tests
158
+ run: bun run vitest run tests/esv.test.ts
159
+ ```
160
+
161
+ ## Test Coverage
162
+
163
+ ### SSO Tests
164
+
165
+ | Test | Description |
166
+ |------|-------------|
167
+ | Login Endpoint | Verifies redirect to IdP with PKCE parameters |
168
+ | User Endpoint (Unauth) | Verifies 401 response without session |
169
+ | Logout Endpoint | Verifies cookie clearing |
170
+ | Back-Channel Logout | Verifies endpoint exists and handles requests |
171
+ | Callback Invalid | Verifies error handling for invalid callbacks |
172
+ | Token Endpoint (Unauth) | Verifies 401 response without session |
173
+ | Refresh Endpoint (Unauth) | Verifies 401 response without session |
174
+
175
+ ### IAM Tests
176
+
177
+ | Test | Description |
178
+ |------|-------------|
179
+ | Authentication Required | Verifies SCIM endpoints require auth |
180
+ | Users Schema | Verifies SCIM ListResponse structure |
181
+ | Groups Schema | Verifies SCIM ListResponse structure |
182
+ | Create User | Creates a test user via SCIM |
183
+ | Get User | Retrieves created user by ID |
184
+ | Update User | Patches user attributes |
185
+ | Delete User | Deletes user and verifies 404 |
186
+ | Create Group | Creates a test group via SCIM |
187
+ | Delete Group | Deletes group |
188
+
189
+ ### Workload Tests
190
+
191
+ | Test | Description |
192
+ |------|-------------|
193
+ | JWKS Endpoint | Verifies JWKS structure with keys |
194
+ | Token Endpoint | Acquires workload access token |
195
+ | Validate No Auth | Verifies 401 without auth header |
196
+ | Validate Invalid | Verifies rejection of invalid tokens |
197
+ | Validate Valid | Verifies acceptance of valid tokens |
198
+ | Whoami with Workload | Verifies workload identity in response |
199
+ | Refresh Endpoint | Verifies token refresh works |
200
+
201
+ ## License
202
+
203
+ Proprietary - Enterprise Standard
@@ -0,0 +1,64 @@
1
+ /**
2
+ * IAM Validation Tests
3
+ *
4
+ * These tests validate that an application correctly implements
5
+ * Enterprise Standard IAM (Identity and Access Management) via SCIM.
6
+ *
7
+ * The core IAM tests validate user management operations. Group management
8
+ * has two optional extensions:
9
+ * - `ext.createGroupsOutboundTests()` - Tests app calling external IAM provider
10
+ * - `ext.createGroupsInboundTests()` - Tests external IAM provider calling app
11
+ */
12
+ import type { IAMValidationConfig, TestDef, ValidationSuiteResult } from '../types';
13
+ /**
14
+ * Runs all IAM validation tests (core user tests + optional groups tests)
15
+ */
16
+ export declare function validateIAM(config: IAMValidationConfig): Promise<ValidationSuiteResult>;
17
+ /**
18
+ * Creates Vitest-compatible test suite for IAM validation.
19
+ *
20
+ * Returns `{ tests, ext }` where:
21
+ * - `tests`: Core user management tests (always run)
22
+ * - `ext`: Extension methods for optional functionality:
23
+ * - `createGroupsOutboundTests()` - Tests app calling external IAM provider
24
+ * - `createGroupsInboundTests()` - Tests external IAM provider calling app
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * describe('IAM', () => {
29
+ * const { tests, ext } = createIAMTests({ ... });
30
+ *
31
+ * // Core user tests
32
+ * tests.forEach(({ name, fn }) => it(name, fn));
33
+ *
34
+ * // Optional: Groups Outbound tests (app -> external IAM)
35
+ * describe('Groups Outbound', () => {
36
+ * ext.createGroupsOutboundTests().forEach(({ name, fn }) => it(name, fn));
37
+ * });
38
+ *
39
+ * // Optional: Groups Inbound tests (external IAM -> app)
40
+ * describe('Groups Inbound', () => {
41
+ * ext.createGroupsInboundTests().forEach(({ name, fn }) => it(name, fn));
42
+ * });
43
+ * });
44
+ * ```
45
+ */
46
+ export declare function createIAMTests(config: IAMValidationConfig): {
47
+ tests: TestDef[];
48
+ ext: {
49
+ /**
50
+ * Create tests for Groups Outbound extension.
51
+ * Tests app calling external IAM provider to create/manage groups.
52
+ * These tests hit the external IAM's SCIM endpoints (proxied through the app).
53
+ */
54
+ createGroupsOutboundTests: () => Array<TestDef>;
55
+ /**
56
+ * Create tests for Groups Inbound extension.
57
+ * Tests external IAM provider calling app's SCIM endpoints.
58
+ * These tests simulate an external IAM provider (like SailPoint) pushing group changes to the app.
59
+ */
60
+ createGroupsInboundTests: () => Array<TestDef>;
61
+ };
62
+ };
63
+ export type { IAMValidationConfig };
64
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/iam/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAoB,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAqftG;;GAEG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAoG7F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,mBAAmB;;;QA6DtD;;;;WAIG;yCAC4B,KAAK,CAAC,OAAO,CAAC;QAmB7C;;;;WAIG;wCAC2B,KAAK,CAAC,OAAO,CAAC;;EAgG/C;AAED,YAAY,EAAE,mBAAmB,EAAE,CAAC"}