@telicent-oss/fe-auth-lib 0.0.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telicent-oss/fe-auth-lib",
3
- "version": "0.0.2",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "description": "OAuth2 client library for Telicent Authentication Server",
@@ -50,5 +50,5 @@
50
50
  "engines": {
51
51
  "node": ">=20.19.0"
52
52
  },
53
- "gitHead": "658932e3799d7e9cbc44e256960c73e071d15abd"
53
+ "gitHead": "4868d793fefb4b0a564b028a85189e608d9ca927"
54
54
  }
@@ -37,14 +37,14 @@ export interface UserInfo {
37
37
  email: string;
38
38
  /** Preferred display name - NOT NULL in DB */
39
39
  preferred_name: string;
40
- /** Is Active - NOT NULL in DB */
41
- isActive: boolean;
42
- /** Groups - NOT NULL in DB */
43
- groups: string[];
44
- /** Roles - NOT NULL in DB */
45
- roles: string[];
46
- /** Permissions - NOT NULL in DB */
47
- permissions: string[];
40
+ /** Is Active - from ID token custom claim */
41
+ isActive?: boolean;
42
+ /** Groups - optional (not present in ID token) */
43
+ groups?: string[];
44
+ /** Roles - optional (not present in ID token) */
45
+ roles?: string[];
46
+ /** Permissions - optional (not present in ID token) */
47
+ permissions?: string[];
48
48
  // Standard OIDC claims (always present)
49
49
  /** Token issuer URL */
50
50
  iss: string;
@@ -74,7 +74,7 @@ export interface UserInfo {
74
74
  token_expired?: boolean;
75
75
  /** Token expiration timestamp (ISO string) */
76
76
  token_expires_at?: string;
77
- /** Source of user info ('id_token' or 'oauth2_userinfo_api') */
77
+ /** Source of user info (id_token; /userinfo removed) */
78
78
  source?: string;
79
79
  /** External identity provider details */
80
80
  externalProvider?: Record<string, unknown>;
@@ -343,22 +343,11 @@ declare class AuthServerOAuth2Client {
343
343
  getUserInfo(): UserInfo | null;
344
344
 
345
345
  /**
346
- * Get fresh user info from OAuth2 userinfo endpoint
346
+ * Returns ID token claims; /userinfo is no longer available.
347
347
  *
348
- * Fetches current user data from auth server. Slower than getUserInfo() but
349
- * guarantees fresh data. Use when you need up-to-date user information.
348
+ * Use getUserInfo() instead. This method remains for API compatibility.
350
349
  *
351
- * @returns Promise resolving to fresh user information
352
- * @throws {Error} If request fails or session invalid
353
- * @example
354
- * ```javascript
355
- * try {
356
- * const freshUserInfo = await authClient.getUserInfoFromAPI();
357
- * console.log("Fresh user data:", freshUserInfo);
358
- * } catch (error) {
359
- * console.error("Failed to get fresh user info:", error);
360
- * }
361
- * ```
350
+ * @returns Promise resolving to user information or null
362
351
  */
363
352
  getUserInfoFromAPI(): Promise<UserInfo | null>;
364
353
 
@@ -601,6 +601,7 @@ class AuthServerOAuth2Client {
601
601
  sub: payload.sub,
602
602
  email: payload.email,
603
603
  preferred_name: payload.preferred_name,
604
+ isActive: payload.isActive,
604
605
  iss: payload.iss,
605
606
  aud: payload.aud,
606
607
  exp: payload.exp,
@@ -646,25 +647,10 @@ class AuthServerOAuth2Client {
646
647
 
647
648
  // Get fresh user info from OAuth2 userinfo endpoint (UNIFIED ENDPOINT)
648
649
  async getUserInfoFromAPI() {
649
- try {
650
- const response = await this.makeAuthenticatedRequest(
651
- `${this.config.authServerUrl}/userinfo`
652
- );
653
-
654
- if (response.ok) {
655
- const data = await response.json();
656
- return {
657
- ...data,
658
- source: this.isCrossDomain
659
- ? "oauth2_userinfo_api_cross_domain"
660
- : "oauth2_userinfo_api_same_domain",
661
- };
662
- }
663
- return null;
664
- } catch (error) {
665
- console.error("Error getting user info from OAuth2 API:", error);
666
- return null;
667
- }
650
+ console.warn(
651
+ "getUserInfoFromAPI: /userinfo has been removed; returning ID token claims instead."
652
+ );
653
+ return this.getUserInfo();
668
654
  }
669
655
 
670
656
  // Get raw ID token from storage
@@ -977,10 +963,4 @@ if (typeof module !== "undefined" && module.exports) {
977
963
  // ES modules
978
964
  exports.default = AuthServerOAuth2Client;
979
965
  exports.AuthServerOAuth2Client = AuthServerOAuth2Client;
980
- }
981
-
982
- // Create global OAuth client instance for browser use
983
- if (typeof window !== "undefined") {
984
- window.AuthServerOAuth2Client = AuthServerOAuth2Client;
985
- window.authServerOAuth2Client = new AuthServerOAuth2Client();
986
- }
966
+ }
package/src/schemas.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare const GetUserInfoSchema: z.ZodObject<{
9
9
  sub: z.ZodString;
10
10
  email: z.ZodString;
11
11
  preferred_name: z.ZodString;
12
+ isActive: z.ZodOptional<z.ZodBoolean>;
12
13
 
13
14
  // Standard OIDC claims (always present)
14
15
  iss: z.ZodString;
package/src/schemas.js CHANGED
@@ -20,9 +20,10 @@ try {
20
20
  if (z) {
21
21
  GetUserInfoSchema = z.object({
22
22
  // Core user identity (from JWTConfig.java:169-171)
23
- sub: z.string(), // Always present
24
- email: z.string().email(), // NOT NULL in DB
25
- preferred_name: z.string(), // NOT NULL in DB
23
+ sub: z.string(), // Always present
24
+ email: z.string().email(), // NOT NULL in DB
25
+ preferred_name: z.string(), // NOT NULL in DB
26
+ isActive: z.boolean().optional(), // Custom claim from ID token
26
27
 
27
28
  // Standard OIDC claims (always present)
28
29
  iss: z.string(), // Issuer URL