@owlmeans/client-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.
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,526 +1,69 @@
1
1
  # @owlmeans/client-auth
2
2
 
3
- Client-side authentication library for OwlMeans Common applications. This package provides comprehensive authentication capabilities for React-based frontend applications, including token management, session persistence, and integration with the OwlMeans authentication subsystem.
3
+ Client-side authentication service providing user auth state and external auth flow setup.
4
4
 
5
5
  ## Overview
6
6
 
7
- The `@owlmeans/client-auth` package extends the base `@owlmeans/auth` and `@owlmeans/auth-common` packages with client-specific functionality. It provides:
8
-
9
- - **Token Management**: Secure storage and retrieval of authentication tokens
10
- - **Session Persistence**: Client-side session management across browser sessions
11
- - **Authentication Service**: Centralized authentication logic for client applications
12
- - **React Components**: Pre-built authentication UI components
13
- - **Module Integration**: Authentication modules for client-side routing and API calls
14
- - **Manager Components**: Authentication manager UI for administrative interfaces
15
-
16
- This package is part of the OwlMeans authentication quadra:
17
- - **@owlmeans/auth**: Common authentication declarations and utilities
18
- - **@owlmeans/auth-common**: Shared authentication logic
19
- - **@owlmeans/client-auth**: Client-side authentication implementation *(this package)*
20
- - **@owlmeans/server-auth**: Server-side authentication implementation
7
+ - `useSelfAuth()` React hook that returns the current authenticated user's `Auth` object
8
+ - `setupExternalAuthentication()` — configure the client to authenticate against an external identity provider
9
+ - `modules` pre-built client modules for the auth flow (login, dispatcher)
10
+ - `DEFAULT_ALIAS` the auth service alias (`'auth'`)
21
11
 
22
12
  ## Installation
23
13
 
24
14
  ```bash
25
- npm install @owlmeans/client-auth
26
- ```
27
-
28
- ## Core Concepts
29
-
30
- ### Authentication Service
31
- The authentication service manages the client-side authentication state, including token storage, validation, and user session management.
32
-
33
- ### Token Management
34
- Client-side tokens are securely stored using the resource system and automatically attached to API requests for authentication.
35
-
36
- ### Resource-based Storage
37
- Authentication data is persisted using the OwlMeans resource system, allowing for consistent data management across the application.
38
-
39
- ## API Reference
40
-
41
- ### Factory Functions
42
-
43
- #### `makeAuthService(alias?: string): AuthService`
44
-
45
- Creates a client-side authentication service instance.
46
-
47
- ```typescript
48
- import { makeAuthService } from '@owlmeans/client-auth'
49
-
50
- const authService = makeAuthService('main-auth')
51
- ```
52
-
53
- **Parameters:**
54
- - `alias`: string (optional) - Service alias for registration, defaults to 'auth'
55
-
56
- **Returns:** AuthService instance with client-specific capabilities
57
-
58
- ### Core Interfaces
59
-
60
- #### `AuthService`
61
-
62
- Main authentication service interface that extends the base AuthService from `@owlmeans/auth-common`.
63
-
64
- ```typescript
65
- interface AuthService extends InitializedService {
66
- token?: string
67
- auth?: Auth
68
-
69
- // Authentication methods
70
- authenticated(): Promise<string | null>
71
- authenticate(token: AuthToken): Promise<void>
72
- update(token?: string): Promise<void>
73
-
74
- // Guard and handler methods
75
- match(): Promise<boolean>
76
- handle<T>(): Promise<T | void>
77
- }
78
- ```
79
-
80
- #### `ClientAuthRecord`
81
-
82
- Interface for authentication data stored in client resources.
83
-
84
- ```typescript
85
- interface ClientAuthRecord extends ResourceRecord {
86
- token: string // Authentication token
87
- profileId?: string // Optional profile identifier
88
- }
89
- ```
90
-
91
- #### `ClientAuthResource`
92
-
93
- Resource interface for managing authentication data persistence.
94
-
95
- ```typescript
96
- interface ClientAuthResource extends ClientResource<ClientAuthRecord> {
97
- // Inherits standard resource methods for CRUD operations
98
- }
99
- ```
100
-
101
- #### `AuthServiceAppend`
102
-
103
- Interface for services that need authentication capabilities.
104
-
105
- ```typescript
106
- interface AuthServiceAppend {
107
- auth(): AuthService
108
- }
109
- ```
110
-
111
- ### Authentication Service Methods
112
-
113
- #### `authenticated(): Promise<string | null>`
114
-
115
- **Purpose**: Checks if the current session is authenticated and returns the auth token
116
-
117
- **Behavior**:
118
- - Checks for existing token in memory
119
- - Falls back to loading token from persistent storage
120
- - Validates token format and expiration
121
- - Returns null if no valid authentication found
122
-
123
- **Usage**: Primary method for checking authentication status
124
-
125
- **Returns**: Promise that resolves to auth token string or null
126
-
127
- ```typescript
128
- const authService = makeAuthService()
129
-
130
- const token = await authService.authenticated()
131
- if (token) {
132
- console.log('User is authenticated')
133
- } else {
134
- console.log('User needs to authenticate')
135
- }
15
+ bun add @owlmeans/client-auth
136
16
  ```
137
17
 
138
- #### `authenticate(token: AuthToken): Promise<void>`
139
-
140
- **Purpose**: Authenticates the user with the provided token
141
-
142
- **Behavior**:
143
- - Calls the authentication dispatcher module with the token
144
- - Stores the received authentication token
145
- - Updates the authentication state
146
- - Persists authentication data for future sessions
18
+ ## Usage
147
19
 
148
- **Usage**: Called after successful login to establish authentication
149
-
150
- **Parameters**:
151
- - `token`: AuthToken - Authentication token received from login process
152
-
153
- **Throws**: `AuthorizationError` if authentication fails
20
+ Access current auth state in a component:
154
21
 
155
22
  ```typescript
156
- try {
157
- await authService.authenticate(loginToken)
158
- console.log('Authentication successful')
159
- } catch (error) {
160
- console.error('Authentication failed:', error.message)
161
- }
162
- ```
163
-
164
- #### `update(token?: string): Promise<void>`
165
-
166
- **Purpose**: Updates the authentication state with a new token
167
-
168
- **Behavior**:
169
- - If token is provided, stores it and updates authentication state
170
- - If token is null/undefined, clears authentication state
171
- - Updates persistent storage accordingly
172
- - Parses token to extract Auth payload
173
-
174
- **Usage**: Called to refresh authentication or clear session
175
-
176
- **Parameters**:
177
- - `token`: string (optional) - New authentication token, or undefined to clear
178
-
179
- ```typescript
180
- // Update with new token
181
- await authService.update('Bearer new-auth-token')
182
-
183
- // Clear authentication
184
- await authService.update()
185
- ```
186
-
187
- #### `match(): Promise<boolean>`
23
+ import { useSelfAuth } from '@owlmeans/client-auth'
188
24
 
189
- **Purpose**: Guard method that checks if authentication requirements are met
190
-
191
- **Behavior**: Returns true if user is authenticated, false otherwise
192
-
193
- **Usage**: Used by routing and module systems for access control
194
-
195
- **Returns**: Promise that resolves to boolean indicating authentication status
196
-
197
- ```typescript
198
- const canAccess = await authService.match()
199
- if (canAccess) {
200
- // Allow access to protected resource
25
+ function UserMenu() {
26
+ const auth = useSelfAuth()
27
+ return <span>{auth?.userId}</span>
201
28
  }
202
29
  ```
203
30
 
204
- #### `handle<T>(): Promise<T | void>`
205
-
206
- **Purpose**: Handler method for processing authenticated requests
207
-
208
- **Behavior**: Currently returns undefined, can be extended for custom handling
209
-
210
- **Usage**: Used by module system for request processing
211
-
212
- **Returns**: Promise that resolves to undefined or custom result
213
-
214
- ### Module Functions
215
-
216
- #### `elevate(modules: ClientModule[], alias: string): void`
217
-
218
- Elevates authentication modules to client-side modules with enhanced capabilities.
219
-
220
- ```typescript
221
- import { elevate } from '@owlmeans/client-auth'
222
-
223
- elevate(authModules, 'dispatcher-auth')
224
- ```
225
-
226
- #### `setupExternalAuthentication(service: string): void`
227
-
228
- Configures external authentication flow for a specific service.
31
+ Set up external authentication (e.g. OIDC redirect):
229
32
 
230
33
  ```typescript
231
34
  import { setupExternalAuthentication } from '@owlmeans/client-auth'
232
35
 
233
- setupExternalAuthentication('oauth-provider')
36
+ // In context setup
37
+ setupExternalAuthentication(context, { serviceUrl: process.env.AUTH_URL })
234
38
  ```
235
39
 
236
- ### Constants
40
+ ## API
237
41
 
238
- #### Authentication Configuration
239
- ```typescript
240
- const DEFAULT_ALIAS = 'auth' // Default service alias
241
- const AUTH_RESOURCE = 'auth' // Resource identifier for auth data
242
- const USER_ID = 'user' // Default user identifier
243
- ```
42
+ ### `useSelfAuth(): Auth | null`
244
43
 
245
- ### Components
44
+ Returns the current `Auth` object from the context, or `null` if not authenticated.
246
45
 
247
- The package provides React components for authentication UI:
46
+ ### `setupExternalAuthentication(ctx, opts?)`
248
47
 
249
- #### Authentication Dispatcher
250
- Located in `./components/dispatcher`, provides components for handling authentication flows.
48
+ Configures the context to redirect to an external identity provider for authentication.
251
49
 
252
- #### Manager Components
253
- Located in `./manager/components`, provides administrative interfaces for authentication management.
50
+ ### `modules`
254
51
 
255
- **Import paths:**
256
- ```typescript
257
- import { /* components */ } from '@owlmeans/client-auth'
258
- import { /* manager components */ } from '@owlmeans/client-auth/manager'
259
- ```
260
-
261
- ### Manager Functionality
262
-
263
- The package includes a manager subsystem accessible via `/manager` export:
264
-
265
- ```typescript
266
- import { /* manager functions */ } from '@owlmeans/client-auth/manager'
267
- import { /* manager modules */ } from '@owlmeans/client-auth/manager/modules'
268
- import { /* manager plugins */ } from '@owlmeans/client-auth/manager/plugins'
269
- ```
270
-
271
- The manager provides:
272
- - Administrative authentication interfaces
273
- - User management components
274
- - Authentication flow configuration
275
- - Plugin system for extending authentication capabilities
276
-
277
- ## Usage Examples
278
-
279
- ### Basic Authentication Setup
280
-
281
- ```typescript
282
- import { makeAuthService } from '@owlmeans/client-auth'
283
- import { makeClientContext } from '@owlmeans/client-context'
284
-
285
- // Create context and auth service
286
- const context = makeClientContext(config)
287
- const authService = makeAuthService()
288
-
289
- // Register the service
290
- context.registerService(authService)
291
-
292
- // Initialize context
293
- await context.configure().init()
294
-
295
- // Check authentication status
296
- const isAuthenticated = await authService.authenticated()
297
- console.log('Authenticated:', isAuthenticated != null)
298
- ```
299
-
300
- ### Authentication Flow
301
-
302
- ```typescript
303
- import { makeAuthService } from '@owlmeans/client-auth'
304
-
305
- const authService = makeAuthService()
306
-
307
- // Authenticate with token from login
308
- const loginToken = { /* token from login process */ }
309
- try {
310
- await authService.authenticate(loginToken)
311
- console.log('Successfully authenticated')
312
- } catch (error) {
313
- console.error('Authentication failed:', error)
314
- }
315
-
316
- // Check authentication status
317
- const token = await authService.authenticated()
318
- if (token) {
319
- console.log('User is authenticated with token:', token)
320
- }
321
-
322
- // Clear authentication
323
- await authService.update()
324
- console.log('Authentication cleared')
325
- ```
326
-
327
- ### Module Integration
328
-
329
- ```typescript
330
- import { modules, setupExternalAuthentication } from '@owlmeans/client-auth'
331
- import { makeClientContext } from '@owlmeans/client-context'
332
-
333
- const context = makeClientContext(config)
334
-
335
- // Register authentication modules
336
- context.registerModules(modules)
337
-
338
- // Setup external authentication
339
- setupExternalAuthentication('google-oauth')
340
-
341
- // Initialize context
342
- await context.configure().init()
343
- ```
344
-
345
- ### Protected Resource Access
346
-
347
- ```typescript
348
- import { makeAuthService } from '@owlmeans/client-auth'
349
-
350
- const authService = makeAuthService()
351
-
352
- // Guard for protected resources
353
- const canAccess = await authService.match()
354
- if (!canAccess) {
355
- throw new Error('Authentication required')
356
- }
357
-
358
- // Access protected resource
359
- const protectedData = await api.getProtectedData()
360
- ```
361
-
362
- ### React Component Integration
363
-
364
- ```typescript
365
- import React from 'react'
366
- import { useContext } from 'react'
367
- import { makeAuthService } from '@owlmeans/client-auth'
368
-
369
- const AuthProvider = ({ children }) => {
370
- const authService = makeAuthService()
371
-
372
- const login = async (credentials) => {
373
- try {
374
- await authService.authenticate(credentials)
375
- // Redirect to dashboard
376
- } catch (error) {
377
- // Handle login error
378
- }
379
- }
380
-
381
- const logout = async () => {
382
- await authService.update() // Clear authentication
383
- // Redirect to login
384
- }
385
-
386
- return (
387
- <AuthContext.Provider value={{ authService, login, logout }}>
388
- {children}
389
- </AuthContext.Provider>
390
- )
391
- }
392
- ```
393
-
394
- ## Error Handling
395
-
396
- The package uses the OwlMeans error system and may throw the following errors:
397
-
398
- ### `AuthorizationError`
399
- Thrown when authentication fails or access is denied.
400
-
401
- ```typescript
402
- import { AuthorizationError } from '@owlmeans/auth'
403
-
404
- try {
405
- await authService.authenticate(invalidToken)
406
- } catch (error) {
407
- if (error instanceof AuthorizationError) {
408
- console.error('Authentication failed:', error.message)
409
- }
410
- }
411
- ```
412
-
413
- Common scenarios:
414
- - Invalid authentication token
415
- - Expired token
416
- - Insufficient permissions
417
- - Network errors during authentication
418
-
419
- ## Resource Management
420
-
421
- Authentication data is managed through the OwlMeans resource system:
422
-
423
- ```typescript
424
- // Access the auth resource directly
425
- const authResource = context.resource<ClientAuthResource>('auth')
426
-
427
- // Load stored authentication data
428
- const authRecord = await authResource.load('user')
429
-
430
- // Save authentication data
431
- await authResource.save({
432
- id: 'user',
433
- token: 'Bearer auth-token-here',
434
- profileId: 'user-profile-123'
435
- })
436
-
437
- // Clear authentication data
438
- await authResource.delete('user')
439
- ```
440
-
441
- ## Integration with Other Packages
442
-
443
- ### Authentication Quadra Integration
444
-
445
- ```typescript
446
- // Common authentication (shared)
447
- import { AuthRole, AuthenticationType } from '@owlmeans/auth'
448
-
449
- // Shared authentication logic
450
- import { authMiddleware } from '@owlmeans/auth-common'
451
-
452
- // Client authentication (this package)
453
- import { makeAuthService } from '@owlmeans/client-auth'
454
-
455
- // Server authentication (backend)
456
- import { makeServerAuthService } from '@owlmeans/server-auth'
457
- ```
458
-
459
- ### Context Integration
460
-
461
- ```typescript
462
- import { makeClientContext } from '@owlmeans/client-context'
463
- import { makeAuthService } from '@owlmeans/client-auth'
464
-
465
- const context = makeClientContext(config)
466
- const authService = makeAuthService()
467
-
468
- context.registerService(authService)
469
- ```
470
-
471
- ### Module Integration
472
-
473
- ```typescript
474
- import { modules } from '@owlmeans/client-auth'
475
- import { makeClientContext } from '@owlmeans/client-context'
476
-
477
- const context = makeClientContext(config)
478
- context.registerModules(modules)
479
- ```
480
-
481
- ### Flow Integration
482
-
483
- ```typescript
484
- import { makeAuthService } from '@owlmeans/client-auth'
485
- import { FlowService } from '@owlmeans/client-flow'
486
-
487
- // Authentication can be integrated with user flows
488
- const authService = makeAuthService()
489
- const flowService = context.service<FlowService>('flow')
490
-
491
- // Use authentication in flow steps
492
- await flowService.addStep('authenticate', async () => {
493
- const isAuth = await authService.authenticated()
494
- if (!isAuth) {
495
- throw new Error('Authentication required')
496
- }
497
- })
498
- ```
52
+ Pre-built `ClientModule[]` for the auth flow (mirrors `@owlmeans/auth-common`'s modules with client route models).
499
53
 
500
- ## Best Practices
54
+ ### `DEFAULT_ALIAS`
501
55
 
502
- 1. **Single Authentication Service**: Use one primary authentication service per application
503
- 2. **Context Registration**: Always register the authentication service with the application context
504
- 3. **Error Handling**: Implement proper error handling for authentication failures
505
- 4. **Token Security**: Let the service handle token storage and validation
506
- 5. **Module Integration**: Use provided modules for consistent authentication flows
507
- 6. **Manager Access**: Use manager components for administrative authentication features
56
+ Auth service alias: `'auth'`.
508
57
 
509
- ## Dependencies
58
+ ## Product-Viable Integration Notes
510
59
 
511
- This package depends on:
512
- - `@owlmeans/auth` - Core authentication types and constants
513
- - `@owlmeans/auth-common` - Shared authentication logic
514
- - `@owlmeans/client-context` - Client-side context management
515
- - `@owlmeans/client-module` - Client-side module system
516
- - `@owlmeans/client-resource` - Client-side resource management
517
- - `@owlmeans/basic-envelope` - Token envelope handling
518
- - `@owlmeans/context` - Core context system
60
+ - The manager web app imports `DEFAULT_ALIAS` from this package as the client-side guard alias.
61
+ - `@owlmeans/web-oidc-rp/auth/plugins` is imported for side effects to register the `OIDC_CLIENT_AUTH` and `GOOGLE_CLIENT_AUTH` plugins.
62
+ - Redirect plugins persist auth control state before leaving the app and restore it before submitting provider query params as `AuthCredentials`.
63
+ - After login, the browser stores a normal OwlMeans bearer token; product authorization is enforced by server gates and handler checks.
519
64
 
520
65
  ## Related Packages
521
66
 
522
- - [`@owlmeans/auth`](../auth) - Core authentication declarations
523
- - [`@owlmeans/auth-common`](../auth-common) - Shared authentication logic
524
- - [`@owlmeans/server-auth`](../server-auth) - Server-side authentication
525
- - [`@owlmeans/client-context`](../client-context) - Client context management
526
- - [`@owlmeans/client-module`](../client-module) - Client module system
67
+ - [`@owlmeans/auth`](../auth) `Auth` type returned by `useSelfAuth`
68
+ - [`@owlmeans/auth-common`](../auth-common) auth module route definitions
69
+ - [`@owlmeans/server-auth`](../server-auth) server-side counterpart
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2B,cAAc,EAAE,MAAM,YAAY,CAAA;AAczE,eAAO,MAAM,aAAa,EAAE,cAyE3B,CAAA"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2B,cAAc,EAAE,MAAM,YAAY,CAAA;AAczE,eAAO,MAAM,aAAa,EAAE,cA4E3B,CAAA"}
@@ -7,7 +7,7 @@ import { useNavigate } from '@owlmeans/client';
7
7
  import { DEFAULT_ALIAS as FLOW_SERVICE } from '@owlmeans/client-flow';
8
8
  import { FLOW_PLACEHOLDER, OidcAuthStep, STD_OIDC_FLOW } from '@owlmeans/flow';
9
9
  import { SERVICE_PARAM } from '@owlmeans/web-flow';
10
- export const DispatcherHOC = Renderer => ({ context, params, alias, query }) => {
10
+ export const DispatcherHOC = Renderer => ({ context, params, alias, query, payload }) => {
11
11
  const [forwarding, setForwarding] = useState();
12
12
  const navigator = useNavigate();
13
13
  const navigate = useCallback(async () => {
@@ -34,7 +34,7 @@ export const DispatcherHOC = Renderer => ({ context, params, alias, query }) =>
34
34
  // We do nothing if we are in the middle of a flow
35
35
  if (await flow.supplied) {
36
36
  const state = await flow.state();
37
- // If the flow we are in already has a targe, it means this is some flow
37
+ // If the flow we are in already has a target, it means this is some flow
38
38
  // that is really happening and we do not need to override it with our own.
39
39
  // It's MAY BE required on the auth manager service side, cause this
40
40
  // component is actually reused by both service and identity providers of OwlMeans.
@@ -47,6 +47,9 @@ export const DispatcherHOC = Renderer => ({ context, params, alias, query }) =>
47
47
  const target = (SERVICE_PARAM in params ? params[SERVICE_PARAM] : context.cfg.shortAlias);
48
48
  if (target != null) {
49
49
  model.target(target);
50
+ if (payload != null) {
51
+ model.updatePayload(payload);
52
+ }
50
53
  }
51
54
  else if (model.state().flow === STD_OIDC_FLOW) {
52
55
  const target = model.step().service;
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources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C,CAAC,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE;oBACpB,oCAAoC;oBACpC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;gBAClB,CAAC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;IAEvB,MAAM,YAAY,GAAG,WAAW,CAA0C,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACzF,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IACjC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,KAAC,QAAQ,IAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAA;AACrE,CAAC,CAAA"}
@@ -2,12 +2,14 @@ import type { FC, PropsWithChildren } from 'react';
2
2
  import type { RoutedComponent } from '@owlmeans/client';
3
3
  import type { AuthToken } from '@owlmeans/auth';
4
4
  import type { ClientContext, ClientConfig } from '@owlmeans/client-context';
5
- import type { AbstractRequest } from '@owlmeans/module';
5
+ import type { AbstractRequest } from '@owlmeans/entrypoint';
6
+ import type { FlowPayload } from '@owlmeans/flow';
6
7
  export interface DispatcherProps {
7
8
  alias: string;
8
9
  params: AbstractRequest['params'];
9
10
  query?: AbstractRequest['query'];
10
11
  context: ClientContext<ClientConfig>;
12
+ payload?: FlowPayload;
11
13
  }
12
14
  export interface TDispatcherHOC {
13
15
  (Renderer: DispatcherRenderer): RoutedComponent<DispatcherProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/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E,eAAe,CAAC,QAAQ,CAAC,CAAA;IACjC,KAAK,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAA;IAChC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,WAAW,CAAA;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,eAAe,CAAC,eAAe,CAAC,CAAA;CACjE;AAED,MAAM,WAAW,kBAAmB,SAAQ,EAAE,CAAC,uBAAuB,CAAC;CACtE;AAED,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAA;IAC3E,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9B"}
package/build/helper.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { ClientModule } from '@owlmeans/client-module';
2
- import type { AbstractRequest } from '@owlmeans/module';
3
- export declare const useWs: (module: string | ClientModule<any>, _request?: Partial<AbstractRequest<any>>) => import("@owlmeans/socket").Connection | null;
4
- export declare const useSelfAuth: (force?: boolean, entity?: string) => boolean;
1
+ import type { ClientEntrypoint } from '@owlmeans/client-entrypoint';
2
+ import type { AbstractRequest } from '@owlmeans/entrypoint';
3
+ export declare const useWs: (module: string | ClientEntrypoint<any>, _request?: Partial<AbstractRequest<any>>) => import("@owlmeans/socket").Connection | null;
4
+ export declare const useSelfAuth: (force?: boolean) => boolean;
5
5
  //# sourceMappingURL=helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AASvD,eAAO,MAAM,KAAK,GAChB,QAAQ,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,WAAW,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,iDA2B7E,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,QAAO,OAAc,EAAE,SAAQ,MAAuB,YAkBjF,CAAA"}
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAGnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAS3D,eAAO,MAAM,KAAK,GAChB,QAAQ,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,EAAE,WAAW,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,iDA2BjF,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,QAAO,OAAc,YAoBhD,CAAA"}