Skip to content

Commit

Permalink
chore(console): update custom JWT scripts sample
Browse files Browse the repository at this point in the history
  • Loading branch information
darcyYe committed Apr 18, 2024
1 parent 26c215f commit 47f0a70
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions packages/console/src/pages/CustomizeJwtDetails/utils/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare global {
/** Logto internal data that can be used to pass additional information
* @param {${JwtCustomizerTypeDefinitionKey.JwtCustomizerUserContext}} user - The user info associated with the token.
*/
export type Data = {
export type Context = {
user: ${JwtCustomizerTypeDefinitionKey.JwtCustomizerUserContext};
}
Expand All @@ -35,13 +35,13 @@ declare global {
* This function is called during the access token generation process to get custom claims for the JWT token.
*
* @param {${JwtCustomizerTypeDefinitionKey.AccessTokenPayload}} token -The JWT token.
* @param {Data} data - Logto internal data that can be used to pass additional information
* @param {${JwtCustomizerTypeDefinitionKey.JwtCustomizerUserContext}} data.user - The user info associated with the token.
* @param {${JwtCustomizerTypeDefinitionKey.EnvironmentVariables}} envVariables - The environment variables.
* @param {Context} context - Logto internal data that can be used to pass additional information
* @param {${JwtCustomizerTypeDefinitionKey.JwtCustomizerUserContext}} context.user - The user info associated with the token.
* @param {${JwtCustomizerTypeDefinitionKey.EnvironmentVariables}} environmentVariables - The environment variables.
*
* @returns The custom claims.
*/
getCustomJwtClaims: (token: ${JwtCustomizerTypeDefinitionKey.AccessTokenPayload}, data: Data, envVariables: ${JwtCustomizerTypeDefinitionKey.EnvironmentVariables}) => Promise<CustomJwtClaims>;
getCustomJwtClaims: ({ token: ${JwtCustomizerTypeDefinitionKey.AccessTokenPayload}, context: Context, environmentVariables: ${JwtCustomizerTypeDefinitionKey.EnvironmentVariables} }) => Promise<CustomJwtClaims>;
}
const exports: Exports;
Expand All @@ -62,7 +62,7 @@ declare global {
*
* @returns The custom claims.
*/
getCustomJwtClaims: (token: ${JwtCustomizerTypeDefinitionKey.ClientCredentialsPayload}, envVariables: ${JwtCustomizerTypeDefinitionKey.EnvironmentVariables}) => Promise<CustomJwtClaims>;
getCustomJwtClaims: ({ token: ${JwtCustomizerTypeDefinitionKey.ClientCredentialsPayload}, environmentVariables: ${JwtCustomizerTypeDefinitionKey.EnvironmentVariables} }) => Promise<CustomJwtClaims>;
}
const exports: Exports;
Expand All @@ -76,14 +76,14 @@ export const defaultAccessTokenJwtCustomizerCode = `/**
* Limit custom claims to under 50KB.
*
* @param {${JwtCustomizerTypeDefinitionKey.AccessTokenPayload}} token -The JWT token.
* @param {Data} data - Logto internal data that can be used to pass additional information
* @param {${JwtCustomizerTypeDefinitionKey.JwtCustomizerUserContext}} data.user - The user info associated with the token.
* @param {${JwtCustomizerTypeDefinitionKey.EnvironmentVariables}} [envVariables] - The environment variables.
* @param {Context} context - Logto internal data that can be used to pass additional information
* @param {${JwtCustomizerTypeDefinitionKey.JwtCustomizerUserContext}} context.user - The user info associated with the token.
* @param {${JwtCustomizerTypeDefinitionKey.EnvironmentVariables}} [environmentVariables] - The environment variables.
*
* @returns The custom claims.
*/
exports.getCustomJwtClaims = async (token, data, envVariables) => {
const getCustomJwtClaims = async ({ token, context, environmentVariables }) => {
return {};
}`;

Expand All @@ -92,12 +92,12 @@ export const defaultClientCredentialsJwtCustomizerCode = `/**
* Limit custom claims to under 50KB.
*
* @param {${JwtCustomizerTypeDefinitionKey.ClientCredentialsPayload}} token -The JWT token.
* @param {${JwtCustomizerTypeDefinitionKey.EnvironmentVariables}} [envVariables] - The environment variables.
* @param {${JwtCustomizerTypeDefinitionKey.EnvironmentVariables}} [environmentVariables] - The environment variables.
*
* @returns The custom claims.
*/
exports.getCustomJwtClaims = async (token, envVariables) => {
const getCustomJwtClaims = async ({ token, environmentVariables }) => {
return {};
}`;

Expand Down Expand Up @@ -170,8 +170,8 @@ return {
externalData: data,
};`;

export const environmentVariablesCodeExample = `exports.getCustomJwtClaims = async (token, data, envVariables) => {
const { apiKey } = envVariables;
export const environmentVariablesCodeExample = `const getCustomJwtClaims = async ({ token, context, environmentVariables }) => {
const { apiKey } = environmentVariables;
const response = await fetch('https://api.example.com/data', {
headers: {
Expand Down

0 comments on commit 47f0a70

Please sign in to comment.