Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const LoginInitScreen: FC<Props> = ({ showFallback = false }) => {
() => {
return;
},
loadedMs,
);

if (res.err) {
Expand Down
41 changes: 40 additions & 1 deletion packages/web-core/openapi/spec_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,8 @@ components:
type: boolean
shortSessionCookieConfig:
$ref: '#/components/schemas/shortSessionCookieConfig'
sessionTokenCookieConfig:
$ref: '#/components/schemas/sessionTokenCookieConfig'
frontendApiUrl:
type: string

Expand Down Expand Up @@ -1170,9 +1172,13 @@ components:
type: object
required:
- shortSession
- sessionToken
properties:
shortSession:
type: string
deprecated: true
sessionToken:
type: string

mePasskeyDeleteRsp:
type: object
Expand Down Expand Up @@ -1266,6 +1272,9 @@ components:
type: boolean
assertionResponse:
type: string
loadedMs:
type: integer
format: int64

connectLoginFinishRsp:
type: object
Expand Down Expand Up @@ -1592,6 +1601,28 @@ components:
type: boolean

shortSessionCookieConfig:
type: object
deprecated: true
required:
- domain
- secure
- sameSite
- path
- lifetimeSeconds
properties:
domain:
type: string
secure:
type: boolean
sameSite:
type: string
enum: [ 'lax', 'strict', 'none' ]
path:
type: string
lifetimeSeconds:
type: integer

sessionTokenCookieConfig:
type: object
required:
- domain
Expand Down Expand Up @@ -1820,14 +1851,22 @@ components:
required:
- blockType
- shortSession
- sessionToken
properties:
blockType:
type: string
longSession:
type: string
description: Only given when project environment is dev
deprecated: true
description: This is only set if the project environment is set to 'dev'. If set the UI components will set the longSession in local storage because the cookie dropping will not work in Safari for example ("third-party cookie").
refreshToken:
type: string
description: This is only set if the project environment is set to 'dev'. If set the UI components will set the longSession in local storage because the cookie dropping will not work in Safari for example ("third-party cookie").
shortSession:
type: string
deprecated: true
sessionToken:
type: string
passkeyOperation:
$ref: '#/components/schemas/passkeyOperation'

Expand Down
82 changes: 81 additions & 1 deletion packages/web-core/src/api/v2/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ export interface ConnectLoginFinishReq {
* @memberof ConnectLoginFinishReq
*/
'assertionResponse': string;
/**
*
* @type {number}
* @memberof ConnectLoginFinishReq
*/
'loadedMs'?: number;
}
/**
*
Expand Down Expand Up @@ -855,17 +861,31 @@ export interface GeneralBlockCompleted {
*/
'blockType': string;
/**
* Only given when project environment is dev
* This is only set if the project environment is set to \'dev\'. If set the UI components will set the longSession in local storage because the cookie dropping will not work in Safari for example (\"third-party cookie\").
* @type {string}
* @memberof GeneralBlockCompleted
* @deprecated
*/
'longSession'?: string;
/**
* This is only set if the project environment is set to \'dev\'. If set the UI components will set the longSession in local storage because the cookie dropping will not work in Safari for example (\"third-party cookie\").
* @type {string}
* @memberof GeneralBlockCompleted
*/
'refreshToken'?: string;
/**
*
* @type {string}
* @memberof GeneralBlockCompleted
* @deprecated
*/
'shortSession': string;
/**
*
* @type {string}
* @memberof GeneralBlockCompleted
*/
'sessionToken': string;
/**
*
* @type {PasskeyOperation}
Expand Down Expand Up @@ -1644,8 +1664,15 @@ export interface MeRefreshRsp {
*
* @type {string}
* @memberof MeRefreshRsp
* @deprecated
*/
'shortSession': string;
/**
*
* @type {string}
* @memberof MeRefreshRsp
*/
'sessionToken': string;
}
/**
*
Expand Down Expand Up @@ -2163,15 +2190,68 @@ export interface SessionConfigRsp {
*
* @type {ShortSessionCookieConfig}
* @memberof SessionConfigRsp
* @deprecated
*/
'shortSessionCookieConfig'?: ShortSessionCookieConfig;
/**
*
* @type {SessionTokenCookieConfig}
* @memberof SessionConfigRsp
*/
'sessionTokenCookieConfig'?: SessionTokenCookieConfig;
/**
*
* @type {string}
* @memberof SessionConfigRsp
*/
'frontendApiUrl'?: string;
}
/**
*
* @export
* @interface SessionTokenCookieConfig
*/
export interface SessionTokenCookieConfig {
/**
*
* @type {string}
* @memberof SessionTokenCookieConfig
*/
'domain': string;
/**
*
* @type {boolean}
* @memberof SessionTokenCookieConfig
*/
'secure': boolean;
/**
*
* @type {string}
* @memberof SessionTokenCookieConfig
*/
'sameSite': SessionTokenCookieConfigSameSiteEnum;
/**
*
* @type {string}
* @memberof SessionTokenCookieConfig
*/
'path': string;
/**
*
* @type {number}
* @memberof SessionTokenCookieConfig
*/
'lifetimeSeconds': number;
}

export const SessionTokenCookieConfigSameSiteEnum = {
Lax: 'lax',
Strict: 'strict',
None: 'none'
} as const;

export type SessionTokenCookieConfigSameSiteEnum = typeof SessionTokenCookieConfigSameSiteEnum[keyof typeof SessionTokenCookieConfigSameSiteEnum];

/**
*
* @export
Expand Down
10 changes: 6 additions & 4 deletions packages/web-core/src/services/ConnectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ export class ConnectService {
connectToken?: string,
ac?: AbortController,
): Promise<Result<ConnectLoginStartRsp, CorbadoError>> {
const existingProcess = await this.#getExistingProcess(() => this.loginInit(ac ?? new AbortController()));
if (!existingProcess) {
const existingProcess = await this.loginInit(ac ?? new AbortController());
if (existingProcess.err) {
return Err(CorbadoError.missingInit());
}

Expand Down Expand Up @@ -279,6 +279,7 @@ export class ConnectService {
preWebAuthn: (ac: AbortController) => void,
postWebAuthn: () => void,
onLoginEnd: () => void,
loadedMs: number,
): Promise<Result<ConnectLoginFinishRsp, CorbadoError>> {
const existingProcess = await this.#getExistingProcess(() => this.loginInit(new AbortController()));
if (!existingProcess) {
Expand All @@ -297,7 +298,7 @@ export class ConnectService {
}

postWebAuthn();
const loginFinishResp = await this.#loginFinish(res.val, true);
const loginFinishResp = await this.#loginFinish(res.val, true, loadedMs);
onLoginEnd();

return loginFinishResp;
Expand Down Expand Up @@ -432,14 +433,15 @@ export class ConnectService {
async #loginFinish(
assertionResponse: string,
isConditionalUI: boolean,
loadedMs?: number,
): Promise<Result<ConnectLoginFinishRsp, CorbadoError>> {
const existingProcess = await this.#getExistingProcess(() => this.loginInit(new AbortController()));
if (!existingProcess) {
return Err(CorbadoError.missingInit());
}

const res = await this.wrapWithErr(() =>
this.#connectApi.connectLoginFinish({ assertionResponse, isConditionalUI }, { timeout: 15 * 1000 }),
this.#connectApi.connectLoginFinish({ assertionResponse, isConditionalUI, loadedMs }, { timeout: 15 * 1000 }),
);

if (isConditionalUI) {
Expand Down
Loading