Skip to content

Commit

Permalink
refactor: update dependency on @logto/cloud and update legacy JWT cus…
Browse files Browse the repository at this point in the history
…tomizer
  • Loading branch information
darcyYe committed Apr 3, 2024
1 parent 316c111 commit de70abe
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/connectors/connector-logto-email/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
"access": "public"
},
"devDependencies": {
"@logto/cloud": "0.2.5-6c090b2"
"@logto/cloud": "0.2.5-1807f9c"
}
}
2 changes: 1 addition & 1 deletion packages/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@fontsource/roboto-mono": "^5.0.0",
"@jest/types": "^29.5.0",
"@logto/app-insights": "workspace:^1.4.0",
"@logto/cloud": "0.2.5-6c090b2",
"@logto/cloud": "0.2.5-1807f9c",
"@logto/connector-kit": "workspace:^2.1.0",
"@logto/core-kit": "workspace:^2.3.0",
"@logto/language-kit": "workspace:^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@logto/cloud": "0.2.5-6c090b2",
"@logto/cloud": "0.2.5-1807f9c",
"@silverhand/eslint-config": "5.0.0",
"@silverhand/ts-config": "5.0.0",
"@types/debug": "^4.1.7",
Expand Down
8 changes: 3 additions & 5 deletions packages/core/src/oidc/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
type Json,
jwtCustomizer as jwtCustomizerLog,
LogResult,
LogtoJwtTokenPath,
LogtoJwtTokenKeyType,
} from '@logto/schemas';
import { generateStandardId } from '@logto/shared';
import { conditional, trySafe, tryThat } from '@silverhand/essentials';
Expand Down Expand Up @@ -269,13 +269,11 @@ export default function initOidc(
body: isTokenClientCredentials
? {
...commonPayload,
// TODO: update once cloud repo is ready.
tokenType: LogtoJwtTokenPath.ClientCredentials,
tokenType: LogtoJwtTokenKeyType.ClientCredentials,
}
: {
...commonPayload,
// TODO: update once cloud repo is ready.
tokenType: LogtoJwtTokenPath.AccessToken,
tokenType: LogtoJwtTokenKeyType.AccessToken,
// TODO (LOG-8555): the newly added `UserProfile` type includes undefined fields and can not be directly assigned to `Json` type. And the `undefined` fields should be removed by zod guard.

Check warning on line 277 in packages/core/src/oidc/init.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/core/src/oidc/init.ts#L277

[no-warning-comments] Unexpected 'todo' comment: 'TODO (LOG-8555): the newly added...'.
// eslint-disable-next-line no-restricted-syntax
context: { user: logtoUserInfo as Record<string, Json> },
Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/routes/logto-config/jwt-customizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
adminTenantId,
jwtCustomizerConfigsGuard,
jwtCustomizerTestRequestBodyGuard,
type CustomJwtFetcher,
type LogtoJwtTokenPath,
} from '@logto/schemas';
import { ResponseError } from '@withtyped/client';
import { ZodError, z } from 'zod';
Expand Down Expand Up @@ -191,9 +189,7 @@ export default function logtoConfigJwtCustomizerRoutes<T extends AuthedRouter>(

try {
ctx.body = await client.post(`/api/services/custom-jwt`, {
// TODO: remove type casting once the cloud repo is updated.
// eslint-disable-next-line no-restricted-syntax
body: body as CustomJwtFetcher & { tokenType: LogtoJwtTokenPath },
body,
});
} catch (error: unknown) {
/**
Expand Down
6 changes: 0 additions & 6 deletions packages/schemas/src/types/logto-config/jwt-customizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ export const clientCredentialsJwtCustomizerGuard = jwtCustomizerGuard

export type ClientCredentialsJwtCustomizer = z.infer<typeof clientCredentialsJwtCustomizerGuard>;

// TODO: Temporarily leave this and will remove it after the cloud repo is updated.
export enum LogtoJwtTokenPath {
AccessToken = 'access-token',
ClientCredentials = 'client-credentials',
}

export enum LogtoJwtTokenKeyType {
AccessToken = 'access-token',
ClientCredentials = 'client-credentials',
Expand Down
19 changes: 11 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de70abe

Please sign in to comment.