@asgardeo/javascript 0.8.1 → 0.8.3

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.
@@ -239,6 +239,16 @@ export interface ThemePreferences {
239
239
  */
240
240
  overrides?: RecursivePartial<ThemeConfig>;
241
241
  }
242
+ /**
243
+ * The storage strategy to use for persisting the user's language selection.
244
+ *
245
+ * - `'cookie'` — persists in `document.cookie` as a domain cookie (default).
246
+ * Useful for cross-subdomain scenarios where the auth portal and
247
+ * the application share a root domain.
248
+ * - `'localStorage'` — persists in `window.localStorage`.
249
+ * - `'none'` — no persistence; the resolved language is held in React state only.
250
+ */
251
+ export type I18nStorageStrategy = 'cookie' | 'localStorage' | 'none';
242
252
  export interface I18nPreferences {
243
253
  /**
244
254
  * Custom translations to override default ones.
@@ -246,6 +256,14 @@ export interface I18nPreferences {
246
256
  bundles?: {
247
257
  [key: string]: I18nBundle;
248
258
  };
259
+ /**
260
+ * The domain to use when setting the language cookie.
261
+ * Only applies when `storageStrategy` is `'cookie'`.
262
+ * Defaults to the root domain derived from `window.location.hostname`
263
+ * (e.g. `'app.example.com'` → `'example.com'`).
264
+ * Override this for eTLD+1 domains like `.co.uk` or custom cookie scoping.
265
+ */
266
+ cookieDomain?: string;
249
267
  /**
250
268
  * The fallback language to use if translations are not available in the specified language.
251
269
  * Defaults to 'en-US'.
@@ -253,9 +271,31 @@ export interface I18nPreferences {
253
271
  fallbackLanguage?: string;
254
272
  /**
255
273
  * The language to use for translations.
256
- * Defaults to the browser's default language.
274
+ * When set, acts as a hard override and bypasses all other detection sources
275
+ * (URL param, stored preference, browser language).
257
276
  */
258
277
  language?: string;
278
+ /**
279
+ * The key used when reading/writing the language to the chosen storage.
280
+ * For `localStorage` this is the key name; for `cookie` this is the cookie name.
281
+ * @default 'asgardeo-i18n-language'
282
+ */
283
+ storageKey?: string;
284
+ /**
285
+ * The storage strategy to use for persisting the user's language selection.
286
+ * @default 'cookie'
287
+ */
288
+ storageStrategy?: I18nStorageStrategy;
289
+ /**
290
+ * The URL query-parameter name to inspect for a language override.
291
+ * Set to `false` to disable URL-parameter detection entirely.
292
+ * When a URL param is detected its value is immediately persisted to storage.
293
+ * @default 'lang'
294
+ * @example
295
+ * // With urlParam: 'locale', the URL ?locale=fr-FR will select French.
296
+ * // With urlParam: false, URL parameters are ignored.
297
+ */
298
+ urlParam?: string | false;
259
299
  }
260
300
  export interface Preferences {
261
301
  /**
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ /**
19
+ * Converts a two-letter ISO 3166-1 alpha-2 country code to a flag emoji using
20
+ * Unicode Regional Indicator Symbols (U+1F1E6–U+1F1FF).
21
+ *
22
+ * @param countryCode - Two-letter uppercase country code (e.g. "US", "GB")
23
+ * @returns Flag emoji string (e.g. "🇺🇸", "🇬🇧")
24
+ */
25
+ export default function countryCodeToFlagEmoji(countryCode: string): string;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ /**
19
+ * Resolves a BCP 47 locale tag to a human-readable display name using the
20
+ * `Intl.DisplayNames` API.
21
+ *
22
+ * Falls back to the raw locale code if the runtime does not support
23
+ * `Intl.DisplayNames` or if resolution returns `undefined`.
24
+ *
25
+ * @param locale - BCP 47 locale tag to resolve (e.g. "en", "fr", "zh-Hant")
26
+ * @param displayLocale - Locale used for the display name language (defaults to "en")
27
+ * @returns Human-readable language name (e.g. "English", "French")
28
+ */
29
+ export default function resolveLocaleDisplayName(locale: string, displayLocale: string): string;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ /**
19
+ * Resolves a BCP 47 locale tag to a flag emoji.
20
+ *
21
+ * Resolution order:
22
+ * 1. Country subtag when present (e.g. `"en-US"` → 🇺🇸)
23
+ * 2. Language-to-country fallback map (e.g. `"en"` → 🇬🇧)
24
+ * 3. Globe emoji 🌐 for unrecognised codes
25
+ *
26
+ * @param locale - BCP 47 locale tag (e.g. "en", "en-US", "fr-CA")
27
+ * @returns Flag or globe emoji string
28
+ */
29
+ declare function resolveLocaleEmoji(locale: string): string;
30
+ export default resolveLocaleEmoji;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgardeo/javascript",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Framework agnostic JavaScript SDK for Asgardeo.",
5
5
  "keywords": [
6
6
  "asgardeo",
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "tslib": "2.8.1",
49
49
  "jose": "^5.2.0",
50
- "@asgardeo/i18n": "0.4.2"
50
+ "@asgardeo/i18n": "0.4.3"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"