vuethenticate 0.1.7 → 0.1.9

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/README.md CHANGED
@@ -217,6 +217,8 @@ The main composable for authentication state management.
217
217
  | `automaticSilentRenew` | `boolean` | | `true` | Enable automatic token refresh |
218
218
  | `silentRedirectUri` | `string` | | `${origin}/auth/silent-callback` | Silent refresh callback URL |
219
219
  | `postLogoutRedirectUri` | `string` | | `${origin}` | Post-logout redirect URL |
220
+ | `logLevel` | `LogLevel` | | `LogLevel.NONE` | Logging level for debug information |
221
+ | `logger` | `Logger` | | `silentLogger` | Custom logger implementation |
220
222
 
221
223
  #### Event Callbacks
222
224
 
@@ -367,6 +369,257 @@ function handleSilentError(error) {
367
369
 
368
370
  > **Note**: This component is primarily used in an iframe or popup for silent token renewal. It should be placed on a minimal page with no other content.
369
371
 
372
+ ## Logging and Debugging
373
+
374
+ Vuethenticate provides comprehensive logging capabilities to help debug authentication flows and monitor authentication events. The logging system supports both internal library logging and configurable `oidc-client-ts` debug output.
375
+
376
+ ### Log Levels
377
+
378
+ ```typescript
379
+ import { LogLevel } from 'vuethenticate';
380
+
381
+ enum LogLevel {
382
+ NONE = 0, // No logging
383
+ ERROR = 1, // Only errors
384
+ WARN = 2, // Warnings and errors
385
+ INFO = 3, // Info, warnings, and errors
386
+ DEBUG = 4, // All messages including debug info
387
+ }
388
+ ```
389
+
390
+ ### Basic Logging Setup
391
+
392
+ ```typescript
393
+ import { useAuth, LogLevel, consoleLogger } from 'vuethenticate';
394
+
395
+ // Enable debug logging with console output
396
+ const auth = useAuth({
397
+ authority: 'https://your-oidc-provider.com',
398
+ clientId: 'your-client-id',
399
+ logLevel: LogLevel.DEBUG,
400
+ logger: consoleLogger
401
+ });
402
+ ```
403
+
404
+ ### Custom Logger Implementation
405
+
406
+ ```typescript
407
+ import { useAuth, LogLevel, type Logger } from 'vuethenticate';
408
+
409
+ const customLogger: Logger = {
410
+ error: (message: string, ...args: unknown[]) => {
411
+ // Send to your error tracking service
412
+ console.error('[AUTH ERROR]', message, ...args);
413
+ // Sentry.captureException(new Error(message));
414
+ },
415
+ warn: (message: string, ...args: unknown[]) => {
416
+ console.warn('[AUTH WARN]', message, ...args);
417
+ },
418
+ info: (message: string, ...args: unknown[]) => {
419
+ console.info('[AUTH INFO]', message, ...args);
420
+ },
421
+ debug: (message: string, ...args: unknown[]) => {
422
+ if (process.env.NODE_ENV === 'development') {
423
+ console.debug('[AUTH DEBUG]', message, ...args);
424
+ }
425
+ },
426
+ };
427
+
428
+ const auth = useAuth({
429
+ authority: 'https://your-oidc-provider.com',
430
+ clientId: 'your-client-id',
431
+ logLevel: LogLevel.INFO,
432
+ logger: customLogger
433
+ });
434
+ ```
435
+
436
+ ### Environment-Based Logging
437
+
438
+ ```typescript
439
+ import { useAuth, LogLevel, consoleLogger } from 'vuethenticate';
440
+
441
+ const getLogConfig = () => {
442
+ switch (process.env.NODE_ENV) {
443
+ case 'development':
444
+ return { logLevel: LogLevel.DEBUG, logger: consoleLogger };
445
+ case 'test':
446
+ return { logLevel: LogLevel.NONE };
447
+ case 'production':
448
+ return { logLevel: LogLevel.ERROR, logger: productionLogger };
449
+ default:
450
+ return { logLevel: LogLevel.WARN, logger: consoleLogger };
451
+ }
452
+ };
453
+
454
+ const auth = useAuth({
455
+ authority: 'https://your-oidc-provider.com',
456
+ clientId: 'your-client-id',
457
+ ...getLogConfig()
458
+ });
459
+ ```
460
+
461
+ ### Available Loggers
462
+
463
+ #### `consoleLogger`
464
+ Standard console output logger suitable for development.
465
+
466
+ #### `silentLogger`
467
+ No-op logger that suppresses all output (default when no logger is specified).
468
+
469
+ #### `createLevelLogger(baseLogger, level)`
470
+ Creates a filtered logger that only outputs messages at or above the specified level.
471
+
472
+ ```typescript
473
+ import { createLevelLogger, consoleLogger, LogLevel } from 'vuethenticate';
474
+
475
+ const warnOnlyLogger = createLevelLogger(consoleLogger, LogLevel.WARN);
476
+ ```
477
+
478
+ ### What Gets Logged
479
+
480
+ When logging is enabled, you'll see output for:
481
+
482
+ - **Authentication initialization** - Setup and configuration validation
483
+ - **Token operations** - Token acquisition, renewal, and expiration
484
+ - **User state changes** - Login, logout, and user profile updates
485
+ - **Silent renewal** - Background token refresh attempts
486
+ - **OIDC protocol flows** - Detailed protocol-level debugging (when DEBUG level)
487
+ - **Error conditions** - All authentication-related errors with context
488
+
489
+ ### OIDC Client Debug Logs
490
+
491
+ The underlying `oidc-client-ts` library has extensive debug logging. When you configure logging in Vuethenticate, it automatically configures the OIDC client logging as well, so you'll see detailed protocol-level information including:
492
+
493
+ - HTTP requests and responses
494
+ - Token validation steps
495
+ - Silent renewal iframe operations
496
+ - OIDC discovery document processing
497
+
498
+ ### Production Considerations
499
+
500
+ For production environments, consider:
501
+
502
+ - Setting `logLevel` to `LogLevel.ERROR` or `LogLevel.NONE`
503
+ - Using a custom logger that sends errors to your monitoring service
504
+ - Avoiding debug-level logging to prevent performance impact
505
+ - Implementing log sampling for high-traffic applications
506
+
507
+ ```typescript
508
+ // Production-safe logging configuration
509
+ const auth = useAuth({
510
+ authority: 'https://your-oidc-provider.com',
511
+ clientId: 'your-client-id',
512
+ logLevel: LogLevel.ERROR,
513
+ logger: {
514
+ error: (message, ...args) => {
515
+ // Send to monitoring service
516
+ monitoringService.error(message, args);
517
+ },
518
+ warn: () => {}, // Suppress in production
519
+ info: () => {}, // Suppress in production
520
+ debug: () => {}, // Suppress in production
521
+ }
522
+ });
523
+ ```
524
+
525
+ ## Logging
526
+
527
+ Vuethenticate provides comprehensive logging support for debugging authentication flows and OIDC protocol interactions. **Logging is silent by default** - you must explicitly configure it to see output.
528
+
529
+ ### Configuration
530
+
531
+ Add logging configuration to your auth config:
532
+
533
+ ```typescript
534
+ import { useAuth, LogLevel, consoleLogger } from 'vuethenticate'
535
+
536
+ const auth = useAuth({
537
+ authority: 'https://your-oidc-provider.com',
538
+ clientId: 'your-client-id',
539
+
540
+ // Enable debug logging
541
+ logLevel: LogLevel.DEBUG,
542
+ // logger: consoleLogger, // Optional: defaults to console when logLevel is set
543
+ })
544
+ ```
545
+
546
+ ### Log Levels
547
+
548
+ | Level | Value | Description |
549
+ |-------|-------|-------------|
550
+ | `LogLevel.NONE` | 0 | No logging (default) |
551
+ | `LogLevel.ERROR` | 1 | Error messages only |
552
+ | `LogLevel.WARN` | 2 | Warnings and errors |
553
+ | `LogLevel.INFO` | 3 | Info, warnings, and errors |
554
+ | `LogLevel.DEBUG` | 4 | All messages including debug info |
555
+
556
+ ### Built-in Loggers
557
+
558
+ | Logger | Description |
559
+ |--------|-------------|
560
+ | `consoleLogger` | Logs to browser console (used automatically when logLevel is set) |
561
+ | `silentLogger` | No output - useful for explicitly disabling logs |
562
+
563
+ ### Behavior
564
+
565
+ - **Silent by default**: No logging occurs unless explicitly configured
566
+ - **Smart defaults**: When you set a `logLevel`, `consoleLogger` is used automatically
567
+ - **Custom loggers**: Provide your own `logger` for custom logging behavior
568
+ - **OIDC integration**: Both internal auth logs and underlying OIDC client logs are controlled by the same configuration
569
+
570
+ ### Custom Logger
571
+
572
+ Implement the `Logger` interface for custom logging:
573
+
574
+ ```typescript
575
+ import type { Logger } from 'vuethenticate'
576
+
577
+ const customLogger: Logger = {
578
+ error: (message, ...args) => {
579
+ // Send to error reporting service
580
+ errorService.log(message, args)
581
+ },
582
+ warn: (message, ...args) => console.warn(message, ...args),
583
+ info: (message, ...args) => console.info(message, ...args),
584
+ debug: (message, ...args) => {
585
+ if (process.env.NODE_ENV === 'development') {
586
+ console.debug(message, ...args)
587
+ }
588
+ },
589
+ }
590
+
591
+ const auth = useAuth({
592
+ authority: 'https://your-oidc-provider.com',
593
+ clientId: 'your-client-id',
594
+ logLevel: LogLevel.INFO,
595
+ logger: customLogger,
596
+ })
597
+ ```
598
+
599
+ ### What Gets Logged
600
+
601
+ With logging enabled, you'll see detailed information about:
602
+
603
+ - **Authentication flows**: Sign-in, sign-out, and callback processing
604
+ - **Token management**: Token refresh, expiration, and renewal
605
+ - **OIDC protocol**: Requests, responses, and protocol-level details
606
+ - **Error handling**: Detailed error information with stack traces
607
+ - **State management**: User loading/unloading events
608
+
609
+ ### Development vs Production
610
+
611
+ ```typescript
612
+ const auth = useAuth({
613
+ authority: 'https://your-oidc-provider.com',
614
+ clientId: 'your-client-id',
615
+
616
+ // Enable detailed logging only in development
617
+ logLevel: process.env.NODE_ENV === 'development'
618
+ ? LogLevel.DEBUG
619
+ : LogLevel.ERROR,
620
+ })
621
+ ```
622
+
370
623
  ## Advanced Usage
371
624
 
372
625
  ### Manual Cleanup
@@ -1 +1 @@
1
- {"version":3,"file":"AuthCallback.vue.d.ts","sourceRoot":"","sources":["../../src/components/AuthCallback.vue"],"names":[],"mappings":"AAgBA;AAyEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;yBAG1B,MAAM,GAAG,OAAO,EAChC,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,eAAe,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EACjE;WAiHO,mBAAmB,CAAC;;;uLAAkE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;yBAhCkB,GAAG;;;YACL,GAAG;;;EAmC1B,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AA5HzE,wBA4H4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"AuthCallback.vue.d.ts","sourceRoot":"","sources":["../../src/components/AuthCallback.vue"],"names":[],"mappings":"AAgBA;AAmFA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;yBAG1B,MAAM,GAAG,OAAO,EAChC,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,eAAe,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EACjE;WA2HO,mBAAmB,CAAC;;;uLAAkE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;yBAhCkB,GAAG;;;YACL,GAAG;;;EAmC1B,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AAtIzE,wBAsI4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"LogoutCallback.vue.d.ts","sourceRoot":"","sources":["../../src/components/LogoutCallback.vue"],"names":[],"mappings":"AAyBA;AAiFA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;yBAGxC,MAAM,GAAG,OAAO,EAChC,aAAa,WAAW,C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ACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;yBAjCkB,GAAG;;;YACL,GAAG;yBACD,GAAG;;;EAmC5B,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AAlJzE,wBAkJ4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SilentCallback.vue.d.ts","sourceRoot":"","sources":["../../src/components/SilentCallback.vue"],"names":[],"mappings":"AAaA;AA6DA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AA6CzD,iBAAS,cAAc;WAiCT,OAAO,IAA6B;;yBAXrB,GAAG;;;YACL,GAAG;;;;EAe7B;AAUD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe,kTAMnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAQpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"SilentCallback.vue.d.ts","sourceRoot":"","sources":["../../src/components/SilentCallback.vue"],"names":[],"mappings":"AAaA;AAiEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAiDzD,iBAAS,cAAc;WAiCT,OAAO,IAA6B;;yBAXrB,GAAG;;;YACL,GAAG;;;;EAe7B;AAUD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe,kTAMnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAQpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -1,6 +1,4 @@
1
- import { AuthConfig, UseAuthReturn } from '../types/auth';
2
- import { Ref } from 'vue';
3
- import { User } from 'oidc-client-ts';
1
+ import { AuthConfig, UseAuthCallbacksReturn, UseAuthReturn } from '../types/auth';
4
2
  /**
5
3
  * Vue composable for authentication state management using OIDC
6
4
  * @param config - Authentication configuration
@@ -12,16 +10,5 @@ export declare const useAuth: <TState = unknown>(config: AuthConfig) => UseAuthR
12
10
  * Automatically finds the active UserManager instance and waits for initialization
13
11
  * @returns Callback processing methods and initialization state
14
12
  */
15
- export declare const useAuthCallbacks: <TState = unknown>() => {
16
- processCallback: () => Promise<{
17
- user: User;
18
- state?: TState;
19
- }>;
20
- processLogoutCallback: () => Promise<{
21
- state?: TState;
22
- }>;
23
- processSilentCallback: () => Promise<void>;
24
- isInitialized: Ref<boolean, boolean>;
25
- isInitializing: Ref<boolean, boolean>;
26
- };
13
+ export declare const useAuthCallbacks: <TState = unknown>() => UseAuthCallbacksReturn<TState>;
27
14
  //# sourceMappingURL=useAuth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/composables/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAoB,KAAK,GAAG,EAAwB,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,KAAK,IAAI,EAAe,MAAM,gBAAgB,CAAC;AAwNxD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,GAAG,OAAO,EACpC,QAAQ,UAAU,KACnB,aAAa,CAAC,MAAM,CAsNtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,GAAG,OAAO;2BAaX,OAAO,CAAC;QACtC,IAAI,EAAE,IAAI,CAAC;QACX,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;iCAkBsC,OAAO,CAAC;QAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;iCAYsC,OAAO,CAAC,IAAI,CAAC;;;CAaxD,CAAC"}
1
+ {"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/composables/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,UAAU,EACV,sBAAsB,EACtB,aAAa,EAChB,MAAM,eAAe,CAAC;AAmRvB;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,GAAG,OAAO,EACpC,QAAQ,UAAU,KACnB,aAAa,CAAC,MAAM,CA+OtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GACzB,MAAM,GAAG,OAAO,OACf,sBAAsB,CAAC,MAAM,CAgFjC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { useAuth } from './composables/useAuth';
2
2
  export { AuthCallback, LogoutCallback, SilentCallback } from './components';
3
- export type { AuthConfig, AuthState, AuthMethods, AuthCallbackMethods, UseAuthReturn, AuthCallbackProps, SilentCallbackProps, LogoutCallbackProps, User, } from './types/auth';
3
+ export { LogLevel, type Logger, consoleLogger, silentLogger, } from './utils/logger';
4
+ export type { AuthConfig, AuthState, AuthMethods, AuthCallbackMethods, UseAuthReturn, UseAuthCallbacksReturn, AuthCallbackProps, SilentCallbackProps, LogoutCallbackProps, User, } from './types/auth';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG5E,YAAY,EACR,UAAU,EACV,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,IAAI,GACP,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG5E,OAAO,EACH,QAAQ,EACR,KAAK,MAAM,EACX,aAAa,EACb,YAAY,GACf,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACR,UAAU,EACV,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,IAAI,GACP,MAAM,cAAc,CAAC"}
package/dist/index.esm.js CHANGED
@@ -1,8 +1,33 @@
1
- import { ref as m, computed as I, watch as W, defineComponent as M, onMounted as T, createElementBlock as F, openBlock as P, Fragment as K, renderSlot as S, createCommentVNode as U, unref as L, createElementVNode as y, toDisplayString as x } from "vue";
2
- import { WebStorageStateStore as Y, UserManager as j } from "oidc-client-ts";
3
- function G(e) {
1
+ import { ref as y, computed as N, watch as j, defineComponent as V, onMounted as z, createElementBlock as _, openBlock as W, Fragment as B, renderSlot as S, createCommentVNode as I, unref as M, createElementVNode as v, toDisplayString as x } from "vue";
2
+ import { WebStorageStateStore as H, Log as E, UserManager as J } from "oidc-client-ts";
3
+ var f = /* @__PURE__ */ ((e) => (e[e.NONE = 0] = "NONE", e[e.ERROR = 1] = "ERROR", e[e.WARN = 2] = "WARN", e[e.INFO = 3] = "INFO", e[e.DEBUG = 4] = "DEBUG", e))(f || {});
4
+ const D = {
5
+ error: (e, ...t) => console.error(e, ...t),
6
+ warn: (e, ...t) => console.warn(e, ...t),
7
+ info: (e, ...t) => console.info(e, ...t),
8
+ debug: (e, ...t) => console.debug(e, ...t)
9
+ }, Q = {
10
+ error: () => {
11
+ },
12
+ warn: () => {
13
+ },
14
+ info: () => {
15
+ },
16
+ debug: () => {
17
+ }
18
+ }, X = (e, t) => ({
19
+ error: t >= 1 ? e.error : () => {
20
+ },
21
+ warn: t >= 2 ? e.warn : () => {
22
+ },
23
+ info: t >= 3 ? e.info : () => {
24
+ },
25
+ debug: t >= 4 ? e.debug : () => {
26
+ }
27
+ });
28
+ function Z(e) {
4
29
  const t = typeof window < "u" ? window.location.origin : "";
5
- return {
30
+ return te(e), {
6
31
  authority: e.authority,
7
32
  client_id: e.clientId,
8
33
  client_secret: e.clientSecret,
@@ -10,7 +35,7 @@ function G(e) {
10
35
  redirect_uri: e.redirectUri ?? `${t}/auth/callback`,
11
36
  scope: e.scope ?? "openid profile",
12
37
  response_type: e.responseType ?? "code",
13
- userStore: e.storage ? new Y({ store: H(e.storage) }) : void 0,
38
+ userStore: e.storage ? new H({ store: ee(e.storage) }) : void 0,
14
39
  automaticSilentRenew: e.automaticSilentRenew ?? !0,
15
40
  silent_redirect_uri: e.silentRedirectUri ?? `${t}/auth/silent-callback`,
16
41
  post_logout_redirect_uri: e.postLogoutRedirectUri ?? `${t}/auth/logout-callback`,
@@ -18,21 +43,21 @@ function G(e) {
18
43
  accessTokenExpiringNotificationTimeInSeconds: 60
19
44
  };
20
45
  }
21
- function H(e) {
46
+ function ee(e) {
22
47
  if (typeof window > "u")
23
- return _();
48
+ return P();
24
49
  switch (e) {
25
50
  case "localStorage":
26
51
  return window.localStorage;
27
52
  case "sessionStorage":
28
53
  return window.sessionStorage;
29
54
  case "memory":
30
- return _();
55
+ return P();
31
56
  default:
32
57
  return window.localStorage;
33
58
  }
34
59
  }
35
- function _() {
60
+ function P() {
36
61
  const e = /* @__PURE__ */ new Map();
37
62
  return {
38
63
  getItem: (t) => e.get(t) ?? null,
@@ -45,7 +70,32 @@ function _() {
45
70
  key: (t) => Array.from(e.keys())[t] ?? null
46
71
  };
47
72
  }
48
- const h = /* @__PURE__ */ new Map(), J = (e) => {
73
+ const te = (e) => {
74
+ if (e.logLevel === void 0 && !e.logger)
75
+ return;
76
+ const t = e.logger ?? (e.logLevel !== void 0 ? D : void 0), r = e.logLevel ?? f.NONE;
77
+ t && (E.setLogger({
78
+ error: t.error,
79
+ warn: t.warn,
80
+ info: t.info,
81
+ debug: t.debug
82
+ }), E.setLevel(re(r)));
83
+ }, re = (e) => {
84
+ switch (e) {
85
+ case f.NONE:
86
+ return E.NONE;
87
+ case f.ERROR:
88
+ return E.ERROR;
89
+ case f.WARN:
90
+ return E.WARN;
91
+ case f.INFO:
92
+ return E.INFO;
93
+ case f.DEBUG:
94
+ return E.DEBUG;
95
+ default:
96
+ return E.NONE;
97
+ }
98
+ }, A = /* @__PURE__ */ new Map(), ne = (e) => {
49
99
  try {
50
100
  const { userManager: t, eventCallbacks: r } = e;
51
101
  r.userLoaded && t.events.removeUserLoaded(r.userLoaded), r.userUnloaded && t.events.removeUserUnloaded(r.userUnloaded), r.accessTokenExpired && t.events.removeAccessTokenExpired(
@@ -58,38 +108,44 @@ const h = /* @__PURE__ */ new Map(), J = (e) => {
58
108
  } catch (t) {
59
109
  console.warn("Error during UserManager cleanup:", t);
60
110
  }
61
- }, N = (e) => `${e.authority}_${e.clientId}`, Q = () => h.size === 0 ? null : (h.size === 1 || console.warn(
111
+ }, G = (e) => `${e.authority}_${e.clientId}`, ae = () => A.size === 0 ? null : (A.size === 1 || console.warn(
62
112
  "Multiple auth instances detected. Callback components may not work as expected. Consider using a single auth instance or specify config explicitly."
63
- ), Array.from(h.values())[0] || null), X = (e) => {
64
- const t = N(e), r = h.get(t);
113
+ ), Array.from(A.values())[0] || null), le = (e) => {
114
+ const t = G(e), r = A.get(t);
65
115
  if (r)
66
116
  return r;
67
- const o = Z(e), n = m(!1), c = m(!1), s = m(null), a = m(!1), p = m(null), d = I(() => !!s.value && !s.value.expired), l = I(() => {
68
- var E;
69
- return ((E = s.value) == null ? void 0 : E.access_token) || null;
70
- }), u = I(() => {
71
- var E;
72
- return !!((E = s.value) != null && E.expired);
73
- }), k = {
74
- userManager: o,
117
+ const s = se(e), n = y(!1), c = y(!1), a = y(null), l = y(!1), o = y(null), b = N(() => !!a.value && !a.value.expired), g = N(() => {
118
+ var m;
119
+ return ((m = a.value) == null ? void 0 : m.access_token) || null;
120
+ }), i = N(() => {
121
+ var m;
122
+ return !!((m = a.value) != null && m.expired);
123
+ }), d = oe(e), k = {
124
+ userManager: s,
75
125
  isInitialized: n,
76
126
  isInitializing: c,
77
- user: s,
78
- isLoading: a,
79
- error: p,
80
- isAuthenticated: d,
81
- accessToken: l,
82
- isExpired: u,
127
+ user: a,
128
+ isLoading: l,
129
+ error: o,
130
+ isAuthenticated: b,
131
+ accessToken: g,
132
+ isExpired: i,
133
+ logger: d,
83
134
  eventCallbacks: {}
84
135
  };
85
- return h.set(t, k), k;
86
- }, Z = (e) => {
87
- const t = G(e);
88
- return new j(t);
89
- }, b = (e, t, r, o) => {
136
+ return A.set(t, k), k;
137
+ }, se = (e) => {
138
+ const t = Z(e);
139
+ return new J(t);
140
+ }, oe = (e) => {
141
+ if (!e.logger && !e.logLevel)
142
+ return Q;
143
+ const t = e.logger ?? D, r = e.logLevel ?? f.NONE;
144
+ return X(t, r);
145
+ }, U = (e, t, r, s) => {
90
146
  const n = e instanceof Error ? e : new Error(t);
91
- return r.value = n, o == null || o(n), n;
92
- }, ee = (e) => {
147
+ return r.value = n, s == null || s(n), n;
148
+ }, ie = (e) => {
93
149
  var t, r;
94
150
  if (!((t = e.authority) != null && t.trim()))
95
151
  throw new Error("AuthConfig: authority is required");
@@ -100,175 +156,202 @@ const h = /* @__PURE__ */ new Map(), J = (e) => {
100
156
  } catch {
101
157
  throw new Error("AuthConfig: authority must be a valid URL");
102
158
  }
103
- }, z = async (e, t = 1e4) => {
159
+ }, T = async (e, t = 1e4) => {
104
160
  if (!e.isInitialized.value)
105
- return new Promise((r, o) => {
161
+ return new Promise((r, s) => {
106
162
  const n = setTimeout(() => {
107
- o(new Error("Authentication initialization timeout"));
108
- }, t), c = W(
163
+ s(new Error("Authentication initialization timeout"));
164
+ }, t), c = j(
109
165
  e.isInitialized,
110
- (s) => {
111
- s && (clearTimeout(n), c(), r());
166
+ (a) => {
167
+ a && (clearTimeout(n), c(), r());
112
168
  },
113
169
  { immediate: !0 }
114
170
  );
115
171
  });
116
- }, ne = (e) => {
117
- ee(e);
118
- const t = X(e), {
172
+ }, ue = (e) => {
173
+ const t = window.location.href;
174
+ return !!(e.silentRedirectUri && t.startsWith(e.silentRedirectUri) || e.redirectUri && t.startsWith(e.redirectUri) || e.postLogoutRedirectUri && t.startsWith(e.postLogoutRedirectUri));
175
+ }, ge = (e) => {
176
+ ie(e);
177
+ const t = le(e), {
119
178
  userManager: r,
120
- isInitialized: o,
179
+ isInitialized: s,
121
180
  isInitializing: n,
122
181
  user: c,
123
- isLoading: s,
124
- error: a,
125
- isAuthenticated: p,
126
- accessToken: d,
127
- isExpired: l
128
- } = t, u = N(e), k = async () => {
129
- if (!(n.value || o.value))
182
+ isLoading: a,
183
+ error: l,
184
+ isAuthenticated: o,
185
+ accessToken: b,
186
+ isExpired: g
187
+ } = t, i = G(e), d = async () => {
188
+ if (!(n.value || s.value))
130
189
  try {
131
- n.value = !0, s.value = !0, a.value = null;
132
- const v = await r.getUser();
133
- if (v)
134
- if (!v.expired)
135
- c.value = v;
136
- else if (e.automaticSilentRenew !== !1)
190
+ n.value = !0, a.value = !0, l.value = null;
191
+ const h = await r.getUser();
192
+ if (h)
193
+ if (!h.expired)
194
+ c.value = h, t.logger.info(
195
+ "[Vuethenticate] useAuth: User restored from storage"
196
+ );
197
+ else if (e.automaticSilentRenew !== !1) {
198
+ t.logger.info(
199
+ "[Vuethenticate] useAuth: Token expired, attempting silent renewal"
200
+ );
137
201
  try {
138
202
  await $();
139
- } catch (i) {
140
- console.warn(
141
- "Silent renewal failed during initialization:",
142
- i
203
+ } catch (u) {
204
+ t.logger.warn(
205
+ "[Vuethenticate] useAuth: Silent renewal failed during initialization",
206
+ u
143
207
  ), await r.removeUser(), c.value = null;
144
208
  }
145
- else
209
+ } else
146
210
  await r.removeUser(), c.value = null;
147
- } catch (v) {
148
- b(
149
- v,
150
- "Failed to initialize authentication",
151
- a,
211
+ s.value = !0;
212
+ } catch (h) {
213
+ t.logger.error(
214
+ "[Vuethenticate] useAuth: Initialization failed",
215
+ h
216
+ ), U(
217
+ h,
218
+ "Authentication initialization failed",
219
+ l,
152
220
  e.onError
153
221
  );
154
222
  } finally {
155
- s.value = !1, n.value = !1, o.value = !0;
223
+ n.value = !1, a.value = !1;
156
224
  }
157
- }, E = async (v) => {
225
+ }, k = async (h) => {
158
226
  try {
159
- s.value = !0, a.value = null, await r.signinRedirect({ state: v });
160
- } catch (i) {
161
- b(i, "Sign in failed", a, e.onError);
227
+ a.value = !0, l.value = null, t.logger.info("[Vuethenticate] useAuth: Starting sign-in flow"), await r.signinRedirect({ state: h });
228
+ } catch (u) {
229
+ t.logger.error("[Vuethenticate] useAuth: Sign-in failed", u), U(u, "Sign in failed", l, e.onError);
162
230
  } finally {
163
- s.value = !1;
231
+ a.value = !1;
164
232
  }
165
- }, q = async (v) => {
233
+ }, m = async (h) => {
166
234
  try {
167
- s.value = !0, a.value = null, c.value = null, await r.signoutRedirect({ state: v });
168
- } catch (i) {
169
- b(i, "Sign out failed", a, e.onError);
235
+ a.value = !0, l.value = null, c.value = null, t.logger.info(
236
+ "[Vuethenticate] useAuth: Starting sign-out flow"
237
+ ), await r.signoutRedirect({ state: h });
238
+ } catch (u) {
239
+ t.logger.error("[Vuethenticate] useAuth: Sign-out failed", u), U(u, "Sign out failed", l, e.onError);
170
240
  } finally {
171
- s.value = !1;
241
+ a.value = !1;
172
242
  }
173
243
  }, $ = async () => {
174
244
  try {
175
- s.value = !0, a.value = null;
176
- const v = await r.signinSilent();
177
- c.value = v;
178
- } catch (v) {
179
- throw b(
180
- v,
245
+ a.value = !0, l.value = null;
246
+ const h = await r.signinSilent();
247
+ c.value = h;
248
+ } catch (h) {
249
+ throw U(
250
+ h,
181
251
  "Silent renewal failed",
182
- a,
252
+ l,
183
253
  e.onError
184
254
  );
185
255
  } finally {
186
- s.value = !1;
256
+ a.value = !1;
187
257
  }
188
- }, B = () => {
189
- a.value = null;
190
- }, O = (v, i) => {
191
- const { userManager: f, user: A, error: D, eventCallbacks: g } = v;
192
- g.userLoaded = (w) => {
193
- var C;
194
- A.value = w, (C = i.onUserLoaded) == null || C.call(i, w);
195
- }, g.userUnloaded = () => {
258
+ }, K = () => {
259
+ l.value = null;
260
+ }, F = (h, u) => {
261
+ const { userManager: C, user: L, error: Y, eventCallbacks: p } = h;
262
+ p.userLoaded = (w) => {
263
+ var R;
264
+ L.value = w, (R = u.onUserLoaded) == null || R.call(u, w);
265
+ }, p.userUnloaded = () => {
196
266
  var w;
197
- A.value = null, (w = i.onUserUnloaded) == null || w.call(i);
198
- }, g.accessTokenExpired = () => {
267
+ L.value = null, (w = u.onUserUnloaded) == null || w.call(u);
268
+ }, p.accessTokenExpired = () => {
199
269
  var w;
200
- (w = i.onAccessTokenExpired) == null || w.call(i);
201
- }, g.accessTokenExpiring = () => {
270
+ (w = u.onAccessTokenExpired) == null || w.call(u);
271
+ }, p.accessTokenExpiring = () => {
202
272
  var w;
203
- (w = i.onAccessTokenExpiring) == null || w.call(i);
204
- }, g.silentRenewError = async (w) => {
273
+ (w = u.onAccessTokenExpiring) == null || w.call(u);
274
+ }, p.silentRenewError = async (w) => {
205
275
  console.warn("Silent renewal failed:", w);
206
276
  try {
207
- await f.removeUser(), A.value = null;
208
- } catch (C) {
277
+ await C.removeUser(), L.value = null;
278
+ } catch (R) {
209
279
  console.error(
210
280
  "Failed to remove user after silent renewal error:",
211
- C
281
+ R
212
282
  );
213
283
  }
214
- b(
284
+ U(
215
285
  w,
216
286
  "Silent renewal failed",
217
- D,
218
- i.onError
287
+ Y,
288
+ u.onError
219
289
  );
220
- }, f.events.addUserLoaded(g.userLoaded), f.events.addUserUnloaded(g.userUnloaded), f.events.addAccessTokenExpired(
221
- g.accessTokenExpired
222
- ), f.events.addAccessTokenExpiring(
223
- g.accessTokenExpiring
224
- ), f.events.addSilentRenewError(g.silentRenewError);
225
- }, V = () => {
226
- J(t), h.delete(u);
290
+ }, C.events.addUserLoaded(p.userLoaded), C.events.addUserUnloaded(p.userUnloaded), C.events.addAccessTokenExpired(
291
+ p.accessTokenExpired
292
+ ), C.events.addAccessTokenExpiring(
293
+ p.accessTokenExpiring
294
+ ), C.events.addSilentRenewError(p.silentRenewError);
295
+ }, q = () => {
296
+ ne(t), A.delete(i);
227
297
  };
228
- return !o.value && !n.value && (k(), O(t, e)), {
298
+ return !s.value && !n.value && !ue(e) ? (d(), F(t, e)) : !s.value && !n.value && (F(t, e), s.value = !0), {
229
299
  user: c,
230
- isAuthenticated: p,
231
- isLoading: s,
232
- error: a,
233
- accessToken: d,
234
- isExpired: l,
235
- signIn: E,
236
- signOut: q,
300
+ isAuthenticated: o,
301
+ isLoading: a,
302
+ error: l,
303
+ accessToken: b,
304
+ isExpired: g,
305
+ signIn: k,
306
+ signOut: m,
237
307
  silentRenew: $,
238
- clearError: B,
239
- cleanup: V
308
+ clearError: K,
309
+ cleanup: q
240
310
  };
241
- }, R = () => {
242
- const e = Q();
311
+ }, O = () => {
312
+ const e = ae();
243
313
  if (!e)
244
314
  throw new Error(
245
315
  "Authentication not initialized. Make sure useAuth() is called in a parent component first."
246
316
  );
247
317
  return {
248
318
  processCallback: async () => {
249
- await z(e);
319
+ await T(e), e.logger.info(
320
+ "[Vuethenticate] useAuthCallbacks: Processing authentication callback"
321
+ );
250
322
  const n = await e.userManager.signinCallback();
251
323
  if (!n)
252
324
  throw new Error("Authentication callback failed: no user returned");
253
- return {
325
+ return e.logger.info(
326
+ "[Vuethenticate] useAuthCallbacks: Authentication callback successful"
327
+ ), {
254
328
  user: n,
255
329
  state: n.state
256
330
  };
257
331
  },
258
332
  processLogoutCallback: async () => {
259
- await z(e);
333
+ await T(e), e.logger.debug(
334
+ "[Vuethenticate] useAuthCallbacks: Processing logout callback"
335
+ );
260
336
  const n = await e.userManager.signoutCallback();
261
- return {
337
+ return e.logger.info(
338
+ "[Vuethenticate] useAuthCallbacks: Logout callback completed successfully"
339
+ ), {
262
340
  state: n == null ? void 0 : n.userState
263
341
  };
264
342
  },
265
343
  processSilentCallback: async () => {
266
- await z(e), await e.userManager.signinCallback();
344
+ await T(e), e.logger.debug(
345
+ "[Vuethenticate] useAuthCallbacks: Processing silent callback"
346
+ ), await e.userManager.signinCallback(), e.logger.debug(
347
+ "[Vuethenticate] useAuthCallbacks: Silent callback completed successfully"
348
+ );
267
349
  },
268
350
  isInitialized: e.isInitialized,
269
- isInitializing: e.isInitializing
351
+ isInitializing: e.isInitializing,
352
+ logger: e.logger
270
353
  };
271
- }, ae = /* @__PURE__ */ M({
354
+ }, he = /* @__PURE__ */ V({
272
355
  __name: "AuthCallback",
273
356
  props: {
274
357
  onSuccess: { type: Function },
@@ -276,36 +359,44 @@ const h = /* @__PURE__ */ new Map(), J = (e) => {
276
359
  },
277
360
  emits: ["success", "error"],
278
361
  setup(e, { emit: t }) {
279
- const r = e, o = t, { processCallback: n, isInitializing: c } = R(), s = m(!0), a = m(null), p = async () => {
280
- var d, l;
362
+ const r = e, s = t, { processCallback: n, isInitializing: c, logger: a } = O(), l = y(!0), o = y(null), b = async () => {
363
+ var g, i;
281
364
  try {
282
- const u = await n();
283
- (d = r.onSuccess) == null || d.call(r, u.user, u.state), o("success", u.user, u.state);
284
- } catch (u) {
285
- const k = u instanceof Error ? u : new Error("Callback processing failed");
286
- a.value = k, (l = r.onError) == null || l.call(r, k), o("error", k);
365
+ a.info(
366
+ "[Vuethenticate] AuthCallback: Processing authentication callback"
367
+ );
368
+ const d = await n();
369
+ a.info(
370
+ "[Vuethenticate] AuthCallback: Authentication callback completed successfully"
371
+ ), (g = r.onSuccess) == null || g.call(r, d.user, d.state), s("success", d.user, d.state);
372
+ } catch (d) {
373
+ const k = d instanceof Error ? d : new Error("Callback processing failed");
374
+ a.error(
375
+ "[Vuethenticate] AuthCallback: Authentication callback failed",
376
+ k
377
+ ), o.value = k, (i = r.onError) == null || i.call(r, k), s("error", k);
287
378
  } finally {
288
- s.value = !1;
379
+ l.value = !1;
289
380
  }
290
381
  };
291
- return T(() => {
292
- p();
293
- }), (d, l) => (P(), F(K, null, [
294
- (L(c) || s.value) && !a.value ? S(d.$slots, "default", { key: 0 }, () => [
295
- l[0] || (l[0] = y("p", null, "Processing authentication...", -1))
296
- ]) : U("", !0),
297
- a.value ? S(d.$slots, "error", {
382
+ return z(() => {
383
+ b();
384
+ }), (g, i) => (W(), _(B, null, [
385
+ (M(c) || l.value) && !o.value ? S(g.$slots, "default", { key: 0 }, () => [
386
+ i[0] || (i[0] = v("p", null, "Processing authentication...", -1))
387
+ ]) : I("", !0),
388
+ o.value ? S(g.$slots, "error", {
298
389
  key: 1,
299
- error: a.value
390
+ error: o.value
300
391
  }, () => [
301
- y("div", null, [
302
- l[1] || (l[1] = y("h2", null, "Authentication Error", -1)),
303
- y("p", null, x(a.value.message), 1)
392
+ v("div", null, [
393
+ i[1] || (i[1] = v("h2", null, "Authentication Error", -1)),
394
+ v("p", null, x(o.value.message), 1)
304
395
  ])
305
- ]) : U("", !0)
396
+ ]) : I("", !0)
306
397
  ], 64));
307
398
  }
308
- }), se = /* @__PURE__ */ M({
399
+ }), ke = /* @__PURE__ */ V({
309
400
  __name: "LogoutCallback",
310
401
  props: {
311
402
  onSuccess: { type: Function },
@@ -313,70 +404,86 @@ const h = /* @__PURE__ */ new Map(), J = (e) => {
313
404
  },
314
405
  emits: ["success", "error"],
315
406
  setup(e, { emit: t }) {
316
- const r = e, o = t, { processLogoutCallback: n, isInitializing: c } = R(), s = m(!0), a = m(null), p = async () => {
317
- var d, l;
407
+ const r = e, s = t, { processLogoutCallback: n, isInitializing: c, logger: a } = O(), l = y(!0), o = y(null), b = async () => {
408
+ var g, i;
318
409
  try {
319
- const u = await n();
320
- (d = r.onSuccess) == null || d.call(r, u.state), o("success", u.state);
321
- } catch (u) {
322
- const k = u instanceof Error ? u : new Error("Logout callback processing failed");
323
- a.value = k, (l = r.onError) == null || l.call(r, k), o("error", k);
410
+ a.info(
411
+ "[Vuethenticate] LogoutCallback: Processing logout callback"
412
+ );
413
+ const d = await n();
414
+ a.info(
415
+ "[Vuethenticate] LogoutCallback: Logout callback completed successfully"
416
+ ), (g = r.onSuccess) == null || g.call(r, d.state), s("success", d.state);
417
+ } catch (d) {
418
+ const k = d instanceof Error ? d : new Error("Logout callback processing failed");
419
+ a.error(
420
+ "[Vuethenticate] LogoutCallback: Logout callback failed",
421
+ k
422
+ ), o.value = k, (i = r.onError) == null || i.call(r, k), s("error", k);
324
423
  } finally {
325
- s.value = !1;
424
+ l.value = !1;
326
425
  }
327
426
  };
328
- return T(() => {
329
- p();
330
- }), (d, l) => (L(c) || s.value) && !a.value ? S(d.$slots, "default", { key: 0 }, () => [
331
- l[0] || (l[0] = y("p", null, "Processing logout...", -1))
332
- ]) : a.value ? S(d.$slots, "error", {
427
+ return z(() => {
428
+ b();
429
+ }), (g, i) => (M(c) || l.value) && !o.value ? S(g.$slots, "default", { key: 0 }, () => [
430
+ i[0] || (i[0] = v("p", null, "Processing logout...", -1))
431
+ ]) : o.value ? S(g.$slots, "error", {
333
432
  key: 1,
334
- error: a.value
433
+ error: o.value
335
434
  }, () => [
336
- y("div", null, [
337
- l[1] || (l[1] = y("h2", null, "Logout Error", -1)),
338
- y("p", null, x(a.value.message), 1)
435
+ v("div", null, [
436
+ i[1] || (i[1] = v("h2", null, "Logout Error", -1)),
437
+ v("p", null, x(o.value.message), 1)
339
438
  ])
340
- ]) : S(d.$slots, "success", { key: 2 }, () => [
341
- l[2] || (l[2] = y("div", null, [
342
- y("h2", null, "Logout Successful"),
343
- y("p", null, "You have been logged out successfully.")
439
+ ]) : S(g.$slots, "success", { key: 2 }, () => [
440
+ i[2] || (i[2] = v("div", null, [
441
+ v("h2", null, "Logout Successful"),
442
+ v("p", null, "You have been logged out successfully.")
344
443
  ], -1))
345
444
  ]);
346
445
  }
347
- }), le = /* @__PURE__ */ M({
446
+ }), we = /* @__PURE__ */ V({
348
447
  __name: "SilentCallback",
349
448
  props: {
350
449
  onError: { type: Function }
351
450
  },
352
451
  setup(e) {
353
- const t = e, { processSilentCallback: r, isInitializing: o } = R(), n = m(null), c = async () => {
354
- var s;
452
+ const t = e, { processSilentCallback: r, isInitializing: s, logger: n } = O(), c = y(null), a = async () => {
453
+ var l;
355
454
  try {
356
- await r();
357
- } catch (a) {
358
- const p = a instanceof Error ? a : new Error("Silent callback processing failed");
359
- n.value = p, (s = t.onError) == null || s.call(t, p), console.error("Silent callback error:", p);
455
+ n.debug(
456
+ "[Vuethenticate] SilentCallback: Processing silent callback"
457
+ ), await r();
458
+ } catch (o) {
459
+ const b = o instanceof Error ? o : new Error("Silent callback processing failed");
460
+ n.error(
461
+ "[Vuethenticate] SilentCallback: Silent callback failed",
462
+ b
463
+ ), c.value = b, (l = t.onError) == null || l.call(t, b);
360
464
  }
361
465
  };
362
- return T(() => {
363
- c();
364
- }), (s, a) => (P(), F(K, null, [
365
- L(o) && !n.value ? S(s.$slots, "default", { key: 0 }, () => [
366
- a[0] || (a[0] = y("p", null, "Processing silent renewal...", -1))
367
- ]) : U("", !0),
368
- n.value ? S(s.$slots, "error", {
466
+ return z(() => {
467
+ a();
468
+ }), (l, o) => (W(), _(B, null, [
469
+ M(s) && !c.value ? S(l.$slots, "default", { key: 0 }, () => [
470
+ o[0] || (o[0] = v("p", null, "Processing silent renewal...", -1))
471
+ ]) : I("", !0),
472
+ c.value ? S(l.$slots, "error", {
369
473
  key: 1,
370
- error: n.value
474
+ error: c.value
371
475
  }, () => [
372
- y("p", null, "Silent renewal error: " + x(n.value.message), 1)
373
- ]) : U("", !0)
476
+ v("p", null, "Silent renewal error: " + x(c.value.message), 1)
477
+ ]) : I("", !0)
374
478
  ], 64));
375
479
  }
376
480
  });
377
481
  export {
378
- ae as AuthCallback,
379
- se as LogoutCallback,
380
- le as SilentCallback,
381
- ne as useAuth
482
+ he as AuthCallback,
483
+ f as LogLevel,
484
+ ke as LogoutCallback,
485
+ we as SilentCallback,
486
+ D as consoleLogger,
487
+ Q as silentLogger,
488
+ ge as useAuth
382
489
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(k,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("oidc-client-ts")):typeof define=="function"&&define.amd?define(["exports","vue","oidc-client-ts"],t):(k=typeof globalThis<"u"?globalThis:k||self,t(k.Vuethenticate={},k.Vue,k.OidcClientTs))})(this,function(k,t,I){"use strict";function L(e){const n=typeof window<"u"?window.location.origin:"";return{authority:e.authority,client_id:e.clientId,client_secret:e.clientSecret,client_authentication:e.clientAuthentication,redirect_uri:e.redirectUri??`${n}/auth/callback`,scope:e.scope??"openid profile",response_type:e.responseType??"code",userStore:e.storage?new I.WebStorageStateStore({store:R(e.storage)}):void 0,automaticSilentRenew:e.automaticSilentRenew??!0,silent_redirect_uri:e.silentRedirectUri??`${n}/auth/silent-callback`,post_logout_redirect_uri:e.postLogoutRedirectUri??`${n}/auth/logout-callback`,includeIdTokenInSilentRenew:!0,accessTokenExpiringNotificationTimeInSeconds:60}}function R(e){if(typeof window>"u")return M();switch(e){case"localStorage":return window.localStorage;case"sessionStorage":return window.sessionStorage;case"memory":return M();default:return window.localStorage}}function M(){const e=new Map;return{getItem:n=>e.get(n)??null,setItem:(n,r)=>e.set(n,r),removeItem:n=>e.delete(n),clear:()=>e.clear(),get length(){return e.size},key:n=>Array.from(e.keys())[n]??null}}const g=new Map,V=e=>{try{const{userManager:n,eventCallbacks:r}=e;r.userLoaded&&n.events.removeUserLoaded(r.userLoaded),r.userUnloaded&&n.events.removeUserUnloaded(r.userUnloaded),r.accessTokenExpired&&n.events.removeAccessTokenExpired(r.accessTokenExpired),r.accessTokenExpiring&&n.events.removeAccessTokenExpiring(r.accessTokenExpiring),r.silentRenewError&&n.events.removeSilentRenewError(r.silentRenewError),n.stopSilentRenew(),n.clearStaleState()}catch(n){console.warn("Error during UserManager cleanup:",n)}},T=e=>`${e.authority}_${e.clientId}`,x=()=>g.size===0?null:(g.size===1||console.warn("Multiple auth instances detected. Callback components may not work as expected. Consider using a single auth instance or specify config explicitly."),Array.from(g.values())[0]||null),N=e=>{const n=T(e),r=g.get(n);if(r)return r;const i=$(e),a=t.ref(!1),d=t.ref(!1),l=t.ref(null),s=t.ref(!1),E=t.ref(null),m=t.computed(()=>!!l.value&&!l.value.expired),o=t.computed(()=>{var h;return((h=l.value)==null?void 0:h.access_token)||null}),u=t.computed(()=>{var h;return!!((h=l.value)!=null&&h.expired)}),p={userManager:i,isInitialized:a,isInitializing:d,user:l,isLoading:s,error:E,isAuthenticated:m,accessToken:o,isExpired:u,eventCallbacks:{}};return g.set(n,p),p},$=e=>{const n=L(e);return new I.UserManager(n)},b=(e,n,r,i)=>{const a=e instanceof Error?e:new Error(n);return r.value=a,i==null||i(a),a},_=e=>{var n,r;if(!((n=e.authority)!=null&&n.trim()))throw new Error("AuthConfig: authority is required");if(!((r=e.clientId)!=null&&r.trim()))throw new Error("AuthConfig: clientId is required");try{new URL(e.authority)}catch{throw new Error("AuthConfig: authority must be a valid URL")}},v=async(e,n=1e4)=>{if(!e.isInitialized.value)return new Promise((r,i)=>{const a=setTimeout(()=>{i(new Error("Authentication initialization timeout"))},n),d=t.watch(e.isInitialized,l=>{l&&(clearTimeout(a),d(),r())},{immediate:!0})})},F=e=>{_(e);const n=N(e),{userManager:r,isInitialized:i,isInitializing:a,user:d,isLoading:l,error:s,isAuthenticated:E,accessToken:m,isExpired:o}=n,u=T(e),p=async()=>{if(!(a.value||i.value))try{a.value=!0,l.value=!0,s.value=null;const w=await r.getUser();if(w)if(!w.expired)d.value=w;else if(e.automaticSilentRenew!==!1)try{await z()}catch(c){console.warn("Silent renewal failed during initialization:",c),await r.removeUser(),d.value=null}else await r.removeUser(),d.value=null}catch(w){b(w,"Failed to initialize authentication",s,e.onError)}finally{l.value=!1,a.value=!1,i.value=!0}},h=async w=>{try{l.value=!0,s.value=null,await r.signinRedirect({state:w})}catch(c){b(c,"Sign in failed",s,e.onError)}finally{l.value=!1}},O=async w=>{try{l.value=!0,s.value=null,d.value=null,await r.signoutRedirect({state:w})}catch(c){b(c,"Sign out failed",s,e.onError)}finally{l.value=!1}},z=async()=>{try{l.value=!0,s.value=null;const w=await r.signinSilent();d.value=w}catch(w){throw b(w,"Silent renewal failed",s,e.onError)}finally{l.value=!1}},D=()=>{s.value=null},K=(w,c)=>{const{userManager:S,user:A,error:W,eventCallbacks:f}=w;f.userLoaded=y=>{var C;A.value=y,(C=c.onUserLoaded)==null||C.call(c,y)},f.userUnloaded=()=>{var y;A.value=null,(y=c.onUserUnloaded)==null||y.call(c)},f.accessTokenExpired=()=>{var y;(y=c.onAccessTokenExpired)==null||y.call(c)},f.accessTokenExpiring=()=>{var y;(y=c.onAccessTokenExpiring)==null||y.call(c)},f.silentRenewError=async y=>{console.warn("Silent renewal failed:",y);try{await S.removeUser(),A.value=null}catch(C){console.error("Failed to remove user after silent renewal error:",C)}b(y,"Silent renewal failed",W,c.onError)},S.events.addUserLoaded(f.userLoaded),S.events.addUserUnloaded(f.userUnloaded),S.events.addAccessTokenExpired(f.accessTokenExpired),S.events.addAccessTokenExpiring(f.accessTokenExpiring),S.events.addSilentRenewError(f.silentRenewError)},j=()=>{V(n),g.delete(u)};return!i.value&&!a.value&&(p(),K(n,e)),{user:d,isAuthenticated:E,isLoading:l,error:s,accessToken:m,isExpired:o,signIn:h,signOut:O,silentRenew:z,clearError:D,cleanup:j}},U=()=>{const e=x();if(!e)throw new Error("Authentication not initialized. Make sure useAuth() is called in a parent component first.");return{processCallback:async()=>{await v(e);const a=await e.userManager.signinCallback();if(!a)throw new Error("Authentication callback failed: no user returned");return{user:a,state:a.state}},processLogoutCallback:async()=>{await v(e);const a=await e.userManager.signoutCallback();return{state:a==null?void 0:a.userState}},processSilentCallback:async()=>{await v(e),await e.userManager.signinCallback()},isInitialized:e.isInitialized,isInitializing:e.isInitializing}},P=t.defineComponent({__name:"AuthCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:n}){const r=e,i=n,{processCallback:a,isInitializing:d}=U(),l=t.ref(!0),s=t.ref(null),E=async()=>{var m,o;try{const u=await a();(m=r.onSuccess)==null||m.call(r,u.user,u.state),i("success",u.user,u.state)}catch(u){const p=u instanceof Error?u:new Error("Callback processing failed");s.value=p,(o=r.onError)==null||o.call(r,p),i("error",p)}finally{l.value=!1}};return t.onMounted(()=>{E()}),(m,o)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[(t.unref(d)||l.value)&&!s.value?t.renderSlot(m.$slots,"default",{key:0},()=>[o[0]||(o[0]=t.createElementVNode("p",null,"Processing authentication...",-1))]):t.createCommentVNode("",!0),s.value?t.renderSlot(m.$slots,"error",{key:1,error:s.value},()=>[t.createElementVNode("div",null,[o[1]||(o[1]=t.createElementVNode("h2",null,"Authentication Error",-1)),t.createElementVNode("p",null,t.toDisplayString(s.value.message),1)])]):t.createCommentVNode("",!0)],64))}}),q=t.defineComponent({__name:"LogoutCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:n}){const r=e,i=n,{processLogoutCallback:a,isInitializing:d}=U(),l=t.ref(!0),s=t.ref(null),E=async()=>{var m,o;try{const u=await a();(m=r.onSuccess)==null||m.call(r,u.state),i("success",u.state)}catch(u){const p=u instanceof Error?u:new Error("Logout callback processing failed");s.value=p,(o=r.onError)==null||o.call(r,p),i("error",p)}finally{l.value=!1}};return t.onMounted(()=>{E()}),(m,o)=>(t.unref(d)||l.value)&&!s.value?t.renderSlot(m.$slots,"default",{key:0},()=>[o[0]||(o[0]=t.createElementVNode("p",null,"Processing logout...",-1))]):s.value?t.renderSlot(m.$slots,"error",{key:1,error:s.value},()=>[t.createElementVNode("div",null,[o[1]||(o[1]=t.createElementVNode("h2",null,"Logout Error",-1)),t.createElementVNode("p",null,t.toDisplayString(s.value.message),1)])]):t.renderSlot(m.$slots,"success",{key:2},()=>[o[2]||(o[2]=t.createElementVNode("div",null,[t.createElementVNode("h2",null,"Logout Successful"),t.createElementVNode("p",null,"You have been logged out successfully.")],-1))])}}),B=t.defineComponent({__name:"SilentCallback",props:{onError:{type:Function}},setup(e){const n=e,{processSilentCallback:r,isInitializing:i}=U(),a=t.ref(null),d=async()=>{var l;try{await r()}catch(s){const E=s instanceof Error?s:new Error("Silent callback processing failed");a.value=E,(l=n.onError)==null||l.call(n,E),console.error("Silent callback error:",E)}};return t.onMounted(()=>{d()}),(l,s)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.unref(i)&&!a.value?t.renderSlot(l.$slots,"default",{key:0},()=>[s[0]||(s[0]=t.createElementVNode("p",null,"Processing silent renewal...",-1))]):t.createCommentVNode("",!0),a.value?t.renderSlot(l.$slots,"error",{key:1,error:a.value},()=>[t.createElementVNode("p",null,"Silent renewal error: "+t.toDisplayString(a.value.message),1)]):t.createCommentVNode("",!0)],64))}});k.AuthCallback=P,k.LogoutCallback=q,k.SilentCallback=B,k.useAuth=F,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
1
+ (function(f,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue"),require("oidc-client-ts")):typeof define=="function"&&define.amd?define(["exports","vue","oidc-client-ts"],r):(f=typeof globalThis<"u"?globalThis:f||self,r(f.Vuethenticate={},f.Vue,f.OidcClientTs))})(this,function(f,r,p){"use strict";var b=(e=>(e[e.NONE=0]="NONE",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e))(b||{});const V={error:(e,...t)=>console.error(e,...t),warn:(e,...t)=>console.warn(e,...t),info:(e,...t)=>console.info(e,...t),debug:(e,...t)=>console.debug(e,...t)},I={error:()=>{},warn:()=>{},info:()=>{},debug:()=>{}},x=(e,t)=>({error:t>=1?e.error:()=>{},warn:t>=2?e.warn:()=>{},info:t>=3?e.info:()=>{},debug:t>=4?e.debug:()=>{}});function $(e){const t=typeof window<"u"?window.location.origin:"";return P(e),{authority:e.authority,client_id:e.clientId,client_secret:e.clientSecret,client_authentication:e.clientAuthentication,redirect_uri:e.redirectUri??`${t}/auth/callback`,scope:e.scope??"openid profile",response_type:e.responseType??"code",userStore:e.storage?new p.WebStorageStateStore({store:F(e.storage)}):void 0,automaticSilentRenew:e.automaticSilentRenew??!0,silent_redirect_uri:e.silentRedirectUri??`${t}/auth/silent-callback`,post_logout_redirect_uri:e.postLogoutRedirectUri??`${t}/auth/logout-callback`,includeIdTokenInSilentRenew:!0,accessTokenExpiringNotificationTimeInSeconds:60}}function F(e){if(typeof window>"u")return M();switch(e){case"localStorage":return window.localStorage;case"sessionStorage":return window.sessionStorage;case"memory":return M();default:return window.localStorage}}function M(){const e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>e.set(t,n),removeItem:t=>e.delete(t),clear:()=>e.clear(),get length(){return e.size},key:t=>Array.from(e.keys())[t]??null}}const P=e=>{if(e.logLevel===void 0&&!e.logger)return;const t=e.logger??(e.logLevel!==void 0?V:void 0),n=e.logLevel??b.NONE;t&&(p.Log.setLogger({error:t.error,warn:t.warn,info:t.info,debug:t.debug}),p.Log.setLevel(_(n)))},_=e=>{switch(e){case b.NONE:return p.Log.NONE;case b.ERROR:return p.Log.ERROR;case b.WARN:return p.Log.WARN;case b.INFO:return p.Log.INFO;case b.DEBUG:return p.Log.DEBUG;default:return p.Log.NONE}},S=new Map,B=e=>{try{const{userManager:t,eventCallbacks:n}=e;n.userLoaded&&t.events.removeUserLoaded(n.userLoaded),n.userUnloaded&&t.events.removeUserUnloaded(n.userUnloaded),n.accessTokenExpired&&t.events.removeAccessTokenExpired(n.accessTokenExpired),n.accessTokenExpiring&&t.events.removeAccessTokenExpiring(n.accessTokenExpiring),n.silentRenewError&&t.events.removeSilentRenewError(n.silentRenewError),t.stopSilentRenew(),t.clearStaleState()}catch(t){console.warn("Error during UserManager cleanup:",t)}},z=e=>`${e.authority}_${e.clientId}`,W=()=>S.size===0?null:(S.size===1||console.warn("Multiple auth instances detected. Callback components may not work as expected. Consider using a single auth instance or specify config explicitly."),Array.from(S.values())[0]||null),D=e=>{const t=z(e),n=S.get(t);if(n)return n;const s=q(e),a=r.ref(!1),d=r.ref(!1),l=r.ref(null),o=r.ref(!1),i=r.ref(null),E=r.computed(()=>!!l.value&&!l.value.expired),h=r.computed(()=>{var A;return((A=l.value)==null?void 0:A.access_token)||null}),c=r.computed(()=>{var A;return!!((A=l.value)!=null&&A.expired)}),g=G(e),w={userManager:s,isInitialized:a,isInitializing:d,user:l,isLoading:o,error:i,isAuthenticated:E,accessToken:h,isExpired:c,logger:g,eventCallbacks:{}};return S.set(t,w),w},q=e=>{const t=$(e);return new p.UserManager(t)},G=e=>{if(!e.logger&&!e.logLevel)return I;const t=e.logger??V,n=e.logLevel??b.NONE;return x(t,n)},U=(e,t,n,s)=>{const a=e instanceof Error?e:new Error(t);return n.value=a,s==null||s(a),a},K=e=>{var t,n;if(!((t=e.authority)!=null&&t.trim()))throw new Error("AuthConfig: authority is required");if(!((n=e.clientId)!=null&&n.trim()))throw new Error("AuthConfig: clientId is required");try{new URL(e.authority)}catch{throw new Error("AuthConfig: authority must be a valid URL")}},N=async(e,t=1e4)=>{if(!e.isInitialized.value)return new Promise((n,s)=>{const a=setTimeout(()=>{s(new Error("Authentication initialization timeout"))},t),d=r.watch(e.isInitialized,l=>{l&&(clearTimeout(a),d(),n())},{immediate:!0})})},j=e=>{const t=window.location.href;return!!(e.silentRedirectUri&&t.startsWith(e.silentRedirectUri)||e.redirectUri&&t.startsWith(e.redirectUri)||e.postLogoutRedirectUri&&t.startsWith(e.postLogoutRedirectUri))},Y=e=>{K(e);const t=D(e),{userManager:n,isInitialized:s,isInitializing:a,user:d,isLoading:l,error:o,isAuthenticated:i,accessToken:E,isExpired:h}=t,c=z(e),g=async()=>{if(!(a.value||s.value))try{a.value=!0,l.value=!0,o.value=null;const k=await n.getUser();if(k)if(!k.expired)d.value=k,t.logger.info("[Vuethenticate] useAuth: User restored from storage");else if(e.automaticSilentRenew!==!1){t.logger.info("[Vuethenticate] useAuth: Token expired, attempting silent renewal");try{await O()}catch(u){t.logger.warn("[Vuethenticate] useAuth: Silent renewal failed during initialization",u),await n.removeUser(),d.value=null}}else await n.removeUser(),d.value=null;s.value=!0}catch(k){t.logger.error("[Vuethenticate] useAuth: Initialization failed",k),U(k,"Authentication initialization failed",o,e.onError)}finally{a.value=!1,l.value=!1}},w=async k=>{try{l.value=!0,o.value=null,t.logger.info("[Vuethenticate] useAuth: Starting sign-in flow"),await n.signinRedirect({state:k})}catch(u){t.logger.error("[Vuethenticate] useAuth: Sign-in failed",u),U(u,"Sign in failed",o,e.onError)}finally{l.value=!1}},A=async k=>{try{l.value=!0,o.value=null,d.value=null,t.logger.info("[Vuethenticate] useAuth: Starting sign-out flow"),await n.signoutRedirect({state:k})}catch(u){t.logger.error("[Vuethenticate] useAuth: Sign-out failed",u),U(u,"Sign out failed",o,e.onError)}finally{l.value=!1}},O=async()=>{try{l.value=!0,o.value=null;const k=await n.signinSilent();d.value=k}catch(k){throw U(k,"Silent renewal failed",o,e.onError)}finally{l.value=!1}},X=()=>{o.value=null},T=(k,u)=>{const{userManager:C,user:R,error:ee,eventCallbacks:y}=k;y.userLoaded=m=>{var v;R.value=m,(v=u.onUserLoaded)==null||v.call(u,m)},y.userUnloaded=()=>{var m;R.value=null,(m=u.onUserUnloaded)==null||m.call(u)},y.accessTokenExpired=()=>{var m;(m=u.onAccessTokenExpired)==null||m.call(u)},y.accessTokenExpiring=()=>{var m;(m=u.onAccessTokenExpiring)==null||m.call(u)},y.silentRenewError=async m=>{console.warn("Silent renewal failed:",m);try{await C.removeUser(),R.value=null}catch(v){console.error("Failed to remove user after silent renewal error:",v)}U(m,"Silent renewal failed",ee,u.onError)},C.events.addUserLoaded(y.userLoaded),C.events.addUserUnloaded(y.userUnloaded),C.events.addAccessTokenExpired(y.accessTokenExpired),C.events.addAccessTokenExpiring(y.accessTokenExpiring),C.events.addSilentRenewError(y.silentRenewError)},Z=()=>{B(t),S.delete(c)};return!s.value&&!a.value&&!j(e)?(g(),T(t,e)):!s.value&&!a.value&&(T(t,e),s.value=!0),{user:d,isAuthenticated:i,isLoading:l,error:o,accessToken:E,isExpired:h,signIn:w,signOut:A,silentRenew:O,clearError:X,cleanup:Z}},L=()=>{const e=W();if(!e)throw new Error("Authentication not initialized. Make sure useAuth() is called in a parent component first.");return{processCallback:async()=>{await N(e),e.logger.info("[Vuethenticate] useAuthCallbacks: Processing authentication callback");const a=await e.userManager.signinCallback();if(!a)throw new Error("Authentication callback failed: no user returned");return e.logger.info("[Vuethenticate] useAuthCallbacks: Authentication callback successful"),{user:a,state:a.state}},processLogoutCallback:async()=>{await N(e),e.logger.debug("[Vuethenticate] useAuthCallbacks: Processing logout callback");const a=await e.userManager.signoutCallback();return e.logger.info("[Vuethenticate] useAuthCallbacks: Logout callback completed successfully"),{state:a==null?void 0:a.userState}},processSilentCallback:async()=>{await N(e),e.logger.debug("[Vuethenticate] useAuthCallbacks: Processing silent callback"),await e.userManager.signinCallback(),e.logger.debug("[Vuethenticate] useAuthCallbacks: Silent callback completed successfully")},isInitialized:e.isInitialized,isInitializing:e.isInitializing,logger:e.logger}},H=r.defineComponent({__name:"AuthCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:t}){const n=e,s=t,{processCallback:a,isInitializing:d,logger:l}=L(),o=r.ref(!0),i=r.ref(null),E=async()=>{var h,c;try{l.info("[Vuethenticate] AuthCallback: Processing authentication callback");const g=await a();l.info("[Vuethenticate] AuthCallback: Authentication callback completed successfully"),(h=n.onSuccess)==null||h.call(n,g.user,g.state),s("success",g.user,g.state)}catch(g){const w=g instanceof Error?g:new Error("Callback processing failed");l.error("[Vuethenticate] AuthCallback: Authentication callback failed",w),i.value=w,(c=n.onError)==null||c.call(n,w),s("error",w)}finally{o.value=!1}};return r.onMounted(()=>{E()}),(h,c)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[(r.unref(d)||o.value)&&!i.value?r.renderSlot(h.$slots,"default",{key:0},()=>[c[0]||(c[0]=r.createElementVNode("p",null,"Processing authentication...",-1))]):r.createCommentVNode("",!0),i.value?r.renderSlot(h.$slots,"error",{key:1,error:i.value},()=>[r.createElementVNode("div",null,[c[1]||(c[1]=r.createElementVNode("h2",null,"Authentication Error",-1)),r.createElementVNode("p",null,r.toDisplayString(i.value.message),1)])]):r.createCommentVNode("",!0)],64))}}),J=r.defineComponent({__name:"LogoutCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:t}){const n=e,s=t,{processLogoutCallback:a,isInitializing:d,logger:l}=L(),o=r.ref(!0),i=r.ref(null),E=async()=>{var h,c;try{l.info("[Vuethenticate] LogoutCallback: Processing logout callback");const g=await a();l.info("[Vuethenticate] LogoutCallback: Logout callback completed successfully"),(h=n.onSuccess)==null||h.call(n,g.state),s("success",g.state)}catch(g){const w=g instanceof Error?g:new Error("Logout callback processing failed");l.error("[Vuethenticate] LogoutCallback: Logout callback failed",w),i.value=w,(c=n.onError)==null||c.call(n,w),s("error",w)}finally{o.value=!1}};return r.onMounted(()=>{E()}),(h,c)=>(r.unref(d)||o.value)&&!i.value?r.renderSlot(h.$slots,"default",{key:0},()=>[c[0]||(c[0]=r.createElementVNode("p",null,"Processing logout...",-1))]):i.value?r.renderSlot(h.$slots,"error",{key:1,error:i.value},()=>[r.createElementVNode("div",null,[c[1]||(c[1]=r.createElementVNode("h2",null,"Logout Error",-1)),r.createElementVNode("p",null,r.toDisplayString(i.value.message),1)])]):r.renderSlot(h.$slots,"success",{key:2},()=>[c[2]||(c[2]=r.createElementVNode("div",null,[r.createElementVNode("h2",null,"Logout Successful"),r.createElementVNode("p",null,"You have been logged out successfully.")],-1))])}}),Q=r.defineComponent({__name:"SilentCallback",props:{onError:{type:Function}},setup(e){const t=e,{processSilentCallback:n,isInitializing:s,logger:a}=L(),d=r.ref(null),l=async()=>{var o;try{a.debug("[Vuethenticate] SilentCallback: Processing silent callback"),await n()}catch(i){const E=i instanceof Error?i:new Error("Silent callback processing failed");a.error("[Vuethenticate] SilentCallback: Silent callback failed",E),d.value=E,(o=t.onError)==null||o.call(t,E)}};return r.onMounted(()=>{l()}),(o,i)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[r.unref(s)&&!d.value?r.renderSlot(o.$slots,"default",{key:0},()=>[i[0]||(i[0]=r.createElementVNode("p",null,"Processing silent renewal...",-1))]):r.createCommentVNode("",!0),d.value?r.renderSlot(o.$slots,"error",{key:1,error:d.value},()=>[r.createElementVNode("p",null,"Silent renewal error: "+r.toDisplayString(d.value.message),1)]):r.createCommentVNode("",!0)],64))}});f.AuthCallback=H,f.LogLevel=b,f.LogoutCallback=J,f.SilentCallback=Q,f.consoleLogger=V,f.silentLogger=I,f.useAuth=Y,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
@@ -1,4 +1,5 @@
1
1
  import { ComputedRef, Ref } from 'vue';
2
+ import { LogLevel, Logger } from '../utils/logger';
2
3
  import { User } from 'oidc-client-ts';
3
4
  export interface AuthConfig {
4
5
  authority: string;
@@ -12,6 +13,8 @@ export interface AuthConfig {
12
13
  automaticSilentRenew?: boolean;
13
14
  silentRedirectUri?: string;
14
15
  postLogoutRedirectUri?: string;
16
+ logLevel?: LogLevel;
17
+ logger?: Logger;
15
18
  onError?: (error: Error) => void;
16
19
  onUserLoaded?: (user: User) => void;
17
20
  onUserUnloaded?: () => void;
@@ -40,6 +43,19 @@ export interface AuthCallbackMethods<TState = unknown> {
40
43
  }>;
41
44
  processSilentCallback: (url?: string) => Promise<void>;
42
45
  }
46
+ export interface UseAuthCallbacksReturn<TState = unknown> {
47
+ processCallback: () => Promise<{
48
+ user: User;
49
+ state?: TState;
50
+ }>;
51
+ processLogoutCallback: () => Promise<{
52
+ state?: TState;
53
+ }>;
54
+ processSilentCallback: () => Promise<void>;
55
+ isInitialized: Ref<boolean>;
56
+ isInitializing: Ref<boolean>;
57
+ logger: Logger;
58
+ }
43
59
  export type UseAuthReturn<TState = unknown> = AuthState & AuthMethods<TState>;
44
60
  export interface AuthCallbackProps<TState = unknown> {
45
61
  onSuccess?: (user: User, state?: TState) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,WAAW,UAAU;IAEvB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CAAC;IAEpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,EAAE,cAAc,GAAG,gBAAgB,GAAG,QAAQ,CAAC;IACvD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,oBAA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B,CAAC"}
@@ -1,5 +1,5 @@
1
- import { AuthConfig } from '../types/auth';
2
1
  import { UserManagerSettings } from 'oidc-client-ts';
2
+ import { AuthConfig } from '../types/auth';
3
3
  /**
4
4
  * Creates UserManager settings from auth configuration
5
5
  * @param config - The authentication configuration
@@ -1 +1 @@
1
- {"version":3,"file":"configHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/configHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D;;;;GAIG;AACH,wBAAgB,yBAAyB,CACrC,MAAM,EAAE,UAAU,GACnB,mBAAmB,CAsBrB"}
1
+ {"version":3,"file":"configHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/configHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,mBAAmB,EAE3B,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACrC,MAAM,EAAE,UAAU,GACnB,mBAAmB,CAyBrB"}
@@ -0,0 +1,3 @@
1
+ export * from './configHelpers';
2
+ export * from './logger';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Log levels for authentication library
3
+ */
4
+ export declare enum LogLevel {
5
+ NONE = 0,
6
+ ERROR = 1,
7
+ WARN = 2,
8
+ INFO = 3,
9
+ DEBUG = 4
10
+ }
11
+ /**
12
+ * Logger interface for authentication library
13
+ */
14
+ export interface Logger {
15
+ error: (message: string, ...args: unknown[]) => void;
16
+ warn: (message: string, ...args: unknown[]) => void;
17
+ info: (message: string, ...args: unknown[]) => void;
18
+ debug: (message: string, ...args: unknown[]) => void;
19
+ }
20
+ /**
21
+ * Console logger implementation
22
+ */
23
+ export declare const consoleLogger: Logger;
24
+ /**
25
+ * Silent logger implementation that does nothing
26
+ */
27
+ export declare const silentLogger: Logger;
28
+ /**
29
+ * Creates a filtered logger based on log level
30
+ * @param logger - Base logger implementation
31
+ * @param level - Minimum log level to output
32
+ * @returns Filtered logger instance
33
+ */
34
+ export declare const createLevelLogger: (logger: Logger, level: LogLevel) => Logger;
35
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,QAAQ;IAChB,IAAI,IAAI;IACR,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACnB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpD,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACxD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAS3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,MAK1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,OAAO,QAAQ,KAAG,MAOnE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vuethenticate",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "A Vue 3 authentication state management library using oidc-client-ts",
5
5
  "keywords": [
6
6
  "vue",
@@ -28,7 +28,7 @@
28
28
  "types": "dist/index.d.ts",
29
29
  "scripts": {
30
30
  "build": "vite build",
31
- "dev": "vite build --watch",
31
+ "dev": "cross-env CHOKIDAR_USEPOLLING=1 vite build --watch",
32
32
  "type-check": "vue-tsc --noEmit",
33
33
  "test": "echo \"Error: no test specified\" && exit 1"
34
34
  },