From 2fec86be5b58ff77a0f0f068ec10078f96dedbe3 Mon Sep 17 00:00:00 2001 From: Francois Gerard Date: Tue, 6 Aug 2024 13:29:22 +0200 Subject: [PATCH] add interface for ensureFNLN --- src/ps-web-apis.ts | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/ps-web-apis.ts b/src/ps-web-apis.ts index 0fa19c1..de1be96 100644 --- a/src/ps-web-apis.ts +++ b/src/ps-web-apis.ts @@ -45,8 +45,16 @@ export interface WhoamiUserInfo { } export interface PurchaseData { - entitlements: [string]; + entitlements + : [string]; } + +export interface UserDataRequestResult { + success: boolean; + reason?: "userNotLoggedIn" | "generalError" | "userAborted"; +} + + export type FetchOptions = RequestInit & { timeout?: number }; export type WaitingRoomQueueDefault = ""; export type WaitingRoomQueue = WaitingRoomQueueDefault | "auth" | "checkout"; @@ -62,6 +70,8 @@ export type GetRosettaEnvByKey = (key: string) => string | undefined; export type WaitForCapacity = (queue: WaitingRoomQueue) => Promise; export type RegisterIframeMessageListener = (eventtype: string, listener: (event: any, iframe: HTMLIFrameElement) => void) => void; + + export interface WhoamiV1 { /** * will assert valid not outdated session before fetch will be done. backend credentials will be added automatically @@ -78,6 +88,7 @@ export interface WhoamiV1 { * gives information if the user is currently a C1 User. These are users which are not logged in from * sso/mypass perspective. These users are originated from the apps and have potentially in app purchases. * If this method resolves to true isLogged in will resolve to false. + * @deprecated there is not replacement for the client planned */ isC1User(): boolean; /** @@ -91,6 +102,26 @@ export interface WhoamiV1 { * an error is resolved if session is invalid and not refeshable (= user logged out) */ ensureUserHasAuthorization(): Promise; + + /** + * Ensures that the user has provided both a first name and a last name. + * If the user has not provided these details, the function will prompt the user + * to enter them. Depending on the `skippable` parameter, the user may be allowed + * to skip this step. + * + * @param skippable - If true, the user can choose to skip providing their first name + * and last name. + * @param title - Optional. A custom title for the prompt that asks for the user's + * first name and last name. If not set default will be used. + * @param text - Optional. A custom text or message to display in the prompt. If not + * set default will be used. + * + * @returns A promise that resolves to an object indicating whether the user provided + * the required information (`success: true`) or not, along with a `reason` if applicable. + * Possible reasons include "userNotLoggedIn", "error", or "userAborted". + */ + ensureUserHasFirstNameAndLastName(skippable: boolean, title?: string, text?: string): Promise; + /** * will start login-process (e.g. go to sso-login) */ @@ -119,6 +150,7 @@ export interface WhoamiV1 { /** * will request customer pseudo id for currently logged user from consent backend * @param clientId The string identifier of the client for which the customer id is requested. + * @deprecated there is not replacement for the client planned */ getCustomerId(clientId: string): Promise; /**