index.d.ts (react-native-app-auth@7.1.3)
0 removals
202 lines
3 additions
205 lines
export interface ServiceConfiguration {
export interface ServiceConfiguration {
authorizationEndpoint: string;
authorizationEndpoint: string;
tokenEndpoint: string;
tokenEndpoint: string;
revocationEndpoint?: string;
revocationEndpoint?: string;
registrationEndpoint?: string;
registrationEndpoint?: string;
endSessionEndpoint?: string;
endSessionEndpoint?: string;
}
}
export type BaseConfiguration =
export type BaseConfiguration =
| {
| {
issuer?: string;
issuer?: string;
serviceConfiguration: ServiceConfiguration;
serviceConfiguration: ServiceConfiguration;
}
}
| {
| {
issuer: string;
issuer: string;
serviceConfiguration?: ServiceConfiguration;
serviceConfiguration?: ServiceConfiguration;
};
};
type CustomHeaders = {
type CustomHeaders = {
authorize?: Record<string, string>;
authorize?: Record<string, string>;
token?: Record<string, string>;
token?: Record<string, string>;
register?: Record<string, string>;
register?: Record<string, string>;
};
};
type AdditionalHeaders = Record<string, string>;
type AdditionalHeaders = Record<string, string>;
interface BuiltInRegistrationParameters {
interface BuiltInRegistrationParameters {
client_name?: string;
client_name?: string;
logo_uri?: string;
logo_uri?: string;
client_uri?: string;
client_uri?: string;
policy_uri?: string;
policy_uri?: string;
tos_uri?: string;
tos_uri?: string;
}
}
export type RegistrationConfiguration = BaseConfiguration & {
export type RegistrationConfiguration = BaseConfiguration & {
redirectUrls: string[];
redirectUrls: string[];
responseTypes?: string[];
responseTypes?: string[];
grantTypes?: string[];
grantTypes?: string[];
subjectType?: string;
subjectType?: string;
tokenEndpointAuthMethod?: string;
tokenEndpointAuthMethod?: string;
additionalParameters?: BuiltInRegistrationParameters & { [name: string]: string };
additionalParameters?: BuiltInRegistrationParameters & { [name: string]: string };
dangerouslyAllowInsecureHttpRequests?: boolean;
dangerouslyAllowInsecureHttpRequests?: boolean;
customHeaders?: CustomHeaders;
customHeaders?: CustomHeaders;
additionalHeaders?: AdditionalHeaders;
additionalHeaders?: AdditionalHeaders;
};
};
export interface RegistrationResponse {
export interface RegistrationResponse {
clientId: string;
clientId: string;
additionalParameters?: { [name: string]: string };
additionalParameters?: { [name: string]: string };
clientIdIssuedAt?: string;
clientIdIssuedAt?: string;
clientSecret?: string;
clientSecret?: string;
clientSecretExpiresAt?: string;
clientSecretExpiresAt?: string;
registrationAccessToken?: string;
registrationAccessToken?: string;
registrationClientUri?: string;
registrationClientUri?: string;
tokenEndpointAuthMethod?: string;
tokenEndpointAuthMethod?: string;
}
}
interface BuiltInParameters {
interface BuiltInParameters {
display?: 'page' | 'popup' | 'touch' | 'wap';
display?: 'page' | 'popup' | 'touch' | 'wap';
login_prompt?: string;
login_prompt?: string;
prompt?: 'consent' | 'login' | 'none' | 'select_account';
prompt?: 'consent' | 'login' | 'none' | 'select_account';
}
}
export type BaseAuthConfiguration = BaseConfiguration & {
export type BaseAuthConfiguration = BaseConfiguration & {
clientId: string;
clientId: string;
};
};
export type AuthConfiguration = BaseAuthConfiguration & {
export type AuthConfiguration = BaseAuthConfiguration & {
clientSecret?: string;
clientSecret?: string;
scopes: string[];
scopes: string[];
redirectUrl: string;
redirectUrl: string;
additionalParameters?: BuiltInParameters & { [name: string]: string };
additionalParameters?: BuiltInParameters & { [name: string]: string };
clientAuthMethod?: 'basic' | 'post';
clientAuthMethod?: 'basic' | 'post';
dangerouslyAllowInsecureHttpRequests?: boolean;
dangerouslyAllowInsecureHttpRequests?: boolean;
customHeaders?: CustomHeaders;
customHeaders?: CustomHeaders;
additionalHeaders?: AdditionalHeaders;
additionalHeaders?: AdditionalHeaders;
connectionTimeoutSeconds?: number;
connectionTimeoutSeconds?: number;
useNonce?: boolean;
useNonce?: boolean;
usePKCE?: boolean;
usePKCE?: boolean;
warmAndPrefetchChrome?: boolean;
warmAndPrefetchChrome?: boolean;
skipCodeExchange?: boolean;
skipCodeExchange?: boolean;
iosCustomBrowser?: 'safari' | 'chrome' | 'opera' | 'firefox';
iosCustomBrowser?: 'safari' | 'chrome' | 'opera' | 'firefox';
androidAllowCustomBrowsers?: (
androidAllowCustomBrowsers?: (
| 'chrome'
| 'chrome'
| 'chromeCustomTab'
| 'chromeCustomTab'
| 'firefox'
| 'firefox'
| 'firefoxCustomTab'
| 'firefoxCustomTab'
| 'samsung'
| 'samsung'
| 'samsungCustomTab'
| 'samsungCustomTab'
)[];
)[];
androidTrustedWebActivity?: boolean;
androidTrustedWebActivity?: boolean;
iosPrefersEphemeralSession?: boolean;
iosPrefersEphemeralSession?: boolean;
};
};
export type EndSessionConfiguration = BaseAuthConfiguration & {
export type EndSessionConfiguration = BaseAuthConfiguration & {
additionalParameters?: { [name: string]: string };
additionalParameters?: { [name: string]: string };
dangerouslyAllowInsecureHttpRequests?: boolean;
dangerouslyAllowInsecureHttpRequests?: boolean;
iosPrefersEphemeralSession?: boolean;
iosPrefersEphemeralSession?: boolean;
};
};
export interface AuthorizeResult {
export interface AuthorizeResult {
accessToken: string;
accessToken: string;
accessTokenExpirationDate: string;
accessTokenExpirationDate: string;
authorizeAdditionalParameters?: { [name: string]: string };
authorizeAdditionalParameters?: { [name: string]: string };
tokenAdditionalParameters?: { [name: string]: string };
tokenAdditionalParameters?: { [name: string]: string };
idToken: string;
idToken: string;
refreshToken: string;
refreshToken: string;
tokenType: string;
tokenType: string;
scopes: string[];
scopes: string[];
authorizationCode: string;
authorizationCode: string;
codeVerifier?: string;
codeVerifier?: string;
}
}
export interface RefreshResult {
export interface RefreshResult {
accessToken: string;
accessToken: string;
accessTokenExpirationDate: string;
accessTokenExpirationDate: string;
additionalParameters?: { [name: string]: string };
additionalParameters?: { [name: string]: string };
idToken: string;
idToken: string;
refreshToken: string | null;
refreshToken: string | null;
tokenType: string;
tokenType: string;
}
}
export interface RevokeConfiguration {
export interface RevokeConfiguration {
tokenToRevoke: string;
tokenToRevoke: string;
sendClientId?: boolean;
sendClientId?: boolean;
includeBasicAuth?: boolean;
includeBasicAuth?: boolean;
}
}
export interface RefreshConfiguration {
export interface RefreshConfiguration {
refreshToken: string;
refreshToken: string;
}
}
export interface LogoutConfiguration {
export interface LogoutConfiguration {
idToken: string;
idToken: string;
postLogoutRedirectUrl: string;
postLogoutRedirectUrl: string;
}
}
export interface EndSessionResult {
export interface EndSessionResult {
idTokenHint: string;
idTokenHint: string;
postLogoutRedirectUri: string;
postLogoutRedirectUri: string;
state: string;
state: string;
}
}
export function prefetchConfiguration(config: AuthConfiguration): Promise<void>;
export function prefetchConfiguration(config: AuthConfiguration): Promise<void>;
export function register(config: RegistrationConfiguration): Promise<RegistrationResponse>;
export function register(config: RegistrationConfiguration): Promise<RegistrationResponse>;
export function authorize(config: AuthConfiguration): Promise<AuthorizeResult>;
export function authorize(config: AuthConfiguration): Promise<AuthorizeResult>;
export function refresh(
export function refresh(
config: AuthConfiguration,
config: AuthConfiguration,
refreshConfig: RefreshConfiguration
refreshConfig: RefreshConfiguration
): Promise<RefreshResult>;
): Promise<RefreshResult>;
export function revoke(
export function revoke(
config: BaseAuthConfiguration,
config: BaseAuthConfiguration,
revokeConfig: RevokeConfiguration
revokeConfig: RevokeConfiguration
): Promise<void>;
): Promise<void>;
export function logout(
export function logout(
config: EndSessionConfiguration,
config: EndSessionConfiguration,
logoutConfig: LogoutConfiguration
logoutConfig: LogoutConfiguration
): Promise<EndSessionResult>;
): Promise<EndSessionResult>;
export function close(): Promise<void>;
// https://tools.ietf.org/html/rfc6749#section-4.1.2.1
// https://tools.ietf.org/html/rfc6749#section-4.1.2.1
type OAuthAuthorizationErrorCode =
type OAuthAuthorizationErrorCode =
| 'unauthorized_client'
| 'unauthorized_client'
| 'access_denied'
| 'access_denied'
| 'unsupported_response_type'
| 'unsupported_response_type'
| 'invalid_scope'
| 'invalid_scope'
| 'server_error'
| 'server_error'
| 'temporarily_unavailable';
| 'temporarily_unavailable';
// https://tools.ietf.org/html/rfc6749#section-5.2
// https://tools.ietf.org/html/rfc6749#section-5.2
type OAuthTokenErrorCode =
type OAuthTokenErrorCode =
| 'invalid_request'
| 'invalid_request'
| 'invalid_client'
| 'invalid_client'
| 'invalid_grant'
| 'invalid_grant'
| 'unauthorized_client'
| 'unauthorized_client'
| 'unsupported_grant_type'
| 'unsupported_grant_type'
| 'invalid_scope';
| 'invalid_scope';
// https://openid.net/specs/openid-connect-registration-1_0.html#RegistrationError
// https://openid.net/specs/openid-connect-registration-1_0.html#RegistrationError
type OICRegistrationErrorCode = 'invalid_redirect_uri' | 'invalid_client_metadata';
type OICRegistrationErrorCode = 'invalid_redirect_uri' | 'invalid_client_metadata';
type AppAuthErrorCode =
type AppAuthErrorCode =
| 'service_configuration_fetch_error'
| 'service_configuration_fetch_error'
| 'authentication_failed'
| 'authentication_failed'
| 'token_refresh_failed'
| 'token_refresh_failed'
| 'token_exchange_failed'
| 'token_exchange_failed'
| 'registration_failed'
| 'registration_failed'
| 'browser_not_found'
| 'browser_not_found'
| 'end_session_failed'
| 'end_session_failed'
| 'authentication_error'
| 'authentication_error'
| 'run_time_exception';
| 'run_time_exception';
type ErrorCode =
type ErrorCode =
| OAuthAuthorizationErrorCode
| OAuthAuthorizationErrorCode
| OAuthTokenErrorCode
| OAuthTokenErrorCode
| OICRegistrationErrorCode
| OICRegistrationErrorCode
| AppAuthErrorCode;
| AppAuthErrorCode;
export interface AppAuthError extends Error {
export interface AppAuthError extends Error {
code: ErrorCode;
code: ErrorCode;
}
}