@geogirafe/lib-geoportal 1.3.0-dev.3008485984 → 1.3.0-dev.3018313151

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.
@@ -6,7 +6,7 @@ export default class OauthComponent extends GirafeHTMLElement {
6
6
  constructor(name?: string);
7
7
  private registerEvents;
8
8
  getDisplayName(): string;
9
- getFullName(): string | null;
9
+ getFullName(): string | undefined;
10
10
  /**
11
11
  * Gets the user initials
12
12
  * super_admin -> SA
@@ -1,6 +1,14 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
1
7
  import { html as uHtml } from 'uhtml';
2
8
  // SPDX-License-Identifier: Apache-2.0
3
9
  import GirafeHTMLElement from '../../base/GirafeHTMLElement.js';
10
+ import { UsedInTemplateOnly } from '../../decorators.js';
11
+ import { Auth_UnknownUserInitials, Auth_UnknownUserName } from '../../tools/auth/authuserinfo.js';
4
12
  export default class OauthComponent extends GirafeHTMLElement {
5
13
  templateUrl = null;
6
14
  styleUrls = null;
@@ -22,20 +30,10 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
22
30
  this.subscribe(/oauth\.userInfo.*/, () => this.refreshRender());
23
31
  }
24
32
  getDisplayName() {
25
- if (this.state.oauth.userInfo?.display_name) {
26
- return this.state.oauth.userInfo.display_name;
27
- }
28
- else if (this.state.oauth.userInfo?.username) {
29
- return this.state.oauth.userInfo.username;
30
- }
31
- return this.state.oauth.userInfo?.email ?? 'Unknown User';
33
+ return this.state.oauth.userInfo?.displayName ?? Auth_UnknownUserName;
32
34
  }
33
35
  getFullName() {
34
- if (this.state.oauth.userInfo?.given_name) {
35
- return `${this.state.oauth.userInfo?.given_name} ${this.state.oauth.userInfo?.family_name}`;
36
- }
37
- // No full name
38
- return null;
36
+ return this.state.oauth.userInfo?.fullName;
39
37
  }
40
38
  /**
41
39
  * Gets the user initials
@@ -44,28 +42,20 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
44
42
  * @returns
45
43
  */
46
44
  getInitials() {
47
- const name = this.getFullName() ?? this.getDisplayName();
48
- const parts = name.split(/[\s_-]+/).filter((part) => part.length > 0);
49
- if (parts.length === 0) {
50
- return '??';
51
- }
52
- else if (parts.length === 1) {
53
- return parts[0].substring(0, 2).toUpperCase();
54
- }
55
- return (parts[0][0] + parts.at(-1)[0]).toUpperCase();
45
+ return this.state.oauth.userInfo?.initials ?? Auth_UnknownUserInitials;
56
46
  }
57
47
  onLoginClick() {
58
48
  if (!this.context.configManager.Config.oauth && !this.context.configManager.Config.gmfauth) {
59
49
  throw new Error('Authentication is not configured on this instance. Login cannot be done.');
60
50
  }
61
51
  else {
62
- this.context.authManager.login();
52
+ void this.context.authManager.login();
63
53
  }
64
54
  }
65
55
  async onLogoutClick() {
66
56
  const logout = await window.gConfirm('Do you want to logout ?', 'Logout');
67
57
  if (logout) {
68
- this.context.authManager.logout();
58
+ void this.context.authManager.logout();
69
59
  }
70
60
  }
71
61
  connectedCallback() {
@@ -75,3 +65,12 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
75
65
  super.girafeTranslate();
76
66
  }
77
67
  }
68
+ __decorate([
69
+ UsedInTemplateOnly()
70
+ ], OauthComponent.prototype, "getDisplayName", null);
71
+ __decorate([
72
+ UsedInTemplateOnly()
73
+ ], OauthComponent.prototype, "getFullName", null);
74
+ __decorate([
75
+ UsedInTemplateOnly()
76
+ ], OauthComponent.prototype, "getInitials", null);
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "GeoGirafe PSC",
6
6
  "url": "https://doc.geogirafe.org"
7
7
  },
8
- "version": "1.3.0-dev.3008485984",
8
+ "version": "1.3.0-dev.3018313151",
9
9
  "type": "module",
10
10
  "engines": {
11
11
  "node": ">=20.19.0"
@@ -1 +1 @@
1
- {"version":"1.3.0-dev.3008485984", "build":"3008485984", "date":"30/10/2026"}
1
+ {"version":"1.3.0-dev.3018313151", "build":"3018313151", "date":"02/11/2026"}
@@ -1,6 +1,7 @@
1
1
  import IGirafeContext from '../context/icontext.js';
2
2
  export default abstract class AbstractConnectManager {
3
3
  private readonly storagePath;
4
+ private readonly urlParameterForHash;
4
5
  protected readonly context: IGirafeContext;
5
6
  constructor(context: IGirafeContext);
6
7
  protected get state(): import("../main.js").State;
@@ -11,7 +12,7 @@ export default abstract class AbstractConnectManager {
11
12
  protected loggedOutFromBackend(): void;
12
13
  handleErrorFromIssuer(): void;
13
14
  handleUnknownError(error: Error): void;
14
- protected loggedOut(): void;
15
+ protected loggedOut(saveState?: boolean): void;
15
16
  /**
16
17
  * The RedirectUrl has to be the same for all call to the issuer
17
18
  * Because the authentication is given for a specific redirectUrl.
@@ -21,6 +22,11 @@ export default abstract class AbstractConnectManager {
21
22
  protected set redirectUrl(value: string);
22
23
  protected getLoginRedirectUrl(silent: boolean): string;
23
24
  protected getLogoutRedirectUrl(): string;
25
+ /**
26
+ * Save the URL hash to a query parameter since some OIDC providers don't allow URL hashes in the redirect URL
27
+ */
28
+ protected preserveUrlHash(url: URL): void;
29
+ protected restoreUrlHash(url: URL): void;
24
30
  protected loadFromLocalStorage(path: string): unknown;
25
31
  protected saveToLocalStorage(path: string, value: string): void;
26
32
  protected resetUrl(): void;
@@ -1,6 +1,7 @@
1
1
  import { SHORTLINK_PARAMETER } from '../share/iurlshortener.js';
2
2
  export default class AbstractConnectManager {
3
3
  storagePath = 'oAuth';
4
+ urlParameterForHash = 'hash';
4
5
  context;
5
6
  constructor(context) {
6
7
  this.context = context;
@@ -20,8 +21,10 @@ export default class AbstractConnectManager {
20
21
  this.state.oauth.error = error.message;
21
22
  this.state.oauth.status = 'loginFailed';
22
23
  }
23
- loggedOut() {
24
- this.context.sessionManager.saveStateToSession();
24
+ loggedOut(saveState = true) {
25
+ if (saveState) {
26
+ this.context.sessionManager.saveStateToSession();
27
+ }
25
28
  this.state.oauth.status = 'loggedOut';
26
29
  this.state.oauth.tokens = undefined;
27
30
  this.state.oauth.userInfo = undefined;
@@ -48,7 +51,7 @@ export default class AbstractConnectManager {
48
51
  url = new URL(this.context.urlManager.getBaseUrlPath());
49
52
  }
50
53
  url.searchParams.append('authentified', 'true');
51
- url.hash = this.context.urlManager.getHash() ?? '';
54
+ this.preserveUrlHash(url);
52
55
  return url.toString();
53
56
  }
54
57
  getLogoutRedirectUrl() {
@@ -57,9 +60,27 @@ export default class AbstractConnectManager {
57
60
  }
58
61
  const url = new URL(this.context.urlManager.getBaseUrlPath());
59
62
  url.searchParams.append('authentified', 'false');
60
- url.hash = this.context.urlManager.getHash() ?? '';
63
+ this.preserveUrlHash(url);
61
64
  return url.toString();
62
65
  }
66
+ /**
67
+ * Save the URL hash to a query parameter since some OIDC providers don't allow URL hashes in the redirect URL
68
+ */
69
+ preserveUrlHash(url) {
70
+ const hash = this.context.urlManager.getHash();
71
+ if (hash?.length && hash !== 'session') {
72
+ console.error('App state in URL!!!');
73
+ }
74
+ if (hash) {
75
+ url.searchParams.append(this.urlParameterForHash, hash);
76
+ }
77
+ }
78
+ restoreUrlHash(url) {
79
+ const urlHash = this.context.urlManager.getParam(this.urlParameterForHash);
80
+ if (urlHash) {
81
+ url.hash = urlHash;
82
+ }
83
+ }
63
84
  loadFromLocalStorage(path) {
64
85
  return this.context.userDataManager.getFromLocalStorage(`${this.storagePath}.${path}`) ?? '';
65
86
  }
@@ -73,7 +94,7 @@ export default class AbstractConnectManager {
73
94
  if (shortId) {
74
95
  url.searchParams.set(SHORTLINK_PARAMETER, shortId);
75
96
  }
76
- url.hash = this.context.urlManager.getHash() ?? '';
97
+ this.restoreUrlHash(url);
77
98
  this.context.urlManager.updateUrl(url);
78
99
  }
79
100
  finalizeLoginWorkflow() {
@@ -82,12 +82,12 @@ export default class AuthManager extends GirafeSingleton {
82
82
  await this.gmfManager.loginWithToken();
83
83
  }
84
84
  // And then we get the UserInfos
85
- const previousUsername = this.state.oauth.userInfo?.username;
85
+ const previousUserIdentifier = this.state.oauth.userInfo?.identifier;
86
86
  await this.gmfManager.getUserInfo();
87
- if (this.state.oauth.userInfo?.username) {
87
+ if (this.state.oauth.userInfo?.identifier) {
88
88
  // TODO REG : At the moment we just test if the username has changed,
89
89
  // but actually we should test if some of the rights have changed
90
- this.state.oauth.somethingChanged = this.state.oauth.userInfo.username !== previousUsername;
90
+ this.state.oauth.somethingChanged = this.state.oauth.userInfo.identifier !== previousUserIdentifier;
91
91
  this.state.oauth.status = 'loggedIn';
92
92
  }
93
93
  else {
@@ -0,0 +1,42 @@
1
+ type Functionalities = {
2
+ authorized_plugins?: string[];
3
+ };
4
+ export declare const Auth_UnknownUserName = "Unknown User";
5
+ export declare const Auth_UnknownUserInitials = "??";
6
+ /**
7
+ * This class represents user information extracted from the authentication process' userInfo endpoint.
8
+ * It supports mapping of GMF custom properties and OIDC standard properties.
9
+ */
10
+ export default class AuthUserInfo {
11
+ identifier: string | undefined;
12
+ displayName: string;
13
+ fullName: string | undefined;
14
+ initials: string;
15
+ email: string | undefined;
16
+ roles: unknown[] | undefined;
17
+ two_factor_enabled: boolean;
18
+ functionalities: Functionalities;
19
+ constructor(userInfo: Record<string, unknown>);
20
+ /**
21
+ * This is the unique identifier at the provider.
22
+ * Check for the OIDC standard field `sub`, then try GMF-specific field `username`.
23
+ */
24
+ private extractIdentifier;
25
+ /**
26
+ * This corresponds to an account or user name.
27
+ * Check first for OIDC standard field `preferred_username`, then try GMF-specific fields `display_name` and `username`.
28
+ * If none of these fields are found, try `email` or fall back to `Unknown User`.
29
+ */
30
+ private extractDisplayName;
31
+ /**
32
+ * Gets the OIDC `name` field, falling back to `given_name` and `family_name`.
33
+ */
34
+ private extractFullName;
35
+ /**
36
+ * Extracts the first letters of the full name or the this.displayName. Examples:
37
+ * super_admin -> SA
38
+ * Gustave-André de la Girouette -> GG
39
+ */
40
+ private extractInitials;
41
+ }
42
+ export {};
@@ -0,0 +1,76 @@
1
+ export const Auth_UnknownUserName = 'Unknown User';
2
+ export const Auth_UnknownUserInitials = '??';
3
+ /**
4
+ * This class represents user information extracted from the authentication process' userInfo endpoint.
5
+ * It supports mapping of GMF custom properties and OIDC standard properties.
6
+ */
7
+ export default class AuthUserInfo {
8
+ identifier;
9
+ displayName;
10
+ fullName;
11
+ initials;
12
+ email;
13
+ roles;
14
+ two_factor_enabled;
15
+ functionalities;
16
+ constructor(userInfo) {
17
+ this.identifier = this.extractIdentifier(userInfo);
18
+ this.displayName = this.extractDisplayName(userInfo);
19
+ this.fullName = this.extractFullName(userInfo);
20
+ this.initials = this.extractInitials();
21
+ this.email = userInfo['email'] ?? undefined;
22
+ this.roles = userInfo['roles'] ?? undefined; // Not parsed yet
23
+ this.two_factor_enabled = userInfo['two_factor_enabled'] === 'true';
24
+ this.functionalities = userInfo['functionalities'] ?? {};
25
+ }
26
+ /**
27
+ * This is the unique identifier at the provider.
28
+ * Check for the OIDC standard field `sub`, then try GMF-specific field `username`.
29
+ */
30
+ extractIdentifier(userInfo) {
31
+ return userInfo['sub'] ?? userInfo['username'] ?? undefined;
32
+ }
33
+ /**
34
+ * This corresponds to an account or user name.
35
+ * Check first for OIDC standard field `preferred_username`, then try GMF-specific fields `display_name` and `username`.
36
+ * If none of these fields are found, try `email` or fall back to `Unknown User`.
37
+ */
38
+ extractDisplayName(userInfo) {
39
+ return (userInfo['preferred_username'] ??
40
+ userInfo['display_name'] ??
41
+ userInfo['username'] ??
42
+ userInfo['email'] ??
43
+ Auth_UnknownUserName);
44
+ }
45
+ /**
46
+ * Gets the OIDC `name` field, falling back to `given_name` and `family_name`.
47
+ */
48
+ extractFullName(userInfo) {
49
+ if (userInfo['name']) {
50
+ return userInfo['name'];
51
+ }
52
+ if (userInfo['given_name']) {
53
+ return `${userInfo['given_name']} ${userInfo['family_name']}`;
54
+ }
55
+ return undefined;
56
+ }
57
+ /**
58
+ * Extracts the first letters of the full name or the this.displayName. Examples:
59
+ * super_admin -> SA
60
+ * Gustave-André de la Girouette -> GG
61
+ */
62
+ extractInitials() {
63
+ const name = this.fullName ?? this.displayName;
64
+ if (name === Auth_UnknownUserName) {
65
+ return Auth_UnknownUserInitials;
66
+ }
67
+ const parts = name.split(/[\s_-]+/).filter((part) => part.length > 0);
68
+ if (parts.length === 0) {
69
+ return Auth_UnknownUserInitials;
70
+ }
71
+ else if (parts.length === 1) {
72
+ return parts[0].substring(0, 2).toUpperCase();
73
+ }
74
+ return (parts[0][0] + parts.at(-1)[0]).toUpperCase();
75
+ }
76
+ }
@@ -1,4 +1,5 @@
1
1
  import AbstractConnectManager from './abstractconnectmanager.js';
2
+ import AuthUserInfo from './authuserinfo.js';
2
3
  /**
3
4
  * For diverse reasons, this could NOT be done using the oAuth2 mechanisms of GMF:
4
5
  * 1. There is no .well-know discovery endpoint
@@ -60,7 +61,7 @@ export default class GMFConnectManager extends AbstractConnectManager {
60
61
  }
61
62
  async silentLogin() {
62
63
  await this.gmfManager.getUserInfo();
63
- this.state.oauth.status = this.state.oauth.userInfo?.username ? 'loggedIn' : 'loggedOut';
64
+ this.state.oauth.status = this.state.oauth.userInfo?.identifier ? 'loggedIn' : 'loggedOut';
64
65
  }
65
66
  async logout() {
66
67
  // Nothing more to do here, just mark as loggedOut
@@ -86,8 +87,9 @@ export default class GMFConnectManager extends AbstractConnectManager {
86
87
  async refreshToken() {
87
88
  console.debug('Refreshing token');
88
89
  const userInfoUrl = `${this.authConfig.url}loginuser`;
89
- this.state.oauth.userInfo = await fetch(userInfoUrl).then((r) => r.json());
90
- if (!this.state.oauth.userInfo?.username) {
90
+ const rawUserInfo = await fetch(userInfoUrl).then((r) => r.json());
91
+ this.state.oauth.userInfo = new AuthUserInfo(rawUserInfo);
92
+ if (!this.state.oauth.userInfo?.identifier) {
91
93
  this.loggedOutFromBackend();
92
94
  }
93
95
  else {
@@ -1,3 +1,4 @@
1
+ import AuthUserInfo from './authuserinfo.js';
1
2
  export default class GMFManager {
2
3
  context;
3
4
  constructor(context) {
@@ -59,7 +60,8 @@ export default class GMFManager {
59
60
  async getUserInfo() {
60
61
  console.debug('Auth: 3. Get UserInfo');
61
62
  const userInfoUrl = this.isOAuth ? this.gmfConfigForOAuth.userInfoUrl : `${this.gmfConfigForGmfAuth.url}loginuser`;
62
- this.state.oauth.userInfo = await fetch(userInfoUrl).then((r) => r.json());
63
+ const rawUserInfo = await fetch(userInfoUrl).then((r) => r.json());
64
+ this.state.oauth.userInfo = new AuthUserInfo(rawUserInfo);
63
65
  }
64
66
  async getAnonymousUserInfo() {
65
67
  console.debug('Auth: 3. Get Anonymous UserInfo');
@@ -67,7 +69,8 @@ export default class GMFManager {
67
69
  ? this.gmfConfigForOAuth.anonymousUserInfoUrl
68
70
  : `${this.gmfConfigForGmfAuth.url}loginuser`;
69
71
  if (anonymousUserInfoUrl) {
70
- this.state.oauth.userInfo = await fetch(anonymousUserInfoUrl).then((r) => r.json());
72
+ const rawUserInfo = await fetch(anonymousUserInfoUrl).then((r) => r.json());
73
+ this.state.oauth.userInfo = new AuthUserInfo(rawUserInfo);
71
74
  }
72
75
  }
73
76
  }
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  import AbstractConnectManager from './abstractconnectmanager.js';
3
- import { authorizationCodeGrantRequest, calculatePKCECodeChallenge, discoveryRequest, generateRandomCodeVerifier, processAuthorizationCodeResponse, processDiscoveryResponse, processRefreshTokenResponse, refreshTokenGrantRequest, TlsClientAuth, validateAuthResponse } from 'oauth4webapi';
3
+ import { authorizationCodeGrantRequest, calculatePKCECodeChallenge, discoveryRequest, expectNoNonce, generateRandomCodeVerifier, generateRandomNonce, processAuthorizationCodeResponse, processDiscoveryResponse, processRefreshTokenResponse, refreshTokenGrantRequest, TlsClientAuth, validateAuthResponse } from 'oauth4webapi';
4
4
  export default class OpenIdConnectManager extends AbstractConnectManager {
5
5
  authorizationServer;
6
6
  silentLoginIframe;
@@ -41,7 +41,9 @@ export default class OpenIdConnectManager extends AbstractConnectManager {
41
41
  }
42
42
  }
43
43
  else if (this.isLoggedOut()) {
44
- this.loggedOut();
44
+ // When a user manually logs out, the stored state has not yet been reloaded.
45
+ // Prevent the current (empty) state from overwriting the stored state.
46
+ this.loggedOut(false);
45
47
  }
46
48
  }
47
49
  /**
@@ -99,6 +101,13 @@ export default class OpenIdConnectManager extends AbstractConnectManager {
99
101
  authorizationUrl.searchParams.set(key, value);
100
102
  }
101
103
  }
104
+ // An oidc nonce protects the id token from replay attacks and should be treated mandatory in modern apps.
105
+ // ref. https://auth0.com/blog/demystifying-oauth-security-state-vs-nonce-vs-pkce/
106
+ if (this.issuerConfig.algorithm === 'oidc') {
107
+ const nonce = generateRandomNonce();
108
+ this.saveToLocalStorage('nonce', nonce);
109
+ authorizationUrl.searchParams.set('nonce', nonce);
110
+ }
102
111
  return authorizationUrl;
103
112
  }
104
113
  getClient() {
@@ -174,9 +183,17 @@ export default class OpenIdConnectManager extends AbstractConnectManager {
174
183
  const client = this.getClient();
175
184
  const currentUrl = new URL(document.URL);
176
185
  try {
186
+ const nonce = this.loadFromLocalStorage('nonce');
187
+ const expectedNonce = typeof nonce === 'string' && nonce ? nonce : expectNoNonce;
177
188
  const params = validateAuthResponse(authorizationServer, client, currentUrl);
178
189
  const response = await authorizationCodeGrantRequest(authorizationServer, client, TlsClientAuth(), params, this.redirectUrl, this.codeVerifier);
179
- const openIdTokens = await processAuthorizationCodeResponse(authorizationServer, client, response);
190
+ const openIdTokens = await processAuthorizationCodeResponse(authorizationServer, client, response, {
191
+ expectedNonce
192
+ });
193
+ if (nonce) {
194
+ // A nonce is only valid for exactly one login attempt
195
+ this.saveToLocalStorage('nonce', '');
196
+ }
180
197
  this.setToken(openIdTokens);
181
198
  this.state.oauth.audience = this.issuerConfig.audience;
182
199
  }
package/tools/main.d.ts CHANGED
@@ -4,6 +4,7 @@ export { default as GeoGirafeApp } from './app/geogirafeapp.js';
4
4
  export { default as ApplicationLifeCycleManager } from './app/lifecyclemanager.js';
5
5
  export { default as AbstractConnectManager } from './auth/abstractconnectmanager.js';
6
6
  export { default as AuthManager } from './auth/authmanager.js';
7
+ export { default as AuthUserInfo, Auth_UnknownUserName, Auth_UnknownUserInitials } from './auth/authuserinfo.js';
7
8
  export { default as GMFConnectManager } from './auth/gmfconnectmanager.js';
8
9
  export { default as GMFManager } from './auth/gmfmanager.js';
9
10
  export { default as OpenIdConnectManager } from './auth/openidconnectmanager.js';
package/tools/main.js CHANGED
@@ -4,6 +4,7 @@ export { default as GeoGirafeApp } from './app/geogirafeapp.js';
4
4
  export { default as ApplicationLifeCycleManager } from './app/lifecyclemanager.js';
5
5
  export { default as AbstractConnectManager } from './auth/abstractconnectmanager.js';
6
6
  export { default as AuthManager } from './auth/authmanager.js';
7
+ export { default as AuthUserInfo, Auth_UnknownUserName, Auth_UnknownUserInitials } from './auth/authuserinfo.js';
7
8
  export { default as GMFConnectManager } from './auth/gmfconnectmanager.js';
8
9
  export { default as GMFManager } from './auth/gmfmanager.js';
9
10
  export { default as OpenIdConnectManager } from './auth/openidconnectmanager.js';
@@ -1,3 +1,4 @@
1
+ import AuthUserInfo from '../auth/authuserinfo.js';
1
2
  import MapPosition from './mapposition.js';
2
3
  import GlobeState from './globe.js';
3
4
  import LayoutState from './layout.js';
@@ -46,20 +47,6 @@ export type News = {
46
47
  lastViewDate: number;
47
48
  lastPublishDate: number;
48
49
  };
49
- type Functionalities = {
50
- authorized_plugins?: string[];
51
- };
52
- type UserInfo = {
53
- username: string;
54
- display_name: string;
55
- email: string;
56
- family_name: string;
57
- given_name: string;
58
- is_intranet: boolean;
59
- two_factor_enable: boolean;
60
- roles: unknown[];
61
- functionalities?: Functionalities;
62
- };
63
50
  /**
64
51
  * Login states :
65
52
  * 1. issuer.loggedIn : Logged in to identity provider
@@ -72,7 +59,7 @@ type UserInfo = {
72
59
  type LoginState = {
73
60
  status: 'not-initialized' | 'issuer.loggedIn' | 'loggedIn' | 'loginFailed' | 'backend.loggedOut' | 'loggedOut' | 'logoutFailed';
74
61
  tokens?: TokenEndpointResponse;
75
- userInfo?: UserInfo;
62
+ userInfo?: AuthUserInfo;
76
63
  audience: string[];
77
64
  error?: string;
78
65
  somethingChanged: boolean;
@@ -4,7 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- // SPDX-License-Identifier: Apache-2.0
8
7
  import MapPosition from './mapposition.js';
9
8
  import GlobeState from './globe.js';
10
9
  import LayoutState from './layout.js';
@@ -1,8 +1,5 @@
1
1
  import GirafeSingleton from '../../base/GirafeSingleton.js';
2
2
  declare class ThemesManager extends GirafeSingleton {
3
- anonymousUserInfo: {
4
- u: string;
5
- };
6
3
  private get state();
7
4
  initializeSingleton(): Promise<void>;
8
5
  private initialize;
@@ -21,7 +21,6 @@ import { DEFAULT_OPACITY, OPACITY_FOR_DEFAULT_BASEMAP } from './themes-config.js
21
21
  import Layer from '../../models/layers/layer.js';
22
22
  import { applyDefaultPrefixToUrl } from '../utils/utils.js';
23
23
  class ThemesManager extends GirafeSingleton {
24
- anonymousUserInfo = { u: 'anonymous' };
25
24
  get state() {
26
25
  return this.context.stateManager.state;
27
26
  }
@@ -76,8 +76,16 @@ function readCurveElement(parser, node, objectStack) {
76
76
  return lineStringToPieces(parser.readLineString(node, objectStack));
77
77
  }
78
78
  if (node.localName === 'Curve') {
79
- warnIfCurveHasUnsupportedSegments(node);
80
- return lineStringToPieces(parser.readCurve(node, objectStack));
79
+ const lineString = parser.readCurve(node, objectStack);
80
+ if (lineString && lineString.getCoordinates().length > 0) {
81
+ return lineStringToPieces(lineString);
82
+ }
83
+ // OpenLayers only understands LineStringSegment inside gml:Curve.
84
+ // QGIS WFS emits ArcString segments; read their posList directly.
85
+ return readSegmentsPosList(node);
86
+ }
87
+ if (node.localName === 'ArcString') {
88
+ return readSegmentsPosList(node);
81
89
  }
82
90
  if (node.localName === 'CompositeCurve') {
83
91
  return geometryToPieces(parser.readCompositeCurve(node, objectStack));
@@ -88,6 +96,40 @@ function readCurveElement(parser, node, objectStack) {
88
96
  console.warn(`CompositeCurve member contains unsupported ${describeNode(node)}.`);
89
97
  return [];
90
98
  }
99
+ function readSegmentsPosList(node) {
100
+ const pieces = [];
101
+ const containers = node.localName === 'Curve' ? Array.from(node.children).filter((c) => c.localName === 'segments') : [node];
102
+ for (const container of containers) {
103
+ for (const segment of Array.from(container.children)) {
104
+ if (segment.localName !== 'ArcString' && segment.localName !== 'LineStringSegment') {
105
+ console.warn(`CompositeCurve member contains unsupported ${describeNode(segment)} segment.`);
106
+ continue;
107
+ }
108
+ const piece = readPosListPiece(segment);
109
+ if (piece.length > 0) {
110
+ pieces.push(piece);
111
+ }
112
+ }
113
+ }
114
+ return pieces;
115
+ }
116
+ function readPosListPiece(node) {
117
+ const posList = Array.from(node.children).find((child) => child.localName === 'posList');
118
+ if (!posList) {
119
+ return [];
120
+ }
121
+ const dimension = Number(posList.getAttribute('srsDimension') ?? posList.getAttribute('dimension') ?? 2) || 2;
122
+ const values = posList.textContent?.trim().split(/\s+/).map(Number) ?? [];
123
+ if (values.length === 0 || values.some((v) => Number.isNaN(v)) || values.length % dimension !== 0) {
124
+ console.warn(`CompositeCurve member contains invalid posList at ${describeNode(node)}.`);
125
+ return [];
126
+ }
127
+ const piece = [];
128
+ for (let i = 0; i < values.length; i += dimension) {
129
+ piece.push(values.slice(i, i + dimension));
130
+ }
131
+ return piece;
132
+ }
91
133
  function readOrientableCurve(parser, node, objectStack) {
92
134
  const baseCurve = Array.from(node.children).find((child) => child.localName === 'baseCurve');
93
135
  if (!baseCurve) {
@@ -103,16 +145,6 @@ function readOrientableCurve(parser, node, objectStack) {
103
145
  }
104
146
  return buildCompositeGeometry(pieces);
105
147
  }
106
- function warnIfCurveHasUnsupportedSegments(node) {
107
- const segments = Array.from(node.children).find((child) => child.localName === 'segments');
108
- if (!segments) {
109
- return;
110
- }
111
- const unsupportedSegment = Array.from(segments.children).find((child) => child.localName !== 'LineStringSegment');
112
- if (unsupportedSegment) {
113
- console.warn(`CompositeCurve member contains unsupported ${describeNode(unsupportedSegment)} segment.`);
114
- }
115
- }
116
148
  function lineStringToPieces(lineString) {
117
149
  if (!lineString) {
118
150
  return [];
@@ -131,9 +163,10 @@ function buildCompositeGeometry(pieces) {
131
163
  if (normalizedPieces.length === 0) {
132
164
  return new MultiLineString([]);
133
165
  }
166
+ const dimension = normalizedPieces[0][0].length;
134
167
  const groups = [];
135
168
  for (const piece of normalizedPieces) {
136
- const current = clonePiece(piece);
169
+ const current = clonePiece(piece).map((coordinate) => normalizeDimension(coordinate, dimension));
137
170
  const previous = groups.at(-1);
138
171
  if (previous && coordinatesEqual(previous[previous.length - 1], current[0])) {
139
172
  previous.push(...current.slice(1));
@@ -144,6 +177,14 @@ function buildCompositeGeometry(pieces) {
144
177
  }
145
178
  return groups.length === 1 ? new LineString(groups[0]) : new MultiLineString(groups);
146
179
  }
180
+ function normalizeDimension(coordinate, dimension) {
181
+ if (coordinate.length === dimension) {
182
+ return coordinate;
183
+ }
184
+ return coordinate.length < dimension
185
+ ? [...coordinate, ...new Array(dimension - coordinate.length).fill(0)]
186
+ : coordinate.slice(0, dimension);
187
+ }
147
188
  function clonePiece(piece) {
148
189
  return piece.map((coordinate) => [...coordinate]);
149
190
  }