@startsimpli/auth 0.4.23 → 0.4.24

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": "@startsimpli/auth",
3
- "version": "0.4.23",
3
+ "version": "0.4.24",
4
4
  "description": "Shared authentication package for StartSimpli Next.js apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -95,46 +95,47 @@ export function AuthProvider({
95
95
  await redeemSsoCodeFromUrl();
96
96
  if (cancelled) return;
97
97
 
98
- // Cross-subdomain SSO fast-path: if we arrived from a central-auth login on
99
- // another *.startsimpli.com host, seed this origin's empty token store from
100
- // the shared `auth_session` cookie so restoreSession() finds a session
101
- // immediately. Guarded no-op when a local session already exists.
102
- hydrateSharedSession();
103
-
104
- if (initialSession) {
105
- authClient.setSession(initialSession);
106
- setState({
107
- session: initialSession,
108
- isLoading: false,
109
- isAuthenticated: true,
110
- });
111
- return;
112
- }
98
+ // Cross-subdomain SSO fast-path: if we arrived from a central-auth login on
99
+ // another *.startsimpli.com host, seed this origin's empty token store from
100
+ // the shared `auth_session` cookie so restoreSession() finds a session
101
+ // immediately. Guarded no-op when a local session already exists.
102
+ hydrateSharedSession();
103
+
104
+ if (initialSession) {
105
+ authClient.setSession(initialSession);
106
+ setState({
107
+ session: initialSession,
108
+ isLoading: false,
109
+ isAuthenticated: true,
110
+ });
111
+ return;
112
+ }
113
113
 
114
- const existing = authClient.getSession();
115
- if (existing) {
116
- setState({
117
- session: existing,
118
- isLoading: false,
119
- isAuthenticated: true,
120
- });
121
- return;
122
- }
114
+ const existing = authClient.getSession();
115
+ if (existing) {
116
+ setState({
117
+ session: existing,
118
+ isLoading: false,
119
+ isAuthenticated: true,
120
+ });
121
+ return;
122
+ }
123
123
 
124
- authClient
125
- .restoreSession()
126
- .then((session) => {
124
+ try {
125
+ const session = await authClient.restoreSession();
127
126
  if (cancelled) return;
128
127
  setState({
129
128
  session,
130
129
  isLoading: false,
131
130
  isAuthenticated: !!session,
132
131
  });
133
- })
134
- .catch(() => {
132
+ } catch {
135
133
  if (cancelled) return;
136
134
  setState({ session: null, isLoading: false, isAuthenticated: false });
137
- });
135
+ }
136
+ };
137
+
138
+ void init();
138
139
 
139
140
  return () => {
140
141
  cancelled = true;