@casual-simulation/aux-vm-browser
Version:
A set of utilities required to securely run an AUX in a web browser.
100 lines • 5.3 kB
TypeScript
import type { AuthHelperInterface, LoginHint, LoginStatus, LoginUIStatus, PolicyUrls, PrivoSignUpInfo } from '@casual-simulation/aux-vm';
import { BehaviorSubject, Subscription } from 'rxjs';
import type { AuthData, AvailablePermissions, RemoteCausalRepoProtocol, PublicRecordKeyPolicy } from '@casual-simulation/aux-common';
import type { GetPlayerConfigResult, CreatePublicRecordKeyResult, IsValidDisplayNameResult, IsValidEmailAddressResult, GrantMarkerPermissionResult, GrantResourcePermissionResult, CompleteLoginSuccess, CompleteWebAuthnLoginSuccess, ValidateSessionKeyFailure } from '@casual-simulation/aux-records';
export declare const WRAPPER_CREATION_TIMEOUT_MS = 2000;
/**
* Defines a class that helps handle authentication/authorization for a particular endpoint.
*/
export declare class AuthEndpointHelper implements AuthHelperInterface {
private _origin;
private _defaultRecordsOrigin;
private _iframe;
private _channel;
private _proxy;
private _initialized;
private _protocolVersion;
protected _sub: Subscription;
private _loginStatus;
private _loginUIStatus;
private _initPromise;
private _recordsOrigin;
private _websocketOrigin;
private _websocketProtocol;
private _newTab;
private _tabCloseInterval;
private _requirePrivoLogin;
private _initialSessionKey;
private _initialConnectionKey;
private _authenticationPromise;
private _authenticating;
get currentLoginStatus(): LoginStatus;
/**
* Creates a new instance of the AuthHelper class.
* @param iframeOrigin The URL that the auth iframe should be loaded from.
* @param defaultRecordsOrigin The HTTP Origin that should be used for the records origin if the auth site does not support protocol version 4.
* @param requirePrivoLogin Whether to require that the user login with Privo.
* @param sessionKey The session key that should be used. If not specified, then the stored session key will be used.
* @param connectionKey The connection key that should be used. If not specified, then the stored connection key will be used.
*/
constructor(iframeOrigin?: string, defaultRecordsOrigin?: string, requirePrivoLogin?: boolean, sessionKey?: string, connectionKey?: string);
get origin(): string;
get recordsOrigin(): string;
get loginStatus(): BehaviorSubject<LoginStatus>;
get loginUIStatus(): BehaviorSubject<LoginUIStatus>;
/**
* Gets whether authentication is supported by this inst.
*/
get supportsAuthentication(): boolean;
get closed(): boolean;
unsubscribe(): void;
dispose(): void;
private _init;
protected _initCore(): Promise<void>;
private _handleOAuthRedirectCallback;
/**
* Determines if the user is authenticated.
*/
isAuthenticated(): Promise<boolean>;
protected _isAuthenticatedCore(): Promise<boolean>;
relogin(): Promise<void>;
/**
* Requests that the user become authenticated if they are not already.
*/
authenticate(hint?: LoginHint): Promise<AuthData>;
protected _authenticateCore(hint?: LoginHint): Promise<AuthData>;
/**
* Requests that the user become authenticated entirely in the background.
* This will not show any UI to the user but may also mean that the user will not be able to be authenticated.
*/
authenticateInBackground(): Promise<AuthData>;
protected _authenticateInBackgroundCore(): Promise<AuthData>;
createPublicRecordKey(recordName: string, policy: PublicRecordKeyPolicy): Promise<CreatePublicRecordKeyResult>;
protected _createPublicRecordKeyCore(recordName: string, policy: PublicRecordKeyPolicy): Promise<CreatePublicRecordKeyResult>;
getRecordsOrigin(): Promise<string>;
getWebsocketOrigin(): Promise<string>;
getWebsocketProtocol(): Promise<RemoteCausalRepoProtocol>;
getRecordKeyPolicy(recordKey: string): Promise<PublicRecordKeyPolicy>;
getAuthToken(): Promise<string>;
protected _getAuthTokenCore(): Promise<string>;
getConnectionKey(): Promise<string>;
protected _getConnectionKeyCore(): Promise<string>;
openAccountPage(): Promise<void>;
setUseCustomUI(useCustomUI: boolean): Promise<void>;
provideEmailAddress(email: string, acceptedTermsOfService: boolean): Promise<void>;
isValidEmailAddress(email: string): Promise<IsValidEmailAddressResult>;
isValidDisplayName(displayName: string, name: string): Promise<IsValidDisplayNameResult>;
provideSmsNumber(sms: string, acceptedTermsOfService: boolean): Promise<void>;
provideCode(code: string): Promise<void>;
provideLoginResult(result: CompleteLoginSuccess | CompleteWebAuthnLoginSuccess): Promise<void>;
providePrivoSignUpInfo(info: PrivoSignUpInfo): Promise<void>;
provideHasAccount(hasAccount: boolean): Promise<void>;
cancelLogin(): Promise<void>;
logout(): Promise<void>;
protected _logoutCore(): Promise<void>;
getPolicyUrls(): Promise<PolicyUrls>;
getComIdWebConfig(comId: string): Promise<GetPlayerConfigResult>;
grantPermission(recordName: string, permission: AvailablePermissions): Promise<GrantMarkerPermissionResult | GrantResourcePermissionResult | ValidateSessionKeyFailure>;
private _createNewTab;
}
//# sourceMappingURL=AuthEndpointHelper.d.ts.map