@orsetra/shared-auth 1.0.6 → 1.0.7

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.
@@ -28,12 +28,15 @@ export function SessionProvider({ children, config }: SessionProviderProps) {
28
28
  const [user, setUser] = useState<User | null>(null)
29
29
  const [isLoading, setIsLoading] = useState(true)
30
30
  const [isConfigured, setIsConfigured] = useState(false)
31
+ // Configure auth synchronously before any render
32
+ if (!ZitadelAuthService.isConfigured()) {
33
+ ZitadelAuthService.configureAuth(config)
34
+ setIsConfigured(true)
35
+ }
31
36
 
32
37
  useEffect(() => {
33
38
  const loadUser = async () => {
34
39
  try {
35
- ZitadelAuthService.configureAuth(config)
36
- setIsConfigured(true)
37
40
  const currentUser = await ZitadelAuthService.getUser()
38
41
  setUser(currentUser)
39
42
  } catch (error) {
package/package.json CHANGED
@@ -1,54 +1,54 @@
1
- {
2
- "name": "@orsetra/shared-auth",
3
- "version": "1.0.6",
4
- "description": "Shared authentication utilities for Orsetra platform using Zitadel",
5
- "main": "./index.ts",
6
- "types": "./index.ts",
7
- "exports": {
8
- ".": "./index.ts",
9
- "./config": "./config/zitadel.config.ts",
10
- "./services": "./services/zitadel.auth.service.ts",
11
- "./components": "./components/index.ts",
12
- "./utils": "./utils/index.ts"
13
- },
14
- "files": [
15
- "index.ts",
16
- "ZitadelProvider.tsx",
17
- "SessionProvider.tsx",
18
- "ProtectedRoute.tsx",
19
- "config",
20
- "services",
21
- "components",
22
- "hooks",
23
- "utils",
24
- "README.md"
25
- ],
26
- "publishConfig": {
27
- "access": "public"
28
- },
29
- "repository": {
30
- "type": "git",
31
- "url": "https://github.com/orsetra/console-ui.git",
32
- "directory": "packages/shared-auth"
33
- },
34
- "keywords": [
35
- "authentication",
36
- "zitadel",
37
- "oidc",
38
- "oauth2",
39
- "orsetra"
40
- ],
41
- "peerDependencies": {
42
- "react": "^18.0.0 || ^19.0.0",
43
- "react-dom": "^18.0.0 || ^19.0.0",
44
- "next": "^14.0.0 || ^15.0.0"
45
- },
46
- "dependencies": {
47
- "oidc-client-ts": "^3.2.1",
48
- "jose": "^5.9.6"
49
- },
50
- "devDependencies": {
51
- "@types/react": "^19",
52
- "typescript": "^5"
53
- }
54
- }
1
+ {
2
+ "name": "@orsetra/shared-auth",
3
+ "version": "1.0.7",
4
+ "description": "Shared authentication utilities for Orsetra platform using Zitadel",
5
+ "main": "./index.ts",
6
+ "types": "./index.ts",
7
+ "exports": {
8
+ ".": "./index.ts",
9
+ "./config": "./config/zitadel.config.ts",
10
+ "./services": "./services/zitadel.auth.service.ts",
11
+ "./components": "./components/index.ts",
12
+ "./utils": "./utils/index.ts"
13
+ },
14
+ "files": [
15
+ "index.ts",
16
+ "ZitadelProvider.tsx",
17
+ "SessionProvider.tsx",
18
+ "ProtectedRoute.tsx",
19
+ "config",
20
+ "services",
21
+ "components",
22
+ "hooks",
23
+ "utils",
24
+ "README.md"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/orsetra/console-ui.git",
32
+ "directory": "packages/shared-auth"
33
+ },
34
+ "keywords": [
35
+ "authentication",
36
+ "zitadel",
37
+ "oidc",
38
+ "oauth2",
39
+ "orsetra"
40
+ ],
41
+ "peerDependencies": {
42
+ "react": "^18.0.0 || ^19.0.0",
43
+ "react-dom": "^18.0.0 || ^19.0.0",
44
+ "next": "^14.0.0 || ^15.0.0"
45
+ },
46
+ "dependencies": {
47
+ "oidc-client-ts": "^3.2.1",
48
+ "jose": "^5.9.6"
49
+ },
50
+ "devDependencies": {
51
+ "@types/react": "^19",
52
+ "typescript": "^5"
53
+ }
54
+ }
@@ -75,9 +75,13 @@ export class ZitadelAuthService {
75
75
  }
76
76
  }
77
77
 
78
+ static isConfigured(): boolean {
79
+ return this.zitadelAuth !== null;
80
+ }
81
+
78
82
  static async getUser(): Promise<User | null> {
79
83
  try {
80
- return await this.getAuth().userManager.getUser();
84
+ return await this.zitadelAuth!.userManager.getUser();
81
85
  } catch (error) {
82
86
  console.error('Error getting user:', error);
83
87
  return null;