Skip to content

Commit

Permalink
Merge pull request #77 from spring-media/apiForServicePassports
Browse files Browse the repository at this point in the history
PA-5013: JS-APi for getting service passports
  • Loading branch information
fgerardwltn24 authored Dec 12, 2024
2 parents 19b902e + 3a80810 commit 02fe82d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
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

0 comments on commit 02fe82d

Please sign in to comment.