-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathinterfaces.ts
More file actions
174 lines (159 loc) · 4.25 KB
/
Copy pathinterfaces.ts
File metadata and controls
174 lines (159 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
* @forgerock/javascript-sdk
*
* interfaces.ts
*
* Copyright (c) 2020 - 2025 Ping Identity Corporation. All rights reserved.
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
import type { ActionTypes } from './enums';
import type { FRCallbackFactory } from '../fr-auth/callbacks/factory';
import type { StringDict, Tokens } from '../shared/interfaces';
type LogLevel = 'none' | 'info' | 'warn' | 'error' | 'debug';
interface Action {
type: ActionTypes;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
payload: any;
}
/**
* Custom Logger for logger
*/
interface LoggerFunctions<
W = (...msgs: unknown[]) => void,
E = (...msgs: unknown[]) => void,
L = (...msgs: unknown[]) => void,
I = (...msgs: unknown[]) => void,
> {
warn?: W;
error?: E;
log?: L;
info?: I;
}
/**
* Configuration options.
*/
interface ConfigOptions {
callbackFactory?: FRCallbackFactory;
clientId?: string;
middleware?: RequestMiddleware[];
realmPath?: string;
redirectUri?: string;
scope?: string;
serverConfig?: ServerConfig;
tokenStore?: TokenStoreObject | 'sessionStorage' | 'localStorage';
tree?: string;
type?: string;
oauthThreshold?: number;
logLevel?: LogLevel;
logger?: LoggerFunctions;
platformHeader?: boolean;
prefix?: string;
}
/**
* Async ConfigOptions for well-known endpoint usage
*/
interface AsyncConfigOptions extends Omit<ConfigOptions, 'serverConfig'> {
serverConfig: AsyncServerConfig;
}
type ConfigurablePaths = keyof CustomPathConfig;
/**
* Optional configuration for custom paths for actions
*/
interface CustomPathConfig {
authenticate?: string;
authorize?: string;
accessToken?: string;
endSession?: string;
userInfo?: string;
revoke?: string;
sessions?: string;
}
type RequestMiddleware = (req: RequestObj, action: Action, next: () => RequestObj) => void;
interface RequestObj {
url: URL;
init: RequestInit;
}
/**
* Configuration settings for connecting to a server.
*/
interface ServerConfig {
baseUrl: string;
paths?: CustomPathConfig;
timeout?: number;
}
/**
* Configuration settings for async config with well-known
*/
interface AsyncServerConfig extends Omit<ServerConfig, 'baseUrl'> {
wellknown?: string;
}
/**
* API for implementing a custom token store
*/
interface TokenStoreObject {
get: (clientId: string) => Promise<Tokens>;
set: (clientId: string, token: Tokens) => Promise<void>;
remove: (clientId: string) => Promise<void>;
}
/**
* Configuration options with a server configuration specified.
*/
interface ValidConfigOptions extends ConfigOptions {
serverConfig: ServerConfig;
logLevel: LogLevel;
}
/**
* Represents configuration overrides used when requesting the next
* step in an authentication tree.
*/
interface StepOptions extends ConfigOptions {
query?: StringDict<string>;
}
interface WellKnownResponse {
issuer: string;
authorization_endpoint: string;
pushed_authorization_request_endpoint?: string;
token_endpoint: string;
userinfo_endpoint: string;
end_session_endpoint: string;
ping_end_idp_session_endpoint?: string;
introspection_endpoint: string;
revocation_endpoint: string;
jwks_uri?: string;
device_authorization_endpoint?: string;
claims_parameter_supported?: boolean;
request_parameter_supported?: boolean;
request_uri_parameter_supported?: boolean;
require_pushed_authorization_requests?: boolean;
scopes_supported?: string[];
response_types_supported?: string[];
response_modes_supported?: string[];
grant_types_supported?: string[];
subject_types_supported?: string[];
id_token_signing_alg_values_supported?: string[];
userinfo_signing_alg_values_supported?: string[];
request_object_signing_alg_values_supported?: string[];
token_endpoint_auth_methods_supported?: string[];
token_endpoint_auth_signing_alg_values_supported?: string[];
claim_types_supported?: string[];
claims_supported?: string[];
code_challenge_methods_supported?: string[];
}
export type {
Action,
AsyncConfigOptions,
AsyncServerConfig,
ConfigOptions,
ConfigurablePaths,
CustomPathConfig,
LogLevel,
LoggerFunctions,
RequestMiddleware,
RequestObj,
ServerConfig,
TokenStoreObject,
ValidConfigOptions,
StepOptions,
WellKnownResponse,
};