@asgardeo/javascript 0.8.0 → 0.8.2

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.
@@ -0,0 +1,44 @@
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
+ * Interface representing the configuration for an agent.
20
+ */
21
+ export interface AgentConfig {
22
+ /**
23
+ * The unique identifier for the agent
24
+ */
25
+ agentID: string;
26
+ /**
27
+ * The secret credential for the agent
28
+ */
29
+ agentSecret: string;
30
+ /**
31
+ * The authenticator name to match during the embedded sign-in flow.
32
+ * Defaults to {@link AgentConfig.DEFAULT_AUTHENTICATOR_NAME} if not provided.
33
+ */
34
+ authenticatorName?: string;
35
+ }
36
+ /**
37
+ * Namespace that holds constants related to {@link AgentConfig}.
38
+ */
39
+ export declare namespace AgentConfig {
40
+ /**
41
+ * Default authenticator name used when none is specified.
42
+ */
43
+ const DEFAULT_AUTHENTICATOR_NAME: string;
44
+ }
@@ -0,0 +1,34 @@
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
+ * Interface representing the authorization code response from the OAuth2/OIDC flow.
20
+ */
21
+ export interface AuthCodeResponse {
22
+ /**
23
+ * The authorization code returned from the authorization endpoint
24
+ */
25
+ code: string;
26
+ /**
27
+ * The session state identifier
28
+ */
29
+ session_state: string;
30
+ /**
31
+ * The state parameter returned from the authorization endpoint
32
+ */
33
+ state: string;
34
+ }
@@ -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
  /**
@@ -80,7 +80,7 @@ export interface Crypto<T = any> {
80
80
  *
81
81
  * @returns Hashed data.
82
82
  */
83
- hashSha256(data: string): T;
83
+ hashSha256(data: string): T | Promise<T>;
84
84
  /**
85
85
  * Verify the provided JWT.
86
86
  *
@@ -44,14 +44,22 @@ export declare enum EmbeddedFlowComponentType {
44
44
  Divider = "DIVIDER",
45
45
  /** Email input field with validation for email addresses. */
46
46
  EmailInput = "EMAIL_INPUT",
47
+ /** Icon display component for rendering named vector icons */
48
+ Icon = "ICON",
49
+ /** Image display component for logos and illustrations */
50
+ Image = "IMAGE",
47
51
  /** One-time password input field for multi-factor authentication */
48
52
  OtpInput = "OTP_INPUT",
49
53
  /** Password input field with masking for sensitive data */
50
54
  PasswordInput = "PASSWORD_INPUT",
51
55
  /** Phone number input field with country code support */
52
56
  PhoneInput = "PHONE_INPUT",
57
+ /** Rich text display component that renders formatted HTML content */
58
+ RichText = "RICH_TEXT",
53
59
  /** Select/dropdown input component for single choice selection */
54
60
  Select = "SELECT",
61
+ /** Stack layout component for arranging children in a row or column */
62
+ Stack = "STACK",
55
63
  /** Text display component for labels, headings, and messages */
56
64
  Text = "TEXT",
57
65
  /** Standard text input field for user data entry */
@@ -159,23 +167,64 @@ export declare enum EmbeddedFlowEventType {
159
167
  */
160
168
  export interface EmbeddedFlowComponent {
161
169
  /**
162
- * Nested child components for container components like Block.
170
+ * Alignment of children along the cross axis (for Stack components).
171
+ */
172
+ align?: string;
173
+ /**
174
+ * Alternative text for Image components.
175
+ */
176
+ alt?: string;
177
+ /**
178
+ * Icon color, CSS color value (for Icon components).
179
+ */
180
+ color?: string;
181
+ /**
182
+ * Nested child components for container components like Block and Stack.
163
183
  */
164
184
  components?: EmbeddedFlowComponent[];
185
+ /**
186
+ * Layout direction for Stack components ('row' | 'column').
187
+ */
188
+ direction?: string;
189
+ /**
190
+ * Icon to render at the end of an Action button (URL string).
191
+ */
192
+ endIcon?: string;
165
193
  /**
166
194
  * Event type for action components that defines the interaction behavior.
167
195
  * Only relevant for Action components.
168
196
  */
169
197
  eventType?: EmbeddedFlowEventType | string;
198
+ /**
199
+ * Gap between children in Stack components (number, maps to spacing units).
200
+ */
201
+ gap?: number;
202
+ /**
203
+ * Height of the component (for Image components, can be string with units or number for pixels).
204
+ * The value depends on the component type (e.g., for Image components).
205
+ */
206
+ height?: string | number;
170
207
  /**
171
208
  * Unique identifier for the component
172
209
  */
173
210
  id: string;
211
+ /**
212
+ * Number of items across the main axis (for Stack grid-like layouts).
213
+ */
214
+ items?: string | number;
215
+ /**
216
+ * Justification of children along the main axis (for Stack components).
217
+ */
218
+ justify?: string;
174
219
  /**
175
220
  * Display label for the component (e.g., field label, button text).
176
221
  * Supports internationalization and may contain template strings.
177
222
  */
178
223
  label?: string;
224
+ /**
225
+ * Icon name for Icon components (e.g., lucide-react icon names like 'ArrowLeftRight').
226
+ */
227
+ name?: string;
179
228
  /**
180
229
  * Options for SELECT components.
181
230
  * Each option can be a string value or an object with value and label.
@@ -198,6 +247,18 @@ export interface EmbeddedFlowComponent {
198
247
  * Used for form validation and UI indicators.
199
248
  */
200
249
  required?: boolean;
250
+ /**
251
+ * Icon size in pixels (for Icon components).
252
+ */
253
+ size?: number;
254
+ /**
255
+ * Image source URL (for Image components).
256
+ */
257
+ src?: string;
258
+ /**
259
+ * Icon to render at the start of an Action button (URL string).
260
+ */
261
+ startIcon?: string;
201
262
  /**
202
263
  * Component type that determines rendering behavior
203
264
  */
@@ -207,6 +268,11 @@ export interface EmbeddedFlowComponent {
207
268
  * The value depends on the component type (e.g., button variants, text variants).
208
269
  */
209
270
  variant?: EmbeddedFlowActionVariant | EmbeddedFlowTextVariant | string;
271
+ /**
272
+ * Width of the component (for Image components, can be string with units or number for pixels).
273
+ * The value depends on the component type (e.g., for Image components).
274
+ */
275
+ width?: string | number;
210
276
  }
211
277
  /**
212
278
  * Response data structure for embedded flow API.
@@ -137,7 +137,7 @@ export interface FlowMetaThemeColors {
137
137
  */
138
138
  export interface FlowMetaThemeColorScheme {
139
139
  /** All colors defined for this color scheme (light or dark) */
140
- colors: FlowMetaThemeColors;
140
+ palette: FlowMetaThemeColors;
141
141
  }
142
142
  /**
143
143
  * Shape / geometry configuration in the v2 theme.
@@ -0,0 +1,34 @@
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
+ * Generic translation function type.
20
+ *
21
+ * The default parameter type (`Record<string, string | number>`) matches the
22
+ * common i18n signature used throughout the SDK. Consumers can supply a more
23
+ * specific type when integrating with third-party i18n libraries.
24
+ *
25
+ * @template TParams - The type of the optional interpolation parameters object.
26
+ *
27
+ * @example
28
+ * // Using the default (SDK-native) signature
29
+ * const t: TranslationFn = (key, params) => i18n.t(key, params);
30
+ *
31
+ * // Using react-i18next's TFunction as TParams
32
+ * const t: TranslationFn<Record<string, unknown>> = i18nextT;
33
+ */
34
+ export type TranslationFn<TParams = Record<string, string | number>> = (key: string, params?: TParams) => string;
@@ -0,0 +1,35 @@
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
+ import { FlowMetadataResponse } from './flow-meta-v2';
19
+ import { TranslationFn } from './translation';
20
+ /**
21
+ * Options for the resolveVars function.
22
+ *
23
+ * @template TFn - The concrete translation function type.
24
+ * Defaults to the SDK-native {@link TranslationFn} signature.
25
+ */
26
+ export interface ResolveVarsOptions<TFn extends TranslationFn = TranslationFn> {
27
+ /**
28
+ * Optional flow metadata for resolving `{{ meta(path) }}` expressions.
29
+ */
30
+ meta?: FlowMetadataResponse | null;
31
+ /**
32
+ * i18n translation function for resolving `{{ t(key) }}` expressions.
33
+ */
34
+ t: TFn;
35
+ }
@@ -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;
@@ -0,0 +1,34 @@
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
+ import { FlowMetadataResponse } from '../../models/v2/flow-meta-v2';
19
+ /**
20
+ * Resolves a dot-path expression against a FlowMetadataResponse object.
21
+ *
22
+ * Supports both camelCase paths (e.g. `logoUrl`) and snake_case API responses
23
+ * (e.g. `logo_url`). When a camelCase segment is not found directly, the
24
+ * function falls back to its snake_case equivalent.
25
+ *
26
+ * @example
27
+ * resolveMeta('application.name', meta) // → 'My App'
28
+ * resolveMeta('ou.name', meta) // → 'My Org'
29
+ *
30
+ * @param path - Dot-separated path into the meta object (e.g. 'application.name')
31
+ * @param meta - The FlowMetadataResponse to look up
32
+ * @returns The resolved string value, or empty string if not found
33
+ */
34
+ export default function resolveMeta(path: string, meta: FlowMetadataResponse): string;
@@ -0,0 +1,41 @@
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
+ import { TranslationFn } from '../../models/v2/translation';
19
+ import { ResolveVarsOptions } from '../../models/v2/vars';
20
+ /**
21
+ * Resolves all template expressions in a string.
22
+ *
23
+ * Supported patterns:
24
+ * - `{{ t(key) }}` — resolved via the i18n translation function.
25
+ * Colon-separated namespaces are converted to dots:
26
+ * `{{ t(signin:heading.label) }}` → `t('signin.heading.label')`
27
+ * - `{{ meta(path) }}` — resolved via a dot-path lookup on FlowMetadataResponse.
28
+ * `{{ meta(application.name) }}` → `meta.application?.name`
29
+ *
30
+ * Template expressions can be embedded inside larger strings:
31
+ * `"Login using {{ meta(application.name) }}"` → `"Login using My App"`
32
+ *
33
+ * Unrecognised expressions are left unchanged.
34
+ *
35
+ * @template TFn - The concrete translation function type.
36
+ *
37
+ * @param text - The string to resolve (may contain zero or more template expressions)
38
+ * @param options - Resolution context: translation function and optional flow metadata
39
+ * @returns The resolved string
40
+ */
41
+ export default function resolveVars<TFn extends TranslationFn = TranslationFn>(text: string | undefined, { t, meta }: ResolveVarsOptions<TFn>): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgardeo/javascript",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "Framework agnostic JavaScript SDK for Asgardeo.",
5
5
  "keywords": [
6
6
  "asgardeo",
@@ -46,7 +46,8 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "tslib": "2.8.1",
49
- "@asgardeo/i18n": "0.4.2"
49
+ "jose": "^5.2.0",
50
+ "@asgardeo/i18n": "0.4.3"
50
51
  },
51
52
  "publishConfig": {
52
53
  "access": "public"