Skip to content

Commit 8f295a7

Browse files
committed
Fix lint issues
1 parent dc337cc commit 8f295a7

13 files changed

Lines changed: 87 additions & 69 deletions

File tree

packages/javascript/src/__legacy__/client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ import {Storage, TemporaryStore} from '../models/store';
3232
import {TokenResponse, IdToken, TokenExchangeRequestConfig} from '../models/token';
3333
import {User} from '../models/user';
3434
import StorageManager from '../StorageManager';
35+
import deepMerge from '../utils/deepMerge';
3536
import extractPkceStorageKeyFromState from '../utils/extractPkceStorageKeyFromState';
3637
import generatePkceStorageKey from '../utils/generatePkceStorageKey';
3738
import getAuthorizeRequestUrlParams from '../utils/getAuthorizeRequestUrlParams';
3839
import processOpenIDScopes from '../utils/processOpenIDScopes';
39-
import deepMerge from '../utils/deepMerge';
4040

4141
/**
4242
* Default configurations.
@@ -1139,8 +1139,9 @@ export class AsgardeoAuthClient<T> {
11391139
* @preserve
11401140
*/
11411141
public async reInitialize(config: Partial<AuthClientConfig<T>>): Promise<void> {
1142-
const currentConfig = this.storageManager.getConfigData();
1143-
const newConfig = deepMerge(currentConfig as unknown as AuthClientConfig<T>, config);
1142+
const currentConfig: AuthClientConfig<T> = this.storageManager.getConfigData() as unknown as AuthClientConfig<T>;
1143+
const newConfig: AuthClientConfig<T> = deepMerge(currentConfig, config);
1144+
11441145
await this.storageManager.setConfigData(newConfig);
11451146
await this.loadOpenIDProviderConfiguration(true);
11461147
}

packages/javascript/src/models/v2/embedded-flow-v2.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,14 @@ export interface EmbeddedFlowComponent {
221221
alt?: string;
222222

223223
/**
224-
* Nested child components for container components like Block and Stack.
224+
* Icon color, CSS color value (for Icon components).
225225
*/
226-
components?: EmbeddedFlowComponent[];
226+
color?: string;
227227

228228
/**
229-
* Icon color, CSS color value (for Icon components).
229+
* Nested child components for container components like Block and Stack.
230230
*/
231-
color?: string;
231+
components?: EmbeddedFlowComponent[];
232232

233233
/**
234234
* Layout direction for Stack components ('row' | 'column').
@@ -251,6 +251,12 @@ export interface EmbeddedFlowComponent {
251251
*/
252252
gap?: number;
253253

254+
/**
255+
* Height of the component (for Image components, can be string with units or number for pixels).
256+
* The value depends on the component type (e.g., for Image components).
257+
*/
258+
height?: string | number;
259+
254260
/**
255261
* Unique identifier for the component
256262
*/
@@ -331,12 +337,6 @@ export interface EmbeddedFlowComponent {
331337
* The value depends on the component type (e.g., for Image components).
332338
*/
333339
width?: string | number;
334-
335-
/**
336-
* Height of the component (for Image components, can be string with units or number for pixels).
337-
* The value depends on the component type (e.g., for Image components).
338-
*/
339-
height?: string | number;
340340
}
341341

342342
/**

packages/javascript/src/models/v2/vars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* under the License.
1717
*/
1818

19-
import {TranslationFn} from './translation';
2019
import {FlowMetadataResponse} from './flow-meta-v2';
20+
import {TranslationFn} from './translation';
2121

2222
/**
2323
* Options for the resolveVars function.

packages/javascript/src/utils/v2/resolveMeta.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,16 @@ import {FlowMetadataResponse} from '../../models/v2/flow-meta-v2';
3434
* @returns The resolved string value, or empty string if not found
3535
*/
3636
export default function resolveMeta(path: string, meta: FlowMetadataResponse): string {
37-
const parts: string[] = path.split('.');
38-
let value: any = meta;
39-
40-
for (const part of parts) {
41-
if (value == null || typeof value !== 'object') {
42-
return '';
37+
const value: unknown = path.split('.').reduce<unknown>((current: unknown, part: string) => {
38+
if (current == null || typeof current !== 'object') {
39+
return undefined;
4340
}
4441

42+
const obj: Record<string, unknown> = current as Record<string, unknown>;
4543
const snakePart: string = part.replace(/[A-Z]/g, (c: string) => `_${c.toLowerCase()}`);
4644

47-
value = part in value ? value[part] : value[snakePart];
48-
}
45+
return part in obj ? obj[part] : obj[snakePart];
46+
}, meta);
4947

5048
return value != null ? String(value) : '';
5149
}

packages/javascript/src/utils/v2/resolveVars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
* under the License.
1717
*/
1818

19+
import resolveMeta from './resolveMeta';
1920
import {TranslationFn} from '../../models/v2/translation';
2021
import {ResolveVarsOptions} from '../../models/v2/vars';
21-
import resolveMeta from './resolveMeta';
2222

2323
/**
2424
* Resolves all template expressions in a string.

packages/react/src/components/presentation/auth/AcceptInvite/v2/BaseAcceptInvite.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import {FC, ReactElement, ReactNode, useCallback, useEffect, useRef, useState} f
2222
import useStyles from './BaseAcceptInvite.styles';
2323
import useAsgardeo from '../../../../../contexts/Asgardeo/useAsgardeo';
2424
import useTheme from '../../../../../contexts/Theme/useTheme';
25-
import {useOAuthCallback} from '../../../../../hooks/v2/useOAuthCallback';
2625
import useTranslation from '../../../../../hooks/useTranslation';
26+
import {useOAuthCallback} from '../../../../../hooks/v2/useOAuthCallback';
2727
import {initiateOAuthRedirect} from '../../../../../utils/oauth';
2828
import {normalizeFlowResponse, extractErrorMessage} from '../../../../../utils/v2/flowTransformer';
2929
import AlertPrimitive from '../../../../primitives/Alert/Alert';
@@ -307,10 +307,15 @@ const BaseAcceptInvite: FC<BaseAcceptInviteProps> = ({
307307
}
308308

309309
try {
310-
const {components} = normalizeFlowResponse(response, t, {
311-
defaultErrorKey: 'components.acceptInvite.errors.generic',
312-
resolveTranslations: false,
313-
}, meta);
310+
const {components} = normalizeFlowResponse(
311+
response,
312+
t,
313+
{
314+
defaultErrorKey: 'components.acceptInvite.errors.generic',
315+
resolveTranslations: false,
316+
},
317+
meta,
318+
);
314319

315320
return {
316321
...response,

packages/react/src/components/presentation/auth/AuthOptionFactory.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ import {
3030
import {css} from '@emotion/css';
3131
import DOMPurify from 'dompurify';
3232
import {cloneElement, CSSProperties, ReactElement} from 'react';
33-
import flowIconRegistry from '../../primitives/Icons/flowIconRegistry';
3433
import {UseTranslation} from '../../../hooks/useTranslation';
3534
import FacebookButton from '../../adapters/FacebookButton';
3635
import GitHubButton from '../../adapters/GitHubButton';
3736
import GoogleButton from '../../adapters/GoogleButton';
37+
import ImageComponent from '../../adapters/ImageComponent';
3838
import LinkedInButton from '../../adapters/LinkedInButton';
3939
import MicrosoftButton from '../../adapters/MicrosoftButton';
4040
import SignInWithEthereumButton from '../../adapters/SignInWithEthereumButton';
4141
import SmsOtpButton from '../../adapters/SmsOtpButton';
4242
import {createField} from '../../factories/FieldFactory';
4343
import Button from '../../primitives/Button/Button';
4444
import Divider from '../../primitives/Divider/Divider';
45+
import flowIconRegistry from '../../primitives/Icons/flowIconRegistry';
4546
import Select from '../../primitives/Select/Select';
4647
import Typography from '../../primitives/Typography/Typography';
4748
import {TypographyVariant} from '../../primitives/Typography/Typography.styles';
48-
import ImageComponent from '../../adapters/ImageComponent';
4949

5050
const logger: ReturnType<typeof createPackageComponentLogger> = createPackageComponentLogger(
5151
'@asgardeo/react',
@@ -161,7 +161,7 @@ const createAuthComponentFromFlow = (
161161
if (!text || (!options.t && !options.meta)) {
162162
return text || '';
163163
}
164-
return resolveVars(text, {meta: options.meta, t: options.t || ((k: string) => k)});
164+
return resolveVars(text, {meta: options.meta, t: options.t || ((k: string): string => k)});
165165
};
166166

167167
switch (component.type) {
@@ -348,7 +348,7 @@ const createAuthComponentFromFlow = (
348348
key={key}
349349
className={richTextClass}
350350
// Manually sanitizes with `DOMPurify`.
351-
// eslint-disable-next-line react/no-danger
351+
// IMPORTANT: DO NOT REMOVE OR MODIFY THIS SANITIZATION STEP.
352352
dangerouslySetInnerHTML={{__html: DOMPurify.sanitize(resolve(component.label))}}
353353
/>
354354
);
@@ -361,18 +361,18 @@ const createAuthComponentFromFlow = (
361361
component={
362362
{
363363
config: {
364-
src: resolve(component.src),
365364
alt: resolve(component.alt) || resolve(component.label) || 'Image',
366-
width: resolve(component.width.toString()) || '100%',
367365
height: resolve(component.height.toString()) || 'auto',
366+
src: resolve(component.src),
367+
width: resolve(component.width.toString()) || '100%',
368368
},
369369
} as any
370370
}
371371
formErrors={undefined}
372372
formValues={undefined}
373373
isFormValid={false}
374374
isLoading={false}
375-
onInputChange={function (name: string, value: string): void {
375+
onInputChange={(): void => {
376376
throw new Error('Function not implemented.');
377377
}}
378378
touchedFields={undefined}

packages/react/src/components/presentation/auth/InviteUser/v2/BaseInviteUser.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,15 @@ const BaseInviteUser: FC<BaseInviteUserProps> = ({
293293
}
294294

295295
try {
296-
const {components} = normalizeFlowResponse(response, t, {
297-
defaultErrorKey: 'components.inviteUser.errors.generic',
298-
resolveTranslations: false,
299-
}, meta);
296+
const {components} = normalizeFlowResponse(
297+
response,
298+
t,
299+
{
300+
defaultErrorKey: 'components.inviteUser.errors.generic',
301+
resolveTranslations: false,
302+
},
303+
meta,
304+
);
300305

301306
return {
302307
...response,

packages/react/src/components/presentation/auth/SignIn/v2/BaseSignIn.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
EmbeddedSignInFlowRequestV2 as EmbeddedSignInFlowRequest,
2222
EmbeddedFlowComponentV2 as EmbeddedFlowComponent,
2323
FlowMetadataResponse,
24-
resolveVars
24+
resolveVars,
2525
} from '@asgardeo/browser';
2626
import {cx} from '@emotion/css';
2727
import {FC, useState, useCallback, ReactElement, ReactNode} from 'react';
@@ -528,13 +528,11 @@ const BaseSignInContent: FC<BaseSignInProps> = ({
528528
}
529529

530530
// Extract heading and subheading components and filter them from the main components
531-
const {title: rawTitle, subtitle: rawSubtitle, componentsWithoutHeadings} = getAuthComponentHeadings(
532-
components as any,
533-
flowTitle,
534-
flowSubtitle,
535-
undefined,
536-
undefined,
537-
);
531+
const {
532+
title: rawTitle,
533+
subtitle: rawSubtitle,
534+
componentsWithoutHeadings,
535+
} = getAuthComponentHeadings(components as any, flowTitle, flowSubtitle, undefined, undefined);
538536
// Resolve any remaining {{meta()}} or {{t()}} expressions in the title/subtitle at render time
539537
const title: string = resolveVars(rawTitle, {meta, t});
540538
const subtitle: string = resolveVars(rawSubtitle, {meta, t});

packages/react/src/components/presentation/auth/SignIn/v2/SignIn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import {FC, ReactElement, useState, useEffect, useRef, ReactNode} from 'react';
3030
// eslint-disable-next-line import/no-named-as-default
3131
import BaseSignIn, {BaseSignInProps} from './BaseSignIn';
3232
import useAsgardeo from '../../../../../contexts/Asgardeo/useAsgardeo';
33-
import {useOAuthCallback} from '../../../../../hooks/v2/useOAuthCallback';
3433
import useTranslation from '../../../../../hooks/useTranslation';
34+
import {useOAuthCallback} from '../../../../../hooks/v2/useOAuthCallback';
3535
import {initiateOAuthRedirect} from '../../../../../utils/oauth';
3636
import {normalizeFlowResponse} from '../../../../../utils/v2/flowTransformer';
3737
import {handlePasskeyAuthentication, handlePasskeyRegistration} from '../../../../../utils/v2/passkey';

0 commit comments

Comments
 (0)