@hotosm/hanko-auth 0.4.8 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotosm/hanko-auth",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "description": "Web component for HOTOSM SSO authentication with Hanko and OSM integration",
5
5
  "type": "module",
6
6
  "main": "dist/hanko-auth.umd.js",
@@ -21,7 +21,8 @@
21
21
  "dev": "vite",
22
22
  "build": "vite build",
23
23
  "watch": "vite build --watch",
24
- "preview": "vite preview"
24
+ "preview": "vite preview",
25
+ "prepublishOnly": "pnpm build"
25
26
  },
26
27
  "keywords": [
27
28
  "hotosm",
@@ -25,8 +25,10 @@ export const styles = css`
25
25
  display: flex;
26
26
  flex-direction: column;
27
27
  align-items: center;
28
+ width: 100%;
28
29
  gap: var(--hot-spacing-small);
29
30
  padding: var(--hot-spacing-large);
31
+ box-sizing: border-box;
30
32
  }
31
33
 
32
34
  .spinner {
@@ -147,15 +149,19 @@ export const styles = css`
147
149
  font-weight: var(--hot-font-weight-bold);
148
150
  color: var(--hot-color-gray-600);
149
151
  overflow: hidden;
152
+ flex-shrink: 0;
150
153
  }
151
154
 
152
155
  .profile-info {
153
- padding: var(--hot-spacing-x-small) var(--hot-spacing-medium);
156
+ min-width: 0;
154
157
  }
155
158
 
156
159
  .profile-email {
157
160
  font-size: var(--hot-font-size-small);
158
161
  font-weight: var(--hot-font-weight-bold);
162
+ overflow: hidden;
163
+ text-overflow: ellipsis;
164
+ white-space: nowrap;
159
165
  }
160
166
 
161
167
  .osm-section {
@@ -260,6 +266,7 @@ export const styles = css`
260
266
  overflow: hidden;
261
267
  font-weight: var(--hot-font-weight-semibold);
262
268
  color: white;
269
+ flex-shrink: 0;
263
270
  }
264
271
 
265
272
  .login-link {
package/src/hanko-auth.ts CHANGED
@@ -85,6 +85,7 @@ interface UserState {
85
85
  email: string | null;
86
86
  username: string | null;
87
87
  emailVerified: boolean;
88
+ avatarUrl?: string;
88
89
  }
89
90
 
90
91
  interface OSMData {
@@ -208,6 +209,21 @@ export class HankoAuth extends LitElement {
208
209
  private _hanko: any = null;
209
210
  private _isPrimary = false; // Is this the primary instance?
210
211
 
212
+ constructor() {
213
+ super();
214
+ try {
215
+ const cached = localStorage.getItem("hotosm-auth-user");
216
+ if (cached) {
217
+ const cachedUser: UserState = JSON.parse(cached);
218
+ this.user = cachedUser;
219
+ this.loading = false;
220
+ if (cachedUser.avatarUrl) {
221
+ this.profilePictureUrl = cachedUser.avatarUrl;
222
+ }
223
+ }
224
+ } catch {}
225
+ }
226
+
211
227
  // Get computed hankoUrl (priority: attribute > meta tag > window.HANKO_URL > origin)
212
228
  get hankoUrl(): string {
213
229
  if (this.hankoUrlAttr) {
@@ -657,6 +673,10 @@ export class HankoAuth extends LitElement {
657
673
  // Redirect to onboarding in progress, don't proceed
658
674
  return;
659
675
  }
676
+ await this.fetchProfileDisplayName();
677
+ if (this.user && this.profilePictureUrl) {
678
+ this.user = { ...this.user, avatarUrl: this.profilePictureUrl };
679
+ }
660
680
 
661
681
  this.dispatchEvent(
662
682
  new CustomEvent("hanko-login", {
@@ -677,8 +697,6 @@ export class HankoAuth extends LitElement {
677
697
  if (this.osmRequired) {
678
698
  await this.checkOSMConnection();
679
699
  }
680
- // Fetch profile display name
681
- await this.fetchProfileDisplayName();
682
700
  if (this.osmRequired && this.autoConnect && !this.osmConnected) {
683
701
  this.log("Auto-connecting to OSM (from existing session)...");
684
702
  this.handleOSMConnect();
@@ -1058,6 +1076,10 @@ export class HankoAuth extends LitElement {
1058
1076
  }
1059
1077
 
1060
1078
  this.log("User state updated:", this.user);
1079
+ await this.fetchProfileDisplayName();
1080
+ if (this.user && this.profilePictureUrl) {
1081
+ this.user = { ...this.user, avatarUrl: this.profilePictureUrl };
1082
+ }
1061
1083
 
1062
1084
  // Broadcast state changes to other instances
1063
1085
  if (this._isPrimary) {
@@ -1076,8 +1098,6 @@ export class HankoAuth extends LitElement {
1076
1098
  if (this.osmRequired) {
1077
1099
  await this.checkOSMConnection();
1078
1100
  }
1079
- // Fetch profile display name (only works with login.hotosm.org backend)
1080
- await this.fetchProfileDisplayName();
1081
1101
 
1082
1102
  // Auto-connect to OSM if required and auto-connect is enabled
1083
1103
  if (this.osmRequired && this.autoConnect && !this.osmConnected) {