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 @@ -133,7 +133,7 @@ const AppendInitScreen = () => {
setAttestationOptions(startAppendRes.val.attestationOptions);
statefulLoader.current.finish();

if (flags?.hasSupportForAutomaticAppend()) {
if (startAppendRes.val.autoAppend) {
await handleSubmit(startAppendRes.val.attestationOptions, false);
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import useAppendProcess from '../../hooks/useAppendProcess';
import useShared from '../../hooks/useShared';
import { PasskeySuccessIcon } from '../shared/icons/PasskeySuccessIcon';
import { PrimaryButton } from '../shared/PrimaryButton';

Expand All @@ -11,6 +12,7 @@ type Props = {

const AppendSuccessScreen = ({ aaguidName }: Props) => {
const { config } = useAppendProcess();
const { getConnectService } = useShared();

const [completing, setCompleting] = React.useState(false);

Expand Down Expand Up @@ -40,7 +42,7 @@ const AppendSuccessScreen = ({ aaguidName }: Props) => {
}

setCompleting(true);
void config.onComplete('complete');
void config.onComplete('complete', getConnectService().encodeClientState());
}}
>
Continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const LoginErrorScreenHard = ({ previousAssertionOptions }: Props) => {
setLoading(false);

try {
await config.onComplete(connectLoginFinishToComplete(resFinish.val));
await config.onComplete(connectLoginFinishToComplete(resFinish.val), getConnectService().encodeClientState());
} catch {
return handleSituation(LoginSituationCode.CtApiNotAvailablePostAuthenticator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const LoginErrorScreenSoft = ({ previousAssertionOptions }: Props) => {
}

try {
await config.onComplete(connectLoginFinishToComplete(resFinish.val));
await config.onComplete(connectLoginFinishToComplete(resFinish.val), getConnectService().encodeClientState());
setLoading(false);
} catch {
handleSituation(LoginSituationCode.CtApiNotAvailablePostAuthenticator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const LoginHybridScreen = (resStart: ConnectLoginStartRsp) => {
}

try {
await config.onComplete(connectLoginFinishToComplete(res.val));
await config.onComplete(connectLoginFinishToComplete(res.val), getConnectService().encodeClientState());
} catch {
return handleSituation(LoginSituationCode.CtApiNotAvailablePostAuthenticator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ const LoginInitScreen: FC<Props> = ({ showFallback = false }) => {
getConnectService().setInvitation(invitationToken);
}

const na = url.searchParams.get('not_authenticated');
if (na === '1') {
getConnectService().handleNa();
}
getConnectService().enrichClientState(config.clientState);

const res = await getConnectService().loginInit(ac);
if (res.err) {
Expand Down Expand Up @@ -180,7 +177,7 @@ const LoginInitScreen: FC<Props> = ({ showFallback = false }) => {
}

try {
await config.onComplete(connectLoginFinishToComplete(res.val));
await config.onComplete(connectLoginFinishToComplete(res.val), getConnectService().encodeClientState());
} catch {
return handleSituation(LoginSituationCode.CtApiNotAvailablePostAuthenticator);
}
Expand Down Expand Up @@ -226,7 +223,7 @@ const LoginInitScreen: FC<Props> = ({ showFallback = false }) => {
}

try {
await config.onComplete(connectLoginFinishToComplete(res.val));
await config.onComplete(connectLoginFinishToComplete(res.val), getConnectService().encodeClientState());
} catch {
void getConnectService().recordEventLoginErrorUntyped();
return handleSituation(LoginSituationCode.CtApiNotAvailablePostAuthenticator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const LoginPasskeyReLoginScreen = () => {
}

try {
await config.onComplete(connectLoginFinishToComplete(resFinish.val));
await config.onComplete(connectLoginFinishToComplete(resFinish.val), getConnectService().encodeClientState());
} catch {
return handleSituation(LoginSituationCode.CtApiNotAvailablePostAuthenticator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const AppendProcessProvider: FC<PropsWithChildren<Props>> = ({ children,
log.debug('error (credential-exists)');

await getConnectService().recordEventAppendCredentialExistsError();
void config.onComplete('complete-noop');
void config.onComplete('complete-noop', getConnectService().encodeClientState());
}, [getConnectService, config]);

const contextValue = useMemo<AppendProcessContextProps>(
Expand Down
5 changes: 3 additions & 2 deletions packages/types/src/connect/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ export type CorbadoConnectLoginConfig = {
onFallbackCustom?(identifier: string, code: string, payload: string): void;
onError?(error: string): void;
onLoaded?(message: string, isFallBackTriggered: boolean): void;
onComplete(signedPasskeyData: string): Promise<void>;
onComplete(signedPasskeyData: string, clientState: string): Promise<void>;
onConditionalLoginStart?(ac: AbortController): void;
onLoginStart?(): void;
onHelpClick?(): void;
onSignupClick?(): void;
clientState?: string;
};

export type CorbadoConnectLoginSecondFactorConfig = {
Expand All @@ -23,7 +24,7 @@ export type CorbadoConnectAppendConfig = {
appendTokenProvider(): Promise<string>;
onError?(error: string): void;
onSkip(status: AppendStatus): Promise<void>;
onComplete(status: AppendStatus): Promise<void>;
onComplete(status: AppendStatus, clientState: string): Promise<void>;
};

export type AppendStatus = 'skip-implicit' | 'skip-explicit' | 'complete' | 'complete-noop';
Expand Down
19 changes: 19 additions & 0 deletions packages/web-core/openapi/spec_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,8 @@ components:
type: string
identifierHintAvailable:
type: boolean
oneTapMeta:
$ref: '#/components/schemas/clientStateMeta'

connectLoginStartRsp:
type: object
Expand Down Expand Up @@ -1352,6 +1354,7 @@ components:
- attestationOptions
- variant
- isRestrictedBrowser
- autoAppend
properties:
attestationOptions:
type: string
Expand All @@ -1363,6 +1366,8 @@ components:
- after-error
isRestrictedBrowser:
type: boolean
autoAppend:
type: boolean

connectAppendFinishReq:
type: object
Expand Down Expand Up @@ -1945,6 +1950,20 @@ components:
type: boolean
privateMode:
type: boolean
clientEnvHandleMeta:
$ref: '#/components/schemas/clientStateMeta'

clientStateMeta:
type: object
required:
- ts
- source
properties:
ts:
type: integer
source:
type: string
enum: [ 'ls', 'url' ]

clientCapabilities:
type: object
Expand Down
45 changes: 45 additions & 0 deletions packages/web-core/src/api/v2/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,40 @@ export interface ClientInformation {
* @memberof ClientInformation
*/
'privateMode'?: boolean;
/**
*
* @type {ClientStateMeta}
* @memberof ClientInformation
*/
'clientEnvHandleMeta'?: ClientStateMeta;
}
/**
*
* @export
* @interface ClientStateMeta
*/
export interface ClientStateMeta {
/**
*
* @type {number}
* @memberof ClientStateMeta
*/
'ts': number;
/**
*
* @type {string}
* @memberof ClientStateMeta
*/
'source': ClientStateMetaSourceEnum;
}

export const ClientStateMetaSourceEnum = {
Ls: 'ls',
Url: 'url'
} as const;

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

/**
*
* @export
Expand Down Expand Up @@ -390,6 +423,12 @@ export interface ConnectAppendStartRsp {
* @memberof ConnectAppendStartRsp
*/
'isRestrictedBrowser': boolean;
/**
*
* @type {boolean}
* @memberof ConnectAppendStartRsp
*/
'autoAppend': boolean;
}

export const ConnectAppendStartRspVariantEnum = {
Expand Down Expand Up @@ -593,6 +632,12 @@ export interface ConnectLoginStartReq {
* @memberof ConnectLoginStartReq
*/
'identifierHintAvailable'?: boolean;
/**
*
* @type {ClientStateMeta}
* @memberof ConnectLoginStartReq
*/
'oneTapMeta'?: ClientStateMeta;
}

export const ConnectLoginStartReqSourceEnum = {
Expand Down
2 changes: 0 additions & 2 deletions packages/web-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ export * from './api';
export * from './models/emailVerifyFromUrl';
export * from './models/lastIdentifier';

export * from './models/connect/connectLastLogin';

export { CredentialRequestOptionsJSON } from '@corbado/webauthn-json';
54 changes: 0 additions & 54 deletions packages/web-core/src/models/connect/connectLastLogin.ts

This file was deleted.

Loading
Loading