From b78027a25c90a4f63b8cac16ae218e182dead6a0 Mon Sep 17 00:00:00 2001 From: Francois Gerard Date: Thu, 12 Dec 2024 13:03:41 +0100 Subject: [PATCH 1/2] add new method to get a service passport --- src/ps-web-apis.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/ps-web-apis.ts b/src/ps-web-apis.ts index 7037ab3..8ea1872 100644 --- a/src/ps-web-apis.ts +++ b/src/ps-web-apis.ts @@ -48,6 +48,23 @@ export interface PurchaseData { entitlements: [string]; } +export interface ServicePassportSuccessResponse { + code: string; + message: string; + passport: string; + expires: number; +} + +export interface ServicePassportErrorResponse { + code: string; + message: string; +} + +export type ServicePassportResponse = + | ServicePassportSuccessResponse + | ServicePassportErrorResponse; + + export interface UserDataRequestResult { success: boolean; reason?: "userNotLoggedIn" | "generalError" | "userAborted"; @@ -197,6 +214,18 @@ export interface WhoamiV1 { * */ renderAuthComponent(container: HTMLElement, props: WonderwallProps): Promise; + + /** + * Retrieves a service passport for the specified service. + * The passport is intended to be used for authenticated communication with the service. + * + * @param service - The identifier or type of the service for which the passport is requested. + * Use "logora" or a custom service identifier as a string. + * + * @returns A promise that resolves to a ServicePassportResponse containing the token and related details. + */ + getServicePassport(service: "logora" | string): Promise; + } export interface AuthRes { From 3a80810d3c86f9100caf5a82611ba3f44aef3026 Mon Sep 17 00:00:00 2001 From: Francois Gerard Date: Thu, 12 Dec 2024 13:04:55 +0100 Subject: [PATCH 2/2] add new method to get a service passport --- dist/ps-web-apis.d.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dist/ps-web-apis.d.ts b/dist/ps-web-apis.d.ts index df83561..2ba4aa6 100644 --- a/dist/ps-web-apis.d.ts +++ b/dist/ps-web-apis.d.ts @@ -8,12 +8,26 @@ export interface WhoamiUserInfo { export interface PurchaseData { entitlements: [string]; } +export interface ServicePassportSuccessResponse { + code: string; + message: string; + passport: string; + expires: number; +} +export interface ServicePassportErrorResponse { + code: string; + message: string; +} +export declare type ServicePassportResponse = ServicePassportSuccessResponse | ServicePassportErrorResponse; export interface UserDataRequestResult { success: boolean; reason?: "userNotLoggedIn" | "generalError" | "userAborted"; } export declare type FetchOptions = RequestInit & { timeout?: number; + retries?: number; + retryDelay?: number; + retryStatusCodes?: number[]; }; export declare type WaitingRoomQueueDefault = ""; export declare type WaitingRoomQueue = WaitingRoomQueueDefault | "auth" | "checkout" | "lefty-in-app-purchase"; @@ -147,6 +161,16 @@ export interface WhoamiV1 { * */ renderAuthComponent(container: HTMLElement, props: WonderwallProps): Promise; + /** + * Retrieves a service passport for the specified service. + * The passport is intended to be used for authenticated communication with the service. + * + * @param service - The identifier or type of the service for which the passport is requested. + * Use "logora" or a custom service identifier as a string. + * + * @returns A promise that resolves to a ServicePassportResponse containing the token and related details. + */ + getServicePassport(service: "logora" | string): Promise; } export interface AuthRes { isLoggedIn: boolean;