Skip to content

Commit e5935b3

Browse files
authored
Merge pull request #70 from murbanowicz/bump-jose
2 parents cbd4dcc + 7e79ef0 commit e5935b3

23 files changed

+1612
-2409
lines changed

.eslintrc.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ lib/apis
99
lib/index.ts
1010
lib/runtime.ts
1111
lib/.openapi-generator
12+
13+
coverage

eslint.config.mjs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import tseslint from '@typescript-eslint/eslint-plugin';
2+
import typescript from '@typescript-eslint/parser';
3+
import n from 'eslint-plugin-n';
4+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
5+
import promise from 'eslint-plugin-promise';
6+
import { defineConfig, globalIgnores } from 'eslint/config';
7+
8+
export default defineConfig([
9+
// Global ignores
10+
globalIgnores(['**/dist', '**/dist-cjs']),
11+
12+
// Base configuration for all files
13+
{
14+
linterOptions: {
15+
reportUnusedDisableDirectives: true,
16+
},
17+
languageOptions: {
18+
ecmaVersion: 'latest',
19+
sourceType: 'module',
20+
},
21+
rules: {
22+
quotes: ['error', 'single'],
23+
},
24+
},
25+
26+
// TypeScript files
27+
{
28+
files: ['**/*.ts'],
29+
plugins: {
30+
'@typescript-eslint': tseslint,
31+
},
32+
languageOptions: {
33+
parser: typescript,
34+
parserOptions: {
35+
project: ['./tsconfig.json', './tsconfig.config.json'],
36+
},
37+
},
38+
rules: {
39+
'@typescript-eslint/explicit-function-return-type': 'off',
40+
'@typescript-eslint/strict-boolean-expressions': 'off',
41+
'@typescript-eslint/no-non-null-assertion': 'off',
42+
'@typescript-eslint/no-misused-promises': 'off',
43+
'@typescript-eslint/no-dynamic-delete': 'off',
44+
},
45+
},
46+
47+
// JavaScript files
48+
{
49+
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
50+
ignores: ['**/*.ts', '**/*.tsx'],
51+
},
52+
53+
// Other plugins
54+
{
55+
plugins: {
56+
n,
57+
promise,
58+
},
59+
rules: {
60+
'n/no-missing-import': 'off',
61+
},
62+
},
63+
64+
// Prettier at the end to override formatting rules
65+
eslintPluginPrettierRecommended,
66+
]);

jest.config.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

lib/__tests__/mocks.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type JWK, SignJWT, exportJWK, generateKeyPair, importJWK } from 'jose';
22
import { type SessionManager } from '../sdk/session-managers';
3+
import { vi } from 'vitest';
34

45
let mockPrivateKey: JWK | undefined;
56
let mockPublicKey: JWK | undefined;
@@ -11,7 +12,7 @@ export const getKeys = async (): Promise<{ privateKey: JWK; publicKey: JWK }> =>
1112
return { privateKey: mockPrivateKey, publicKey: mockPublicKey };
1213
}
1314
const { publicKey: generatedPublicKey, privateKey: generatedPrivateKey } =
14-
await generateKeyPair(mockJwtAlg);
15+
await generateKeyPair(mockJwtAlg, { extractable: true });
1516

1617
const generatedPrivateJwk = await exportJWK(generatedPrivateKey);
1718
const generatedPublicJwk = await exportJWK(generatedPublicKey);
@@ -22,7 +23,7 @@ export const getKeys = async (): Promise<{ privateKey: JWK; publicKey: JWK }> =>
2223
return { privateKey: mockPrivateKey, publicKey: mockPublicKey };
2324
};
2425

25-
export const fetchClient = jest.fn().mockImplementation(
26+
export const fetchClient = vi.fn().mockImplementation(
2627
async () =>
2728
await Promise.resolve({
2829
json: async () => {

lib/__tests__/sdk/oauth2-flows/AuthCodeWithPKCE.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { base64UrlEncode, sha256 } from '../../../sdk/utilities';
66
import { AuthCodeWithPKCE } from '../../../sdk/oauth2-flows';
77
import { getSDKHeader } from '../../../sdk/version';
88
import * as mocks from '../../mocks';
9+
import { describe, it, expect, beforeAll, afterEach } from 'vitest';
910

1011
describe('AuthCodeWitPKCE', () => {
1112
const { sessionManager } = mocks;

lib/__tests__/sdk/oauth2-flows/AuthorizationCode.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010

1111
import { KindeSDKError, KindeSDKErrorCode } from '../../../sdk/exceptions';
1212
import { generateRandomString } from '../../../sdk/utilities';
13+
import { describe, it, expect, beforeAll, afterEach } from 'vitest';
1314

1415
describe('AuthorizationCode', () => {
1516
const { sessionManager } = mocks;
@@ -381,9 +382,7 @@ describe('AuthorizationCode', () => {
381382
await sessionManager.setSessionItem('refresh_token', 'mines are here');
382383
await sessionManager.setSessionItem(
383384
'access_token',
384-
(
385-
await mocks.getMockAccessToken(clientConfig.authDomain, true)
386-
).token
385+
(await mocks.getMockAccessToken(clientConfig.authDomain, true)).token
387386
);
388387

389388
const client = new AuthorizationCode(clientConfig, clientSecret);

lib/__tests__/sdk/oauth2-flows/ClientCredentials.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createLocalJWKSet, importJWK } from 'jose';
1+
import { importJWK } from 'jose';
22
import { ClientCredentials } from '../../../sdk/oauth2-flows/ClientCredentials';
33
import { type ClientCredentialsOptions } from '../../../sdk/oauth2-flows/types';
44
import {
@@ -8,6 +8,7 @@ import {
88
} from '../../../sdk/utilities';
99
import { getSDKHeader } from '../../../sdk/version';
1010
import * as mocks from '../../mocks';
11+
import { describe, it, expect, beforeAll, afterEach } from 'vitest';
1112

1213
describe('ClientCredentials', () => {
1314
const clientConfig: ClientCredentialsOptions = {

lib/__tests__/sdk/session-managers/BrowserSessionManager.browser.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
/**
2-
* @jest-environment jsdom
3-
*/
4-
51
import { BrowserSessionManager } from '../../../sdk/session-managers';
2+
import { describe, it, expect, afterEach } from 'vitest';
63

74
describe('BrowserSessionManager', () => {
85
const sessionManager = new BrowserSessionManager();

lib/__tests__/sdk/utilities/feature-flags.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as mocks from '../../mocks';
2+
import { describe, it, expect, beforeAll, beforeEach, afterEach } from 'vitest';
23

34
import {
45
type FeatureFlags,

0 commit comments

Comments
 (0)