|
1 |
| -interface GrapQlResponseType { |
2 |
| - data: any | undefined; |
3 |
| - errors: Error[]; |
4 |
| -} |
5 |
| -interface ApiResponse<T> { |
6 |
| - ok: boolean; |
7 |
| - errors: Error[]; |
8 |
| - data: T | undefined; |
9 |
| -} |
10 |
| -interface ConfigType { |
11 |
| - authorizerURL: string; |
12 |
| - redirectURL: string; |
13 |
| - clientID: string; |
14 |
| - extraHeaders?: Record<string, string>; |
15 |
| -} |
16 |
| -interface User { |
17 |
| - id: string; |
18 |
| - email: string; |
19 |
| - preferred_username: string; |
20 |
| - email_verified: boolean; |
21 |
| - signup_methods: string; |
22 |
| - given_name?: string | null; |
23 |
| - family_name?: string | null; |
24 |
| - middle_name?: string | null; |
25 |
| - nickname?: string | null; |
26 |
| - picture?: string | null; |
27 |
| - gender?: string | null; |
28 |
| - birthdate?: string | null; |
29 |
| - phone_number?: string | null; |
30 |
| - phone_number_verified?: boolean | null; |
31 |
| - roles?: string[]; |
32 |
| - created_at: number; |
33 |
| - updated_at: number; |
34 |
| - is_multi_factor_auth_enabled?: boolean; |
35 |
| - app_data?: Record<string, any>; |
36 |
| -} |
37 |
| -interface AuthToken { |
38 |
| - message?: string; |
39 |
| - access_token: string; |
40 |
| - expires_in: number; |
41 |
| - id_token: string; |
42 |
| - refresh_token?: string; |
43 |
| - user?: User; |
44 |
| - should_show_email_otp_screen?: boolean; |
45 |
| - should_show_mobile_otp_screen?: boolean; |
46 |
| -} |
47 |
| -interface GenericResponse { |
48 |
| - message: string; |
49 |
| -} |
50 |
| -type Headers = Record<string, string>; |
51 |
| -interface LoginInput { |
52 |
| - email?: string; |
53 |
| - phone_number?: string; |
54 |
| - password: string; |
55 |
| - roles?: string[]; |
56 |
| - scope?: string[]; |
57 |
| - state?: string; |
58 |
| -} |
59 |
| -interface SignupInput { |
60 |
| - email?: string; |
61 |
| - password: string; |
62 |
| - confirm_password: string; |
63 |
| - given_name?: string; |
64 |
| - family_name?: string; |
65 |
| - middle_name?: string; |
66 |
| - nickname?: string; |
67 |
| - picture?: string; |
68 |
| - gender?: string; |
69 |
| - birthdate?: string; |
70 |
| - phone_number?: string; |
71 |
| - roles?: string[]; |
72 |
| - scope?: string[]; |
73 |
| - redirect_uri?: string; |
74 |
| - is_multi_factor_auth_enabled?: boolean; |
75 |
| - state?: string; |
76 |
| - app_data?: Record<string, any>; |
77 |
| -} |
78 |
| -interface MagicLinkLoginInput { |
79 |
| - email: string; |
80 |
| - roles?: string[]; |
81 |
| - scopes?: string[]; |
82 |
| - state?: string; |
83 |
| - redirect_uri?: string; |
84 |
| -} |
85 |
| -interface VerifyEmailInput { |
86 |
| - token: string; |
87 |
| - state?: string; |
88 |
| -} |
89 |
| -interface ResendVerifyEmailInput { |
90 |
| - email: string; |
91 |
| - identifier: string; |
92 |
| -} |
93 |
| -interface VerifyOtpInput { |
94 |
| - email?: string; |
95 |
| - phone_number?: string; |
96 |
| - otp: string; |
97 |
| - state?: string; |
98 |
| -} |
99 |
| -interface ResendOtpInput { |
100 |
| - email?: string; |
101 |
| - phone_number?: string; |
102 |
| -} |
103 |
| -interface GraphqlQueryInput { |
104 |
| - query: string; |
105 |
| - variables?: Record<string, any>; |
106 |
| - headers?: Headers; |
107 |
| -} |
108 |
| -interface MetaData { |
109 |
| - version: string; |
110 |
| - client_id: string; |
111 |
| - is_google_login_enabled: boolean; |
112 |
| - is_facebook_login_enabled: boolean; |
113 |
| - is_github_login_enabled: boolean; |
114 |
| - is_linkedin_login_enabled: boolean; |
115 |
| - is_apple_login_enabled: boolean; |
116 |
| - is_twitter_login_enabled: boolean; |
117 |
| - is_microsoft_login_enabled: boolean; |
118 |
| - is_email_verification_enabled: boolean; |
119 |
| - is_basic_authentication_enabled: boolean; |
120 |
| - is_magic_link_login_enabled: boolean; |
121 |
| - is_sign_up_enabled: boolean; |
122 |
| - is_strong_password_enabled: boolean; |
123 |
| -} |
124 |
| -interface UpdateProfileInput { |
125 |
| - old_password?: string; |
126 |
| - new_password?: string; |
127 |
| - confirm_new_password?: string; |
128 |
| - email?: string; |
129 |
| - given_name?: string; |
130 |
| - family_name?: string; |
131 |
| - middle_name?: string; |
132 |
| - nickname?: string; |
133 |
| - gender?: string; |
134 |
| - birthdate?: string; |
135 |
| - phone_number?: string; |
136 |
| - picture?: string; |
137 |
| - is_multi_factor_auth_enabled?: boolean; |
138 |
| - app_data?: Record<string, any>; |
139 |
| -} |
140 |
| -interface ForgotPasswordInput { |
141 |
| - email: string; |
142 |
| - state?: string; |
143 |
| - redirect_uri?: string; |
144 |
| -} |
145 |
| -interface ResetPasswordInput { |
146 |
| - token: string; |
147 |
| - password: string; |
148 |
| - confirm_password: string; |
149 |
| -} |
150 |
| -interface SessionQueryInput { |
151 |
| - roles?: string[]; |
152 |
| -} |
153 |
| -interface IsValidJWTQueryInput { |
154 |
| - jwt: string; |
155 |
| - roles?: string[]; |
156 |
| -} |
157 |
| -interface ValidJWTResponse { |
158 |
| - valid: string; |
159 |
| - message: string; |
160 |
| -} |
161 |
| -declare enum OAuthProviders { |
162 |
| - Apple = "apple", |
163 |
| - Github = "github", |
164 |
| - Google = "google", |
165 |
| - Facebook = "facebook", |
166 |
| - LinkedIn = "linkedin" |
167 |
| -} |
168 |
| -declare enum ResponseTypes { |
169 |
| - Code = "code", |
170 |
| - Token = "token" |
171 |
| -} |
172 |
| -interface AuthorizeInput { |
173 |
| - response_type: ResponseTypes; |
174 |
| - use_refresh_token?: boolean; |
175 |
| - response_mode?: string; |
176 |
| -} |
177 |
| -interface AuthorizeResponse { |
178 |
| - state: string; |
179 |
| - code?: string; |
180 |
| - error?: string; |
181 |
| - error_description?: string; |
182 |
| -} |
183 |
| -interface RevokeTokenInput { |
184 |
| - refresh_token: string; |
185 |
| -} |
186 |
| -interface GetTokenInput { |
187 |
| - code?: string; |
188 |
| - grant_type?: string; |
189 |
| - refresh_token?: string; |
190 |
| -} |
191 |
| -interface GetTokenResponse { |
192 |
| - access_token: string; |
193 |
| - expires_in: number; |
194 |
| - id_token: string; |
195 |
| - refresh_token?: string; |
196 |
| -} |
197 |
| -interface ValidateJWTTokenInput { |
198 |
| - token_type: 'access_token' | 'id_token' | 'refresh_token'; |
199 |
| - token: string; |
200 |
| - roles?: string[]; |
201 |
| -} |
202 |
| -interface ValidateJWTTokenResponse { |
203 |
| - is_valid: boolean; |
204 |
| - claims: Record<string, any>; |
205 |
| -} |
206 |
| -interface ValidateSessionInput { |
207 |
| - cookie?: string; |
208 |
| - roles?: string[]; |
209 |
| -} |
210 |
| -interface ValidateSessionResponse { |
211 |
| - is_valid: boolean; |
212 |
| - user: User; |
213 |
| -} |
214 |
| - |
215 |
| -declare class Authorizer { |
| 1 | +import * as Types from './types'; |
| 2 | +import type { ApiResponse, AuthToken, AuthorizeResponse, ConfigType, GenericResponse, GetTokenResponse, MetaData, ResendVerifyEmailInput, User, ValidateJWTTokenResponse, ValidateSessionResponse } from './types'; |
| 3 | +export * from './types'; |
| 4 | +export declare class Authorizer { |
216 | 5 | config: ConfigType;
|
217 | 6 | codeVerifier: string;
|
218 | 7 | constructor(config: ConfigType);
|
219 |
| - authorize: (data: AuthorizeInput) => Promise<ApiResponse<GetTokenResponse> | ApiResponse<AuthorizeResponse>>; |
| 8 | + authorize: (data: Types.AuthorizeInput) => Promise<ApiResponse<GetTokenResponse> | ApiResponse<AuthorizeResponse>>; |
220 | 9 | browserLogin: () => Promise<ApiResponse<AuthToken>>;
|
221 |
| - forgotPassword: (data: ForgotPasswordInput) => Promise<ApiResponse<GenericResponse>>; |
| 10 | + forgotPassword: (data: Types.ForgotPasswordInput) => Promise<ApiResponse<GenericResponse>>; |
222 | 11 | getMetaData: () => Promise<ApiResponse<MetaData>>;
|
223 |
| - getProfile: (headers?: Headers) => Promise<ApiResponse<User>>; |
224 |
| - getSession: (headers?: Headers, params?: SessionQueryInput) => Promise<ApiResponse<AuthToken>>; |
225 |
| - getToken: (data: GetTokenInput) => Promise<ApiResponse<GetTokenResponse>>; |
226 |
| - login: (data: LoginInput) => Promise<ApiResponse<AuthToken>>; |
227 |
| - logout: (headers?: Headers) => Promise<ApiResponse<GenericResponse>>; |
228 |
| - magicLinkLogin: (data: MagicLinkLoginInput) => Promise<ApiResponse<GenericResponse>>; |
| 12 | + getProfile: (headers?: Types.Headers) => Promise<ApiResponse<User>>; |
| 13 | + getSession: (headers?: Types.Headers, params?: Types.SessionQueryInput) => Promise<ApiResponse<AuthToken>>; |
| 14 | + getToken: (data: Types.GetTokenInput) => Promise<ApiResponse<GetTokenResponse>>; |
| 15 | + login: (data: Types.LoginInput) => Promise<ApiResponse<AuthToken>>; |
| 16 | + logout: (headers?: Types.Headers) => Promise<ApiResponse<GenericResponse>>; |
| 17 | + magicLinkLogin: (data: Types.MagicLinkLoginInput) => Promise<ApiResponse<GenericResponse>>; |
229 | 18 | oauthLogin: (oauthProvider: string, roles?: string[], redirect_uri?: string, state?: string) => Promise<void>;
|
230 |
| - resendOtp: (data: ResendOtpInput) => Promise<ApiResponse<GenericResponse>>; |
231 |
| - resetPassword: (data: ResetPasswordInput) => Promise<ApiResponse<GenericResponse>>; |
| 19 | + resendOtp: (data: Types.ResendOtpInput) => Promise<ApiResponse<GenericResponse>>; |
| 20 | + resetPassword: (data: Types.ResetPasswordInput) => Promise<ApiResponse<GenericResponse>>; |
232 | 21 | revokeToken: (data: {
|
233 | 22 | refresh_token: string;
|
234 |
| - }) => Promise<ApiResponse<any>>; |
235 |
| - signup: (data: SignupInput) => Promise<ApiResponse<AuthToken>>; |
236 |
| - updateProfile: (data: UpdateProfileInput, headers?: Headers) => Promise<ApiResponse<GenericResponse>>; |
237 |
| - deactivateAccount: (headers?: Headers) => Promise<ApiResponse<GenericResponse>>; |
238 |
| - validateJWTToken: (params?: ValidateJWTTokenInput) => Promise<ApiResponse<ValidateJWTTokenResponse>>; |
239 |
| - validateSession: (params?: ValidateSessionInput) => Promise<ApiResponse<ValidateSessionResponse>>; |
240 |
| - verifyEmail: (data: VerifyEmailInput) => Promise<ApiResponse<AuthToken>>; |
| 23 | + }) => Promise<Types.ApiResponse<any>>; |
| 24 | + signup: (data: Types.SignupInput) => Promise<ApiResponse<AuthToken>>; |
| 25 | + updateProfile: (data: Types.UpdateProfileInput, headers?: Types.Headers) => Promise<ApiResponse<GenericResponse>>; |
| 26 | + deactivateAccount: (headers?: Types.Headers) => Promise<ApiResponse<GenericResponse>>; |
| 27 | + validateJWTToken: (params?: Types.ValidateJWTTokenInput) => Promise<ApiResponse<ValidateJWTTokenResponse>>; |
| 28 | + validateSession: (params?: Types.ValidateSessionInput) => Promise<ApiResponse<ValidateSessionResponse>>; |
| 29 | + verifyEmail: (data: Types.VerifyEmailInput) => Promise<ApiResponse<AuthToken>>; |
241 | 30 | resendVerifyEmail: (data: ResendVerifyEmailInput) => Promise<ApiResponse<GenericResponse>>;
|
242 |
| - verifyOtp: (data: VerifyOtpInput) => Promise<ApiResponse<AuthToken>>; |
| 31 | + verifyOtp: (data: Types.VerifyOtpInput) => Promise<ApiResponse<AuthToken>>; |
243 | 32 | private graphqlQuery;
|
244 | 33 | private errorResponse;
|
245 | 34 | private okResponse;
|
246 | 35 | }
|
247 |
| - |
248 |
| -export { ApiResponse, AuthToken, AuthorizeInput, AuthorizeResponse, Authorizer, ConfigType, ForgotPasswordInput, GenericResponse, GetTokenInput, GetTokenResponse, GrapQlResponseType, GraphqlQueryInput, Headers, IsValidJWTQueryInput, LoginInput, MagicLinkLoginInput, MetaData, OAuthProviders, ResendOtpInput, ResendVerifyEmailInput, ResetPasswordInput, ResponseTypes, RevokeTokenInput, SessionQueryInput, SignupInput, UpdateProfileInput, User, ValidJWTResponse, ValidateJWTTokenInput, ValidateJWTTokenResponse, ValidateSessionInput, ValidateSessionResponse, VerifyEmailInput, VerifyOtpInput }; |
0 commit comments