mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
chore: update cloud dependency
This commit is contained in:
parent
18fb88ecdd
commit
89ba8a1a0c
3 changed files with 25 additions and 23 deletions
|
@ -28,7 +28,7 @@
|
||||||
"@fontsource/roboto-mono": "^5.0.0",
|
"@fontsource/roboto-mono": "^5.0.0",
|
||||||
"@jest/types": "^29.5.0",
|
"@jest/types": "^29.5.0",
|
||||||
"@logto/app-insights": "workspace:^1.4.0",
|
"@logto/app-insights": "workspace:^1.4.0",
|
||||||
"@logto/cloud": "0.2.5-d9576f9",
|
"@logto/cloud": "0.2.5-ceb63ed",
|
||||||
"@logto/connector-kit": "workspace:^2.1.0",
|
"@logto/connector-kit": "workspace:^2.1.0",
|
||||||
"@logto/core-kit": "workspace:^2.3.0",
|
"@logto/core-kit": "workspace:^2.3.0",
|
||||||
"@logto/language-kit": "workspace:^1.1.0",
|
"@logto/language-kit": "workspace:^1.1.0",
|
||||||
|
|
|
@ -14,10 +14,9 @@ import {
|
||||||
logtoCookieKey,
|
logtoCookieKey,
|
||||||
type LogtoUiCookie,
|
type LogtoUiCookie,
|
||||||
LogtoJwtTokenKey,
|
LogtoJwtTokenKey,
|
||||||
type JsonObject,
|
type CustomJwtFetcher,
|
||||||
} from '@logto/schemas';
|
} from '@logto/schemas';
|
||||||
import { conditional, trySafe, tryThat } from '@silverhand/essentials';
|
import { conditional, trySafe, tryThat } from '@silverhand/essentials';
|
||||||
import { got } from 'got';
|
|
||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
import koaBody from 'koa-body';
|
import koaBody from 'koa-body';
|
||||||
import Provider, { errors } from 'oidc-provider';
|
import Provider, { errors } from 'oidc-provider';
|
||||||
|
@ -239,8 +238,7 @@ export default function initOidc(
|
||||||
|
|
||||||
if (script) {
|
if (script) {
|
||||||
// Wait for cloud API to be ready and we can use cloud connection client to request the API.
|
// Wait for cloud API to be ready and we can use cloud connection client to request the API.
|
||||||
const accessToken = await cloudConnection.getAccessToken();
|
const client = await cloudConnection.getClient();
|
||||||
const { endpoint: cloudApiEndpoint } = await cloudConnection.getCloudConnectionData();
|
|
||||||
|
|
||||||
// We pass context to the cloud API only when it is a user's access token.
|
// We pass context to the cloud API only when it is a user's access token.
|
||||||
const logtoUserInfo = conditional(
|
const logtoUserInfo = conditional(
|
||||||
|
@ -248,23 +246,27 @@ export default function initOidc(
|
||||||
token.accountId &&
|
token.accountId &&
|
||||||
(await libraries.jwtCustomizers.getUserContext(token.accountId))
|
(await libraries.jwtCustomizers.getUserContext(token.accountId))
|
||||||
);
|
);
|
||||||
const result =
|
/**
|
||||||
(await trySafe(
|
* `token` and `context` can not be assigned to Record<string, Json> according to the type inference,
|
||||||
got
|
* use request body guard to ensure the type.
|
||||||
.post(`${cloudApiEndpoint}/services/custom-jwt`, {
|
*
|
||||||
headers: {
|
* Use direct type casting to avoid the type inference issue since if the type is not correct the client
|
||||||
Authorization: `Bearer ${accessToken}`,
|
* will throw an Zod type error, there is no need to implement the zod guard and error handling here.
|
||||||
},
|
*/
|
||||||
json: {
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
const payload = {
|
||||||
script,
|
script,
|
||||||
envVars,
|
envVars,
|
||||||
token,
|
token,
|
||||||
...conditional(logtoUserInfo && { context: { user: logtoUserInfo } }),
|
context: conditional(logtoUserInfo && { user: logtoUserInfo }),
|
||||||
},
|
} as unknown as CustomJwtFetcher;
|
||||||
|
return (
|
||||||
|
(await trySafe(
|
||||||
|
client.post(`/api/services/custom-jwt`, {
|
||||||
|
body: payload,
|
||||||
})
|
})
|
||||||
.json<JsonObject>()
|
)) ?? {}
|
||||||
)) ?? {};
|
);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extraClientMetadata: {
|
extraClientMetadata: {
|
||||||
|
|
|
@ -2919,8 +2919,8 @@ importers:
|
||||||
specifier: workspace:^1.4.0
|
specifier: workspace:^1.4.0
|
||||||
version: link:../app-insights
|
version: link:../app-insights
|
||||||
'@logto/cloud':
|
'@logto/cloud':
|
||||||
specifier: 0.2.5-d9576f9
|
specifier: 0.2.5-ceb63ed
|
||||||
version: 0.2.5-d9576f9(zod@3.22.4)
|
version: 0.2.5-ceb63ed(zod@3.22.4)
|
||||||
'@logto/connector-kit':
|
'@logto/connector-kit':
|
||||||
specifier: workspace:^2.1.0
|
specifier: workspace:^2.1.0
|
||||||
version: link:../toolkit/connector-kit
|
version: link:../toolkit/connector-kit
|
||||||
|
|
Loading…
Reference in a new issue