@asgardeo/javascript 0.8.0 → 0.8.1

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
+ }
@@ -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,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.1",
4
4
  "description": "Framework agnostic JavaScript SDK for Asgardeo.",
5
5
  "keywords": [
6
6
  "asgardeo",
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "tslib": "2.8.1",
49
+ "jose": "^5.2.0",
49
50
  "@asgardeo/i18n": "0.4.2"
50
51
  },
51
52
  "publishConfig": {