Skip to content

Commit 7994ff3

Browse files
committed
Add situation config to connect append component
1 parent 5cb8fea commit 7994ff3

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

packages/connect-react/src/components/append/AppendInitScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const AppendInitScreen = () => {
8080
getConnectService().setInvitation(invitationToken);
8181
}
8282

83-
const res = await getConnectService().appendInit(ac);
83+
const res = await getConnectService().appendInit(ac, config.situation);
8484
if (res.err) {
8585
if (res.val.type === ConnectErrorType.Cancel) {
8686
return;
@@ -107,7 +107,7 @@ const AppendInitScreen = () => {
107107
return handleSituation(AppendSituationCode.CtApiNotAvailablePreAuthenticator);
108108
}
109109

110-
const startAppendRes = await getConnectService().startAppend(appendToken, loadedMs, ac);
110+
const startAppendRes = await getConnectService().startAppend(appendToken, loadedMs, ac, undefined, config.situation);
111111
if (startAppendRes.err) {
112112
if (startAppendRes.val.type === ConnectErrorType.Cancel) {
113113
return;

packages/types/src/connect/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type CorbadoConnectAppendConfig = {
2626
onError?(error: string): void;
2727
onSkip(status: AppendStatus): Promise<void>;
2828
onComplete(status: AppendStatus, clientState: string): Promise<void>;
29+
situation?: string;
2930
};
3031

3132
export type AppendStatus = 'skip-implicit' | 'skip-explicit' | 'complete' | 'complete-noop';

packages/web-core/src/services/ConnectService.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ export class ConnectService {
350350
return loginFinishResp;
351351
}
352352

353-
async appendInit(abortController: AbortController): Promise<Result<ConnectAppendInitData, ConnectError>> {
353+
async appendInit(
354+
abortController: AbortController,
355+
situation?: string,
356+
): Promise<Result<ConnectAppendInitData, ConnectError>> {
354357
const existingProcess = ConnectProcess.loadFromStorage(this.#projectId);
355358
if (existingProcess) {
356359
log.debug('process exists, preparing api clients');
@@ -363,7 +366,10 @@ export class ConnectService {
363366
}
364367
}
365368

366-
const { req, flags } = await this.#getInitReq();
369+
const { req, flags } = await this.#getInitReq<ConnectAppendInitReq>();
370+
if (situation) {
371+
req.situation = situation;
372+
}
367373
const res = await this.wrapWithErr(() =>
368374
this.#connectApi.connectAppendInit(req, { signal: abortController.signal }),
369375
);
@@ -419,15 +425,16 @@ export class ConnectService {
419425
loadedMs: number,
420426
abortController?: AbortController,
421427
initiatedByUser?: boolean,
428+
situation?: string,
422429
): Promise<Result<ConnectAppendStartRsp, ConnectError>> {
423-
const existingProcess = await this.#getExistingProcess(() => this.appendInit(new AbortController()));
430+
const existingProcess = await this.#getExistingProcess(() => this.appendInit(new AbortController(), situation));
424431
if (!existingProcess) {
425432
return Err(new ConnectError(ConnectErrorType.MissingInit));
426433
}
427434

428435
return this.wrapWithErr(() =>
429436
this.#connectApi.connectAppendStart(
430-
{ appendTokenValue: appendTokenValue, forcePasskeyAppend: initiatedByUser, loadedMs },
437+
{ appendTokenValue, forcePasskeyAppend: initiatedByUser, loadedMs, situation },
431438
abortController && { signal: abortController.signal },
432439
),
433440
);

0 commit comments

Comments
 (0)