Skip to content

PA-5013: JS-APi for getting service passports #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 12, 2024
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
24 changes: 24 additions & 0 deletions dist/ps-web-apis.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -147,6 +161,16 @@ export interface WhoamiV1 {
*
*/
renderAuthComponent(container: HTMLElement, props: WonderwallProps): Promise<AuthRes>;
/**
* 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<ServicePassportResponse>;
}
export interface AuthRes {
isLoggedIn: boolean;
Expand Down
29 changes: 29 additions & 0 deletions src/ps-web-apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -197,6 +214,18 @@ export interface WhoamiV1 {
*
*/
renderAuthComponent(container: HTMLElement, props: WonderwallProps): Promise<AuthRes>;

/**
* 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<ServicePassportResponse>;

}

export interface AuthRes {
Expand Down
Loading