Skip to content

Commit

Permalink
chore(lint): Fix lint warnings.
Browse files Browse the repository at this point in the history
- Exclude prettierrc.cjs from lint
- lint prettier format autofix and adjust signature of Function
- coalescing chains.
  • Loading branch information
jafin authored and guillaume-chervet committed Jul 21, 2024
1 parent 11a6906 commit 32a2af3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default [
'**/.changeset',
'**/vite.config.js',
'**/webpack-runtime.js',
'.prettierrc.cjs',
],
},
...fixupConfigRules(
Expand Down
16 changes: 6 additions & 10 deletions packages/oidc-client/src/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import Oidc from './oidc';
import {getValidTokenAsync, OidcToken, Tokens} from './parseTokens';
import {Fetch, StringMap, TokenAutomaticRenewMode} from './types';
import { getValidTokenAsync, OidcToken } from './parseTokens';
import { Fetch } from './types';

// @ts-ignore
export const fetchWithTokens =
(
fetch: Fetch,
oidc: Oidc | null,
demonstrating_proof_of_possession: boolean = false,
): Fetch =>
(fetch: Fetch, oidc: Oidc | null, demonstrating_proof_of_possession: boolean = false): Fetch =>
async (...params: Parameters<Fetch>): Promise<Response> => {
const [url, options, ...rest] = params;
const optionTmp = options ? { ...options } : { method: 'GET' };
Expand All @@ -18,12 +14,12 @@ export const fetchWithTokens =
? new Headers(optionTmp.headers)
: optionTmp.headers;
}
const oidcToken : OidcToken = {

const oidcToken: OidcToken = {
tokens: oidc.tokens,
configuration: { token_automatic_renew_mode: oidc.configuration.token_automatic_renew_mode },
renewTokensAsync: oidc.renewTokensAsync.bind(oidc),
}
};

// @ts-ignore
const getValidToken = await getValidTokenAsync(oidcToken);
Expand Down
10 changes: 5 additions & 5 deletions packages/oidc-client/src/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import { performAuthorizationRequestAsync, performFirstTokenRequestAsync } from
import { getParseQueryStringFromLocation } from './route-utils.js';
import { OidcConfiguration, StringMap } from './types.js';

// eslint-disable-next-line @typescript-eslint/ban-types
export type InitAsyncFunction = (authority: string, authorityConfiguration: any) => Promise<any>;

export const defaultLoginAsync =
(
configurationName: string,
configuration: OidcConfiguration,
publishEvent: (string, any) => void,
initAsync: Function,
initAsync: InitAsyncFunction,
oidcLocation: ILOidcLocation,
) =>
(
Expand Down Expand Up @@ -168,7 +169,7 @@ export const loginCallbackAsync =
extras[key] = value;
}
}
if (getLoginParams && getLoginParams.extras) {
if (getLoginParams?.extras) {
for (const [key, value] of Object.entries(getLoginParams.extras)) {
if (key.endsWith(':token_request')) {
extras[key.replace(':token_request', '')] = value;
Expand Down Expand Up @@ -233,8 +234,7 @@ export const loginCallbackAsync =

if (
demonstratingProofOfPossessionNonce &&
formattedTokens.accessToken &&
formattedTokens.accessToken.includes('SECURED_BY_OIDC_SERVICE_WORKER')
formattedTokens?.accessToken.includes('SECURED_BY_OIDC_SERVICE_WORKER')
) {
throw new Error(
'Demonstration of proof of possession require Access token not hidden by service worker',
Expand Down
9 changes: 7 additions & 2 deletions packages/oidc-client/src/silentLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ export type SilentLoginResponse = {
error: string;
};

// eslint-disable-next-line @typescript-eslint/ban-types
export type PublishEventFunction = (eventName: string, eventData: any) => void;

export const _silentLoginAsync =
(configurationName: string, configuration: OidcConfiguration, publishEvent: Function) =>
(
configurationName: string,
configuration: OidcConfiguration,
publishEvent: PublishEventFunction,
) =>
(
extras: StringMap = null,
state: string = null,
Expand Down

0 comments on commit 32a2af3

Please sign in to comment.