witspry-auth-ng-client 1.0.0

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.
@@ -0,0 +1,154 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Router } from '@angular/router';
3
+ import { Observable } from 'rxjs';
4
+ import { OAuth2Config } from '../models/oauth2-config.model';
5
+ import { AuthState, UserInfoResponse } from '../models/oauth2-types.model';
6
+ import { OAuth2StorageService } from './oauth2-storage.service';
7
+ import * as i0 from "@angular/core";
8
+ /**
9
+ * OAuth2 Service with PKCE Support
10
+ * Handles OAuth2 authorization flow, token management, and user authentication
11
+ */
12
+ export declare class OAuth2Service {
13
+ private config;
14
+ private platformId;
15
+ private http;
16
+ private router;
17
+ private storageService;
18
+ private _authState;
19
+ private _authStateSubject;
20
+ authState$: Observable<AuthState>;
21
+ readonly authState: import("@angular/core").Signal<AuthState>;
22
+ private logLevel;
23
+ constructor(config: OAuth2Config, platformId: Object, http: HttpClient, router: Router, storageService: OAuth2StorageService);
24
+ /**
25
+ * Initialize authentication state from stored tokens
26
+ */
27
+ private initializeAuthState;
28
+ /**
29
+ * Generate cryptographically secure PKCE challenge
30
+ */
31
+ private generatePKCEChallenge;
32
+ /**
33
+ * Generate cryptographically secure 6-digit code verifier
34
+ */
35
+ private generateSecureCodeVerifier;
36
+ /**
37
+ * Create SHA-256 hash and base64 encode for code challenge
38
+ */
39
+ private createCodeChallenge;
40
+ /**
41
+ * Generate cryptographically secure state parameter for CSRF protection
42
+ */
43
+ private generateState;
44
+ /**
45
+ * Generate nonce if not provided in config
46
+ */
47
+ private generateNonce;
48
+ /**
49
+ * Start OAuth2 PKCE authorization flow
50
+ */
51
+ startAuthorization(): Promise<void>;
52
+ /**
53
+ * Build authorization URL with parameters
54
+ */
55
+ private buildAuthorizationUrl;
56
+ /**
57
+ * Handle OAuth2 callback and extract tokens
58
+ */
59
+ handleCallback(): Promise<void>;
60
+ /**
61
+ * Extract error from callback URL
62
+ */
63
+ private extractErrorFromCallback;
64
+ /**
65
+ * Extract authorization code from query parameters
66
+ */
67
+ private extractAuthorizationCode;
68
+ /**
69
+ * Extract tokens from URL fragment
70
+ */
71
+ private extractTokensFromFragment;
72
+ /**
73
+ * Exchange authorization code for tokens
74
+ */
75
+ private exchangeCodeForTokens;
76
+ /**
77
+ * Handle token response and store tokens securely
78
+ */
79
+ private handleTokenResponse;
80
+ /**
81
+ * Validate state parameter for CSRF protection
82
+ */
83
+ private validateState;
84
+ /**
85
+ * Get current access token (only if valid/not expired)
86
+ */
87
+ getAccessToken(): string | null;
88
+ /**
89
+ * Get raw access token (even if expired) - used for refresh flow
90
+ */
91
+ getRawAccessToken(): string | null;
92
+ /**
93
+ * Get current refresh token
94
+ */
95
+ getRefreshToken(): string | null;
96
+ /**
97
+ * Check if user is authenticated
98
+ */
99
+ isAuthenticated(): boolean;
100
+ /**
101
+ * Check if authentication is available in current environment
102
+ */
103
+ isAuthenticationAvailable(): boolean;
104
+ /**
105
+ * Fetch user information from OIDC userinfo endpoint
106
+ */
107
+ getUserInfo(): Promise<UserInfoResponse>;
108
+ /**
109
+ * Check if token is valid (not expired)
110
+ */
111
+ private isTokenValid;
112
+ /**
113
+ * Refresh access token using refresh token
114
+ */
115
+ refreshAccessToken(): Promise<string>;
116
+ /**
117
+ * Logout user and clean up all stored data
118
+ */
119
+ logout(): Promise<void>;
120
+ /**
121
+ * Revoke tokens at authorization server
122
+ */
123
+ private revokeTokens;
124
+ /**
125
+ * Store token information securely
126
+ */
127
+ private storeTokenInfo;
128
+ /**
129
+ * Retrieve stored token information
130
+ */
131
+ private getStoredTokenInfo;
132
+ /**
133
+ * Update authentication state
134
+ */
135
+ private updateAuthState;
136
+ /**
137
+ * Debug logging
138
+ */
139
+ private logDebug;
140
+ /**
141
+ * Info logging
142
+ */
143
+ private logInfo;
144
+ /**
145
+ * Warning logging
146
+ */
147
+ private logWarn;
148
+ /**
149
+ * Error logging
150
+ */
151
+ private logError;
152
+ static ɵfac: i0.ɵɵFactoryDeclaration<OAuth2Service, never>;
153
+ static ɵprov: i0.ɵɵInjectableDeclaration<OAuth2Service>;
154
+ }
@@ -0,0 +1,6 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { OAuth2Config } from '../models/oauth2-config.model';
3
+ /**
4
+ * Injection token for OAuth2 configuration
5
+ */
6
+ export declare const OAUTH2_CONFIG_TOKEN: InjectionToken<OAuth2Config>;
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "witspry-auth-ng-client",
3
+ "version": "1.0.0",
4
+ "description": "Witspry auth angular library for secure authentication with configurable providers",
5
+ "keywords": [
6
+ "angular",
7
+ "oauth2",
8
+ "pkce",
9
+ "authentication",
10
+ "security",
11
+ "oidc",
12
+ "authorization",
13
+ "jwt",
14
+ "token"
15
+ ],
16
+ "author": "Satya Jugran <satya.jugran@gmail.com>",
17
+ "license": "MIT",
18
+ "homepage": "https://github.com/satya-jugran/witspry-auth-ng-client#readme",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/satya-jugran/witspry-auth-ng-client.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/satya-jugran/witspry-auth-ng-client/issues"
25
+ },
26
+ "peerDependencies": {
27
+ "@angular/common": "^19.0.0",
28
+ "@angular/core": "^19.0.0",
29
+ "@angular/router": "^19.0.0",
30
+ "rxjs": "~7.8.0"
31
+ },
32
+ "dependencies": {
33
+ "tslib": "^2.3.0"
34
+ },
35
+ "sideEffects": false,
36
+ "module": "fesm2022/witspry-auth-ng-client.mjs",
37
+ "typings": "index.d.ts",
38
+ "exports": {
39
+ "./package.json": {
40
+ "default": "./package.json"
41
+ },
42
+ ".": {
43
+ "types": "./index.d.ts",
44
+ "default": "./fesm2022/witspry-auth-ng-client.mjs"
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,9 @@
1
+ export * from './lib/models/oauth2-config.model';
2
+ export * from './lib/models/oauth2-types.model';
3
+ export * from './lib/services/oauth2.service';
4
+ export * from './lib/services/oauth2-storage.service';
5
+ export * from './lib/interceptors/oauth2.interceptor';
6
+ export * from './lib/components/oauth2-callback/oauth2-callback.component';
7
+ export * from './lib/guards/oauth2-auth.guard';
8
+ export * from './lib/tokens/oauth2-config.token';
9
+ export * from './lib/ng-oauth2-pkce.service';