@owlmeans/server-auth 0.1.1 → 0.1.3

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 (55) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +33 -454
  3. package/build/actions/service.d.ts +2 -2
  4. package/build/actions/service.d.ts.map +1 -1
  5. package/build/actions/service.js.map +1 -1
  6. package/build/manager/actions/manager.d.ts +4 -4
  7. package/build/manager/actions/manager.d.ts.map +1 -1
  8. package/build/manager/actions/manager.js.map +1 -1
  9. package/build/manager/exports.d.ts +4 -4
  10. package/build/manager/exports.d.ts.map +1 -1
  11. package/build/manager/exports.js +2 -2
  12. package/build/manager/exports.js.map +1 -1
  13. package/build/manager/main.js +1 -1
  14. package/build/manager/main.js.map +1 -1
  15. package/build/manager/model.js +2 -2
  16. package/build/manager/model.js.map +1 -1
  17. package/build/manager/modules.d.ts +1 -1
  18. package/build/manager/modules.d.ts.map +1 -1
  19. package/build/manager/modules.js +3 -3
  20. package/build/manager/modules.js.map +1 -1
  21. package/build/manager/plugins/re-captcha.js +3 -3
  22. package/build/manager/plugins/re-captcha.js.map +1 -1
  23. package/build/manager/plugins/types.d.ts +1 -1
  24. package/build/manager/plugins/types.d.ts.map +1 -1
  25. package/build/manager/plugins/utils.d.ts +1 -1
  26. package/build/manager/plugins/utils.d.ts.map +1 -1
  27. package/build/manager/plugins/utils.js +2 -2
  28. package/build/manager/plugins/utils.js.map +1 -1
  29. package/build/manager/types.d.ts +1 -1
  30. package/build/manager/types.d.ts.map +1 -1
  31. package/build/modules.d.ts +2 -2
  32. package/build/modules.d.ts.map +1 -1
  33. package/build/modules.js +2 -2
  34. package/build/modules.js.map +1 -1
  35. package/build/types.d.ts +1 -1
  36. package/build/types.d.ts.map +1 -1
  37. package/package.json +31 -26
  38. package/src/actions/service.ts +2 -2
  39. package/src/manager/actions/manager.ts +4 -4
  40. package/src/manager/exports.ts +4 -4
  41. package/src/manager/main.ts +1 -1
  42. package/src/manager/model.ts +2 -2
  43. package/src/manager/modules.ts +3 -3
  44. package/src/manager/plugins/re-captcha.ts +4 -4
  45. package/src/manager/plugins/types.ts +1 -1
  46. package/src/manager/plugins/utils.ts +2 -2
  47. package/src/manager/rely.ts +1 -1
  48. package/src/manager/types.ts +1 -1
  49. package/src/modules.ts +5 -5
  50. package/src/service.ts +1 -1
  51. package/src/types.ts +1 -1
  52. package/tests/context.ts +59 -0
  53. package/tests/service.spec.ts +174 -0
  54. package/tests/tsconfig.json +12 -0
  55. package/tsconfig.json +6 -5
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 OwlMeans Common — Fullstack typescript framework
3
+ Copyright (c) 2026 OwlMeans Common — Fullstack typescript framework
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,490 +1,69 @@
1
1
  # @owlmeans/server-auth
2
2
 
3
- Server-side authentication service for OwlMeans Common applications. This package provides a comprehensive server authentication implementation with Ed25519 signature verification, token management, cache integration, and centralized authentication hub capabilities.
3
+ Server-side Ed25519 authentication service for OwlMeans backends.
4
4
 
5
5
  ## Overview
6
6
 
7
- The `@owlmeans/server-auth` package delivers server-side authentication functionality for the OwlMeans ecosystem, offering:
8
-
9
- - **Authentication Service**: Server-side authentication with Ed25519 signature verification
10
- - **Token Management**: Authentication token creation, validation, and lifecycle management
11
- - **Guard Integration**: Seamless integration with OwlMeans module guard system
12
- - **Cache Support**: Authentication state caching for performance optimization
13
- - **Central Auth Hub**: Complete authentication manager application for centralized authentication
14
- - **Trusted Entity Support**: Integration with trusted service authentication
15
-
16
- This package follows the OwlMeans "quadra" pattern as a server-side implementation complementing `@owlmeans/auth-common` and working with client authentication packages.
7
+ - Implements the `GuardService` interface for Ed25519-signed token verification
8
+ - `appendAuthService()` registers the auth guard into a server context
9
+ - `DEFAULT_ALIAS` (`'auth'`) is the service alias and re-exported as `DAUTH_GUARD` via `@owlmeans/server-app`
10
+ - Handles token caching via a static resource identified by `AUTH_CACHE`
17
11
 
18
12
  ## Installation
19
13
 
20
14
  ```bash
21
- npm install @owlmeans/server-auth
22
- ```
23
-
24
- ## Dependencies
25
-
26
- This package requires and integrates with:
27
- - `@owlmeans/auth`: Core authentication types and validation
28
- - `@owlmeans/auth-common`: Common authentication components
29
- - `@owlmeans/basic-envelope`: Cryptographic message envelopes
30
- - `@owlmeans/server-context`: Server context management
31
- - `@owlmeans/basic-keys`: Cryptographic operations
32
- - `@owlmeans/static-resource`: Resource management
33
-
34
- ## Core Concepts
35
-
36
- ### Authentication Service
37
-
38
- The server authentication service handles token validation, signature verification, and authentication state management using Ed25519 cryptographic signatures.
39
-
40
- ### Token Verification
41
-
42
- Implements secure token verification using envelope-based signatures and trusted entity validation, ensuring non-repudiable authentication.
43
-
44
- ### Central Auth Hub
45
-
46
- Includes a complete authentication manager application that can serve as a centralized authentication hub for microservices architectures.
47
-
48
- ## API Reference
49
-
50
- ### Types
51
-
52
- #### `AuthService`
53
- Main server authentication service interface extending GuardService.
54
-
55
- ```typescript
56
- interface AuthService extends GuardService {
57
- authenticate: (token: AuthToken) => Promise<AuthToken>
58
- unpack: (token: string) => Promise<Auth>
59
- }
60
- ```
61
-
62
- **Methods:**
63
- - **`authenticate(token: AuthToken): Promise<AuthToken>`**: Validates and processes authentication token
64
- - **`unpack(token: string): Promise<Auth>`**: Unpacks and verifies authentication token to extract Auth object
65
-
66
- #### `AuthServiceAppend`
67
- Interface for contexts that provide authentication service access.
68
-
69
- ```typescript
70
- interface AuthServiceAppend {
71
- auth: () => AuthService
72
- }
73
- ```
74
-
75
- #### `AuthSpent`
76
- Interface for authentication cache records.
77
-
78
- ```typescript
79
- interface AuthSpent extends ResourceRecord {
80
- // Cache record for authentication state
81
- }
82
- ```
83
-
84
- ### Factory Functions
85
-
86
- #### `makeAuthService(alias?: string): AuthService`
87
-
88
- Creates a server authentication service instance with signature verification capabilities.
89
-
90
- **Parameters:**
91
- - `alias` (optional): Service alias (default: `DEFAULT_ALIAS`)
92
-
93
- **Returns:** AuthService instance
94
-
95
- **Features:**
96
- - Ed25519 signature verification
97
- - Token unpacking and validation
98
- - Cache integration for performance
99
- - Trusted entity authentication
100
-
101
- **Example:**
102
- ```typescript
103
- import { makeAuthService } from '@owlmeans/server-auth'
104
-
105
- const authService = makeAuthService('auth')
106
-
107
- // Use as a guard service
108
- const isAuthenticated = await authService.match(request)
109
- if (isAuthenticated) {
110
- const result = await authService.handle(request, response)
111
- }
112
-
113
- // Authenticate tokens
114
- const validatedToken = await authService.authenticate(authToken)
115
-
116
- // Unpack tokens to Auth objects
117
- const auth = await authService.unpack(bearerToken)
118
- ```
119
-
120
- ### Service Methods
121
-
122
- #### `match(req: AbstractRequest): Promise<boolean>`
123
-
124
- Checks if a request contains valid authentication token format.
125
-
126
- **Parameters:**
127
- - `req`: Request object to check for authentication
128
-
129
- **Returns:** Promise resolving to boolean indicating if auth token is present
130
-
131
- **Example:**
132
- ```typescript
133
- const hasAuth = await authService.match(req)
134
- if (hasAuth) {
135
- // Request has authentication token
136
- }
137
- ```
138
-
139
- #### `handle<T>(req: AbstractRequest, res: AbstractResponse<Auth>): Promise<T>`
140
-
141
- Processes authentication request and validates the token signature.
142
-
143
- **Parameters:**
144
- - `req`: Request object with authentication token
145
- - `res`: Response object to resolve with Auth data
146
-
147
- **Returns:** Promise resolving to boolean indicating success
148
-
149
- **Process:**
150
- 1. Extracts Ed25519 token from request
151
- 2. Creates envelope from token
152
- 3. Verifies signature against trusted entity
153
- 4. Resolves response with Auth object on success
154
-
155
- **Example:**
156
- ```typescript
157
- const success = await authService.handle(req, res)
158
- if (success) {
159
- // Authentication successful, Auth data available in res
160
- }
161
- ```
162
-
163
- #### `authenticate(token: AuthToken): Promise<AuthToken>`
164
-
165
- Validates and processes an authentication token.
166
-
167
- **Parameters:**
168
- - `token`: Authentication token to validate
169
-
170
- **Returns:** Promise resolving to validated AuthToken
171
-
172
- **Throws:** `AuthenFailed` if token validation fails
173
-
174
- **Example:**
175
- ```typescript
176
- try {
177
- const validToken = await authService.authenticate(userToken)
178
- // Token is valid and can be used
179
- } catch (error) {
180
- if (error instanceof AuthenFailed) {
181
- // Handle authentication failure
182
- }
183
- }
184
- ```
185
-
186
- #### `unpack(token: string): Promise<Auth>`
187
-
188
- Unpacks a bearer token string and extracts the Auth object.
189
-
190
- **Parameters:**
191
- - `token`: Bearer token string (e.g., "Bearer ed25519:...")
192
-
193
- **Returns:** Promise resolving to Auth object
194
-
195
- **Process:**
196
- 1. Splits bearer token to extract authorization part
197
- 2. Creates envelope from token
198
- 3. Verifies signature against trusted entity
199
- 4. Returns unpacked Auth object
200
-
201
- **Example:**
202
- ```typescript
203
- const bearerToken = "Bearer ed25519:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
204
- const auth = await authService.unpack(bearerToken)
205
-
206
- console.log(auth.userId) // Access user information
207
- console.log(auth.role) // Access user role
15
+ bun add @owlmeans/server-auth
208
16
  ```
209
17
 
210
- ### Constants
18
+ ## Usage
211
19
 
212
- #### Authentication Constants
20
+ Registered automatically by `makeContext()` from `@owlmeans/server-app`. To customize, pass `customize: true` and append manually:
213
21
 
214
22
  ```typescript
215
- const DEFAULT_ALIAS = 'auth' // Default service alias
216
- const AUTH_CACHE = 'auth-cache' // Cache resource name
217
- const AUTH_SRV_KEY = 'server-auth-key' // Server key identifier
218
- const AUTHEN_TIMEFRAME = 60 * 60 * 1000 // Authentication timeframe (1 hour)
219
- ```
220
-
221
- ### Modules
23
+ import { makeContext } from '@owlmeans/server-app'
24
+ import { appendAuthService, AUTH_CACHE } from '@owlmeans/server-auth'
222
25
 
223
- The package provides predefined authentication modules for server-side routing. These modules are automatically configured with proper validation schemas and authentication handlers.
26
+ const context = makeContext(appConfig, true) // skip default auth
224
27
 
225
- ```typescript
226
- import { modules } from '@owlmeans/server-auth'
227
-
228
- // Modules include server-side authentication endpoints
229
- // with proper request/response validation
28
+ // Append auth with custom config
29
+ appendAuthService(context)
230
30
  ```
231
31
 
232
- ## Usage Examples
233
-
234
- ### Basic Server Authentication Setup
32
+ Reference the guard by alias when protecting routes:
235
33
 
236
34
  ```typescript
237
- import { makeAuthService } from '@owlmeans/server-auth'
238
- import { makeServerContext } from '@owlmeans/server-context'
239
-
240
- // Create server context
241
- const context = makeServerContext({
242
- service: 'auth-server',
243
- type: AppType.Backend,
244
- layer: Layer.Service
245
- })
35
+ import { DAUTH_GUARD } from '@owlmeans/server-app'
36
+ // same as DEFAULT_ALIAS from @owlmeans/server-auth
246
37
 
247
- // Create and register authentication service
248
- const authService = makeAuthService('auth')
249
- context.registerService(authService)
250
-
251
- await context.configure().init()
252
-
253
- // Service is now available for authentication
38
+ const adminModule = module(route('admin', '/admin'), guard(DAUTH_GUARD))
254
39
  ```
255
40
 
256
- ### Using as Module Guard
41
+ ## API
257
42
 
258
- ```typescript
259
- import { guard } from '@owlmeans/module'
43
+ ### `appendAuthService<C, T>(context): void`
260
44
 
261
- // Create module with authentication guard
262
- const protectedModule = module(
263
- route('protected', '/api/protected'),
264
- guard('auth') // References the auth service
265
- )
45
+ Registers the Ed25519 auth service and its nonce cache resource into the context.
266
46
 
267
- // The auth service will automatically validate tokens for this module
268
- ```
47
+ ### `makeAuthService(alias?): AuthService`
269
48
 
270
- ### Manual Token Validation
49
+ Creates the auth service directly (used internally by `appendAuthService`).
271
50
 
272
- ```typescript
273
- const authService = makeAuthService()
51
+ ### `DEFAULT_ALIAS`
274
52
 
275
- // Validate incoming request
276
- const isValid = await authService.match(req)
277
- if (isValid) {
278
- const success = await authService.handle(req, res)
279
- if (success) {
280
- // Authentication successful
281
- const auth = res.value // Auth object
282
- console.log(`Authenticated user: ${auth.userId}`)
283
- }
284
- }
285
- ```
286
-
287
- ### Token Processing
53
+ The auth service alias: `'auth'`. Re-exported as `DAUTH_GUARD` from `@owlmeans/server-app`.
288
54
 
289
- ```typescript
290
- // Process authentication token
291
- try {
292
- const authToken = { token: 'user-auth-token' }
293
- const validatedToken = await authService.authenticate(authToken)
294
-
295
- // Token is now validated and can be used
296
- console.log('Token validated successfully')
297
- } catch (error) {
298
- console.error('Authentication failed:', error.message)
299
- }
300
- ```
55
+ ### `AUTH_CACHE`
301
56
 
302
- ### Bearer Token Unpacking
57
+ Resource alias for the nonce replay-prevention cache.
303
58
 
304
- ```typescript
305
- // Extract Auth from bearer token
306
- const bearerToken = req.headers.authorization // "Bearer ed25519:..."
307
-
308
- try {
309
- const auth = await authService.unpack(bearerToken)
310
-
311
- // Use Auth object
312
- console.log(`User: ${auth.userId}, Role: ${auth.role}`)
313
- console.log(`Scopes: ${auth.scopes.join(', ')}`)
314
- } catch (error) {
315
- console.error('Token unpacking failed:', error)
316
- }
317
- ```
318
-
319
- ### Integration with Express.js
320
-
321
- ```typescript
322
- import express from 'express'
323
-
324
- const app = express()
325
- const authService = makeAuthService()
326
-
327
- // Authentication middleware
328
- app.use(async (req, res, next) => {
329
- const hasAuth = await authService.match(req)
330
-
331
- if (hasAuth) {
332
- try {
333
- const authRes = { resolve: (auth) => { req.auth = auth } }
334
- await authService.handle(req, authRes)
335
- next()
336
- } catch (error) {
337
- res.status(401).json({ error: 'Authentication failed' })
338
- }
339
- } else {
340
- res.status(401).json({ error: 'No authentication provided' })
341
- }
342
- })
343
-
344
- // Protected routes
345
- app.get('/api/protected', (req, res) => {
346
- res.json({
347
- message: 'Access granted',
348
- user: req.auth.userId
349
- })
350
- })
351
- ```
352
-
353
- ### Cache Integration
354
-
355
- ```typescript
356
- // Service automatically uses cache for performance
357
- // Cache resource should be configured in context
358
-
359
- const context = makeServerContext({
360
- service: 'auth-app',
361
- // ... other config
362
- resources: [{
363
- alias: 'auth-cache',
364
- type: 'redis', // or other cache implementation
365
- config: {
366
- // cache configuration
367
- }
368
- }]
369
- })
370
-
371
- const authService = makeAuthService()
372
- context.registerService(authService)
373
-
374
- // Cache is automatically used for authentication state
375
- ```
59
+ ## Product-Viable Integration Notes
376
60
 
377
- ### Multi-Service Authentication
378
-
379
- ```typescript
380
- // Configure multiple auth services for different purposes
381
- const userAuthService = makeAuthService('user-auth')
382
- const serviceAuthService = makeAuthService('service-auth')
383
- const adminAuthService = makeAuthService('admin-auth')
384
-
385
- context.registerService(userAuthService)
386
- context.registerService(serviceAuthService)
387
- context.registerService(adminAuthService)
388
-
389
- // Use different services for different authentication needs
390
- const userAuth = await userAuthService.authenticate(userToken)
391
- const serviceAuth = await serviceAuthService.authenticate(serviceToken)
392
- ```
393
-
394
- ## Authentication Manager Application
395
-
396
- The package includes a complete authentication manager application for centralized authentication:
397
-
398
- ### Manager Features
399
-
400
- - **Central Authentication Hub**: Serves as authentication center for microservices
401
- - **Token Issuance**: Issues authentication tokens for validated users
402
- - **Multi-Service Support**: Handles authentication for multiple services
403
- - **Admin Interface**: Management interface for authentication configuration
404
-
405
- ### Manager Usage
406
-
407
- ```typescript
408
- // Located in src/manager - see manager/README.md for details
409
- import { authManager } from '@owlmeans/server-auth/manager'
410
-
411
- // The manager provides a complete authentication application
412
- // that can be deployed as a standalone service
413
- ```
414
-
415
- ## Security Considerations
416
-
417
- ### Token Security
418
- - All tokens use Ed25519 signatures for non-repudiable authentication
419
- - Tokens include expiration times to limit exposure windows
420
- - Signature verification prevents token tampering
421
-
422
- ### Trusted Entities
423
- - Authentication relies on trusted entity verification
424
- - Trusted entities must be properly configured and secured
425
- - Private keys should be stored securely and rotated regularly
426
-
427
- ### Cache Security
428
- - Authentication cache should be secured and encrypted
429
- - Cache entries should have appropriate TTL values
430
- - Cache should be cleared on security events
431
-
432
- ## Error Handling
433
-
434
- The package provides comprehensive error handling:
435
-
436
- - **AuthenFailed**: Authentication token validation failed
437
- - **AuthorizationError**: Authorization verification failed
438
- - **SyntaxError**: Configuration or context errors
439
-
440
- ```typescript
441
- try {
442
- const auth = await authService.unpack(token)
443
- } catch (error) {
444
- if (error instanceof AuthenFailed) {
445
- // Handle authentication failure
446
- } else if (error instanceof AuthorizationError) {
447
- // Handle authorization failure
448
- }
449
- }
450
- ```
451
-
452
- ## Performance Considerations
453
-
454
- - **Cache Integration**: Uses cache for frequently accessed authentication data
455
- - **Signature Verification**: Ed25519 operations are computationally efficient
456
- - **Token Reuse**: Validated tokens can be cached to avoid repeated verification
457
- - **Resource Management**: Proper cleanup of authentication resources
458
-
459
- ## Integration with OwlMeans Ecosystem
460
-
461
- This package integrates with:
462
-
463
- - **@owlmeans/auth-common**: Common authentication components
464
- - **@owlmeans/client-auth**: Client-side authentication
465
- - **@owlmeans/basic-envelope**: Cryptographic message envelopes
466
- - **@owlmeans/server-context**: Server context management
467
- - **@owlmeans/module**: Module guard system integration
468
-
469
- ## Best Practices
470
-
471
- 1. **Configure cache** for better authentication performance
472
- 2. **Use trusted entities** for secure signature verification
473
- 3. **Implement proper error handling** for authentication failures
474
- 4. **Set appropriate token TTL** values for security
475
- 5. **Monitor authentication logs** for security analysis
476
- 6. **Rotate trusted keys** regularly
61
+ - Register `appendAuthService(context)` before `appendAuthIdentityResources(context)` and product-specific gate services.
62
+ - Register `AUTH_CACHE` explicitly as a Redis resource when customizing the backend context.
63
+ - This package verifies bearer tokens and populates `request.auth`; authorization remains the job of module gates and handler-level entity checks.
64
+ - Pair it with `@owlmeans/server-auth-identity` when external provider login should produce durable local account/profile/credentials records.
477
65
 
478
66
  ## Related Packages
479
67
 
480
- - **@owlmeans/client-auth**: Client-side authentication
481
- - **@owlmeans/auth-common**: Common authentication components
482
- - **@owlmeans/server-context**: Server context management
483
- - **@owlmeans/basic-envelope**: Cryptographic envelopes
484
- - **@owlmeans/static-resource**: Resource management
485
-
486
- ## Manager Application
487
-
488
- For detailed information about the authentication manager application, see the [Manager README](src/manager/README.md).
489
-
490
- The manager provides a complete authentication service that can function as a central authentication hub for microservices architectures.
68
+ - [`@owlmeans/auth-common`](../auth-common) — `GUARD_ED25519` constant and auth modules
69
+ - [`@owlmeans/server-app`](../server-app) — `makeContext` calls `appendAuthService` by default
@@ -1,4 +1,4 @@
1
- import type { RefedModuleHandler } from '@owlmeans/server-module';
1
+ import type { RefedEntrypointHandler } from '@owlmeans/server-entrypoint';
2
2
  import type { AuthToken } from '@owlmeans/auth';
3
- export declare const authenticate: RefedModuleHandler<AuthToken>;
3
+ export declare const authenticate: RefedEntrypointHandler<AuthToken>;
4
4
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/actions/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAS/C,eAAO,MAAM,YAAY,EAAE,kBAAkB,CAAC,SAAS,CAKtD,CAAA"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/actions/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAS/C,eAAO,MAAM,YAAY,EAAE,sBAAsB,CAAC,SAAS,CAK1D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/actions/service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAKjD,MAAM,CAAC,MAAM,YAAY,GAAkC,UAAU,CACnE,KAAK,EAAE,OAAkB,EAAE,GAAG,EAAE,EAAE;IAChC,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,EAAE,cAAc,CAAY,CAAA;IAC7D,OAAO,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;AACnD,CAAC,CACF,CAAA"}
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/actions/service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAKjD,MAAM,CAAC,MAAM,YAAY,GAAsC,UAAU,CACvE,KAAK,EAAE,OAAkB,EAAE,GAAG,EAAE,EAAE;IAChC,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,EAAE,cAAc,CAAY,CAAA;IAC7D,OAAO,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;AACnD,CAAC,CACF,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import type { AllowanceRequest, AuthCredentials } from '@owlmeans/auth';
2
- import type { RefedModuleHandler } from '@owlmeans/server-module';
3
- export declare const authenticationInit: RefedModuleHandler<AllowanceRequest>;
4
- export declare const authenticate: RefedModuleHandler<AuthCredentials>;
5
- export declare const rely: RefedModuleHandler<void>;
2
+ import type { RefedEntrypointHandler } from '@owlmeans/server-entrypoint';
3
+ export declare const authenticationInit: RefedEntrypointHandler<AllowanceRequest>;
4
+ export declare const authenticate: RefedEntrypointHandler<AuthCredentials>;
5
+ export declare const rely: RefedEntrypointHandler<void>;
6
6
  //# sourceMappingURL=manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/manager/actions/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAIjE,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,CAAC,gBAAgB,CAGnE,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,kBAAkB,CAAC,eAAe,CAG5D,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAKzC,CAAA"}
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/manager/actions/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAIzE,eAAO,MAAM,kBAAkB,EAAE,sBAAsB,CAAC,gBAAgB,CAGvE,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,sBAAsB,CAAC,eAAe,CAGhE,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,sBAAsB,CAAC,IAAI,CAK7C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/manager/actions/manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAG3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D,MAAM,CAAC,MAAM,kBAAkB,GAAyC,UAAU,CAChF,KAAK,EAAE,OAAyB,EAAE,GAAG,EAAE,EAAE,CACvC,MAAM,aAAa,CAAC,GAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAClE,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAwC,UAAU,CACzE,KAAK,EAAE,OAAwB,EAAE,GAAG,EAAE,EAAE,CACtC,MAAM,aAAa,CAAC,GAA4B,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAC1E,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAA6B,gBAAgB;AAC5D,4DAA4D;AAC5D,+DAA+D;AAC/D,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CACvB,MAAM,aAAa,CAAC,GAA4B,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CACzE,CAAA"}
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/manager/actions/manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAG3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D,MAAM,CAAC,MAAM,kBAAkB,GAA6C,UAAU,CACpF,KAAK,EAAE,OAAyB,EAAE,GAAG,EAAE,EAAE,CACvC,MAAM,aAAa,CAAC,GAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAClE,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAA4C,UAAU,CAC7E,KAAK,EAAE,OAAwB,EAAE,GAAG,EAAE,EAAE,CACtC,MAAM,aAAa,CAAC,GAA4B,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAC1E,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAiC,gBAAgB;AAChE,4DAA4D;AAC5D,+DAA+D;AAC/D,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CACvB,MAAM,aAAa,CAAC,GAA4B,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CACzE,CAAA"}
@@ -4,11 +4,11 @@ export { addWebService } from '@owlmeans/client-config';
4
4
  export { service, TRUSTED } from '@owlmeans/config';
5
5
  export { AppType, assertContext } from '@owlmeans/context';
6
6
  export { klusterize } from '@owlmeans/kluster';
7
- export { elevate } from '@owlmeans/server-module';
8
- export { elevate as celevate, stab } from '@owlmeans/client-module';
9
- export type { RefedModuleHandler } from '@owlmeans/server-module';
7
+ export { elevate } from '@owlmeans/server-entrypoint';
8
+ export { elevate as celevate, stab } from '@owlmeans/client-entrypoint';
9
+ export type { RefedEntrypointHandler } from '@owlmeans/server-entrypoint';
10
10
  export { handleIntermediate, handleBody, handleRequest, handleParams } from '@owlmeans/server-api';
11
- export type { AbstractRequest, AbstractResponse } from '@owlmeans/module';
11
+ export type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint';
12
12
  export { backend } from '@owlmeans/route';
13
13
  export { AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT } from '@owlmeans/auth';
14
14
  export { GUARD_ED25519, BED255_CASHE_RESOURCE } from '@owlmeans/auth-common';
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/manager/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AACnE,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAClG,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/manager/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AACvE,YAAY,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAClG,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
@@ -3,8 +3,8 @@ export { addWebService } from '@owlmeans/client-config';
3
3
  export { service, TRUSTED } from '@owlmeans/config';
4
4
  export { AppType, assertContext } from '@owlmeans/context';
5
5
  export { klusterize } from '@owlmeans/kluster';
6
- export { elevate } from '@owlmeans/server-module';
7
- export { elevate as celevate, stab } from '@owlmeans/client-module';
6
+ export { elevate } from '@owlmeans/server-entrypoint';
7
+ export { elevate as celevate, stab } from '@owlmeans/client-entrypoint';
8
8
  export { handleIntermediate, handleBody, handleRequest, handleParams } from '@owlmeans/server-api';
9
9
  export { backend } from '@owlmeans/route';
10
10
  export { AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT } from '@owlmeans/auth';
@@ -1 +1 @@
1
- {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/manager/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAEnE,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAElG,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/manager/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAEvE,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAElG,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { modules } from './modules.js';
2
2
  export const main = async (ctx) => {
3
- ctx.registerModules(modules);
3
+ ctx.registerEntrypoints(modules);
4
4
  await ctx.configure().init();
5
5
  await ctx.getApiServer().listen();
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/manager/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EAAgD,GAAM,EAAE,EAAE;IACjF,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAC5B,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,CAAA;IAC5B,MAAM,GAAG,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,CAAA;AACnC,CAAC,CAAA"}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/manager/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EAAgD,GAAM,EAAE,EAAE;IACjF,GAAG,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;IAChC,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,CAAA;IAC5B,MAAM,GAAG,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,CAAA;AACnC,CAAC,CAAA"}
@@ -8,7 +8,7 @@ export const makeAuthModel = (context) => {
8
8
  const cache = (context) => context.resource(AUTH_CACHE);
9
9
  const model = {
10
10
  init: async (request) => {
11
- const plugin = getPlugin(request.type, context);
11
+ const plugin = await getPlugin(request.type, context);
12
12
  const response = await plugin.init(request);
13
13
  const envelope = makeEnvelopeModel(plugin.type);
14
14
  /**
@@ -43,7 +43,7 @@ export const makeAuthModel = (context) => {
43
43
  if (credential.userId == null) {
44
44
  throw new AuthenPayloadError('userId');
45
45
  }
46
- const plugin = getPlugin(envelope.type(), context);
46
+ const plugin = await getPlugin(envelope.type(), context);
47
47
  // @TODO this token PROBABLY needs to be registered somewhere and rechecked
48
48
  // from time to time to make sure that the session is not deleted
49
49
  // or permission hasn't changed.