diff --git a/lib/build/recipe/session/api/implementation.js b/lib/build/recipe/session/api/implementation.js index 8208d69e0..0a172dff8 100644 --- a/lib/build/recipe/session/api/implementation.js +++ b/lib/build/recipe/session/api/implementation.js @@ -11,6 +11,7 @@ const normalisedURLPath_1 = __importDefault(require("../../../normalisedURLPath" const sessionRequestFunctions_1 = require("../sessionRequestFunctions"); const error_1 = __importDefault(require("../error")); const __2 = require("../../.."); +const constants_1 = require("../constants"); function getAPIInterface() { return { refreshPOST: async function ({ options, userContext }) { @@ -97,7 +98,14 @@ function getAPIInterface() { userContext ); if (sessionInformation !== undefined) { - userSessions.push(sessionInformation); + userSessions.push( + Object.assign(Object.assign({}, sessionInformation), { + userAgent: + sessionInformation.sessionDataInDatabase[ + constants_1.USER_AGENT_KEY_FOR_SESSION_DATA + ], + }) + ); } resolve(); } catch (err) { diff --git a/lib/build/recipe/session/types.d.ts b/lib/build/recipe/session/types.d.ts index 24cc30c9d..6e142362f 100644 --- a/lib/build/recipe/session/types.d.ts +++ b/lib/build/recipe/session/types.d.ts @@ -334,7 +334,7 @@ export declare type APIInterface = { }) => Promise< | { status: "OK"; - sessions: SessionInformation[]; + sessions: SessionInformationWithExtractedInformation[]; } | SessionError | GeneralErrorResponse @@ -368,6 +368,9 @@ export declare type SessionInformation = { timeCreated: number; tenantId: string; }; +export declare type SessionInformationWithExtractedInformation = SessionInformation & { + userAgent: string | undefined; +}; export declare type ClaimValidationResult = | { isValid: true; diff --git a/lib/ts/recipe/session/api/implementation.ts b/lib/ts/recipe/session/api/implementation.ts index 72175ae34..7a5f81eef 100644 --- a/lib/ts/recipe/session/api/implementation.ts +++ b/lib/ts/recipe/session/api/implementation.ts @@ -1,11 +1,12 @@ import SessionWrapper, { APIInterface, APIOptions, VerifySessionOptions } from "../"; import { normaliseHttpMethod } from "../../../utils"; import NormalisedURLPath from "../../../normalisedURLPath"; -import { SessionContainerInterface, SessionInformation } from "../types"; +import { SessionContainerInterface, SessionInformationWithExtractedInformation } from "../types"; import { GeneralErrorResponse, UserContext } from "../../../types"; import { getSessionFromRequest, refreshSessionInRequest } from "../sessionRequestFunctions"; import SessionError from "../error"; import { getUser } from "../../.."; +import { USER_AGENT_KEY_FOR_SESSION_DATA } from "../constants"; export default function getAPIInterface(): APIInterface { return { @@ -91,7 +92,7 @@ export default function getAPIInterface(): APIInterface { }): Promise< | { status: "OK"; - sessions: SessionInformation[]; + sessions: SessionInformationWithExtractedInformation[]; } | SessionError | GeneralErrorResponse @@ -130,7 +131,7 @@ export default function getAPIInterface(): APIInterface { // Since we need to fetch multiple sessions information, // we are creating multiple promises for fetching the details // and using a Promise.all() to resolve them together. - const userSessions: SessionInformation[] = []; + const userSessions: SessionInformationWithExtractedInformation[] = []; const sessionGetPromises: Promise[] = []; allSessionHandles.forEach((sessionHandle) => { @@ -142,7 +143,11 @@ export default function getAPIInterface(): APIInterface { userContext ); if (sessionInformation !== undefined) { - userSessions.push(sessionInformation); + userSessions.push({ + ...sessionInformation, + userAgent: + sessionInformation.sessionDataInDatabase[USER_AGENT_KEY_FOR_SESSION_DATA], + }); } resolve(); diff --git a/lib/ts/recipe/session/types.ts b/lib/ts/recipe/session/types.ts index bf8255b90..c4f3378ab 100644 --- a/lib/ts/recipe/session/types.ts +++ b/lib/ts/recipe/session/types.ts @@ -405,7 +405,7 @@ export type APIInterface = { }) => Promise< | { status: "OK"; - sessions: SessionInformation[]; + sessions: SessionInformationWithExtractedInformation[]; } | SessionError | GeneralErrorResponse @@ -443,6 +443,10 @@ export type SessionInformation = { tenantId: string; }; +export type SessionInformationWithExtractedInformation = SessionInformation & { + userAgent: string | undefined; +}; + export type ClaimValidationResult = { isValid: true } | { isValid: false; reason?: JSONValue }; export type ClaimValidationError = { id: string;