diff --git a/packages/core/package.json b/packages/core/package.json index 6a15d0500..f062d2a1e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -30,7 +30,7 @@ "i18next": "^21.0.0", "iconv-lite": "0.6.3", "inquirer": "^8.2.2", - "jose": "^3.14.3", + "jose": "^4.0.0", "koa": "^2.13.1", "koa-body": "^5.0.0", "koa-logger": "^3.2.1", diff --git a/packages/core/src/middleware/koa-auth.test.ts b/packages/core/src/middleware/koa-auth.test.ts index c667225fa..be9896b9c 100644 --- a/packages/core/src/middleware/koa-auth.test.ts +++ b/packages/core/src/middleware/koa-auth.test.ts @@ -1,4 +1,4 @@ -import { jwtVerify } from 'jose/jwt/verify'; +import { jwtVerify } from 'jose'; import { Context } from 'koa'; import { IRouterParamContext } from 'koa-router'; @@ -8,7 +8,7 @@ import { createContextWithRouteParameters } from '@/utils/test-utils'; import koaAuth, { WithAuthContext } from './koa-auth'; -jest.mock('jose/jwt/verify', () => ({ +jest.mock('jose', () => ({ jwtVerify: jest.fn(() => ({ payload: { sub: 'fooUser' } })), })); diff --git a/packages/core/src/middleware/koa-auth.ts b/packages/core/src/middleware/koa-auth.ts index cab2c1c31..b66fea455 100644 --- a/packages/core/src/middleware/koa-auth.ts +++ b/packages/core/src/middleware/koa-auth.ts @@ -1,6 +1,6 @@ import { IncomingHttpHeaders } from 'http'; -import { jwtVerify } from 'jose/jwt/verify'; +import { jwtVerify } from 'jose'; import { MiddlewareType, Request } from 'koa'; import { IRouterParamContext } from 'koa-router'; diff --git a/packages/core/src/oidc/init.ts b/packages/core/src/oidc/init.ts index 631114a31..338d32669 100644 --- a/packages/core/src/oidc/init.ts +++ b/packages/core/src/oidc/init.ts @@ -1,7 +1,7 @@ /* istanbul ignore file */ import { CustomClientMetadataKey } from '@logto/schemas'; -import { fromKeyLike } from 'jose/jwk/from_key_like'; +import { exportJWK } from 'jose'; import Koa from 'koa'; import mount from 'koa-mount'; import { Provider, errors } from 'oidc-provider'; @@ -16,7 +16,7 @@ import { routes } from '@/routes/consts'; export default async function initOidc(app: Koa): Promise { const { issuer, privateKey, defaultIdTokenTtl, defaultRefreshTokenTtl } = envSet.values.oidc; - const keys = [await fromKeyLike(privateKey)]; + const keys = [await exportJWK(privateKey)]; const cookieConfig = Object.freeze({ sameSite: 'lax', path: '/', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4579e5aee..14e63afb1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -184,7 +184,7 @@ importers: inquirer: ^8.2.2 jest: ^27.5.1 jest-matcher-specific-error: ^1.0.0 - jose: ^3.14.3 + jose: ^4.0.0 koa: ^2.13.1 koa-body: ^5.0.0 koa-logger: ^3.2.1 @@ -222,7 +222,7 @@ importers: i18next: 21.6.12 iconv-lite: 0.6.3 inquirer: 8.2.2 - jose: 3.20.3 + jose: 4.6.0 koa: 2.13.4 koa-body: 5.0.0 koa-logger: 3.2.1 @@ -12205,17 +12205,8 @@ packages: '@sideway/pinpoint': 2.0.0 dev: true - /jose/3.20.3: - resolution: {integrity: sha512-Z4a5Nl4pmGivdSgaq+a5EbNjrvSO4vtBTmVy5C3HNxWfJ92aG8DTNZrQywowxyOlSqdX/BmCPAy/ieElXDM3pw==} - dev: false - - /jose/4.3.7: - resolution: {integrity: sha512-S7Xfsy8nN9Iw/AZxk+ZxEbd5ImIwJPM0TfAo8zI8FF+3lidQ2yiK4dqzsaPKSbZD0woNVSY0KCql6rlKc5V7ug==} - dev: false - /jose/4.6.0: resolution: {integrity: sha512-0hNAkhMBNi4soKSAX4zYOFV+aqJlEz/4j4fregvasJzEVtjDChvWqRjPvHwLqr5hx28Ayr6bsOs1Kuj87V0O8w==} - dev: true /js-base64/3.7.2: resolution: {integrity: sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ==} @@ -14299,7 +14290,7 @@ packages: debug: 4.3.3 ejs: 3.1.6 got: 11.8.3 - jose: 4.3.7 + jose: 4.6.0 jsesc: 3.0.2 koa: 2.13.4 koa-compose: 4.1.0