@authorizerdev/authorizer-js 2.0.2 → 3.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -9,169 +9,240 @@ interface ApiResponse<T> {
9
9
  interface ConfigType {
10
10
  authorizerURL: string;
11
11
  redirectURL: string;
12
- clientID: string;
12
+ clientID?: string;
13
13
  extraHeaders?: Record<string, string>;
14
14
  }
15
+ interface Pagination {
16
+ limit: number;
17
+ page: number;
18
+ offset: number;
19
+ total: number;
20
+ }
21
+ interface Meta {
22
+ version: string;
23
+ client_id: string;
24
+ is_google_login_enabled: boolean;
25
+ is_facebook_login_enabled: boolean;
26
+ is_github_login_enabled: boolean;
27
+ is_linkedin_login_enabled: boolean;
28
+ is_apple_login_enabled: boolean;
29
+ is_discord_login_enabled: boolean;
30
+ is_twitter_login_enabled: boolean;
31
+ is_microsoft_login_enabled: boolean;
32
+ is_twitch_login_enabled: boolean;
33
+ is_roblox_login_enabled: boolean;
34
+ is_email_verification_enabled: boolean;
35
+ is_basic_authentication_enabled: boolean;
36
+ is_magic_link_login_enabled: boolean;
37
+ is_sign_up_enabled: boolean;
38
+ is_strong_password_enabled: boolean;
39
+ is_multi_factor_auth_enabled: boolean;
40
+ is_mobile_basic_authentication_enabled: boolean;
41
+ is_phone_verification_enabled: boolean;
42
+ }
15
43
  interface User {
16
44
  id: string;
17
- email: string;
18
- preferred_username: string;
45
+ email: string | null;
19
46
  email_verified: boolean;
20
47
  signup_methods: string;
48
+ given_name: string | null;
49
+ family_name: string | null;
50
+ middle_name: string | null;
51
+ nickname: string | null;
52
+ preferred_username: string | null;
53
+ gender: string | null;
54
+ birthdate: string | null;
55
+ phone_number: string | null;
56
+ phone_number_verified: boolean;
57
+ picture: string | null;
58
+ roles: string[];
59
+ created_at: number | null;
60
+ updated_at: number | null;
61
+ revoked_timestamp: number | null;
62
+ is_multi_factor_auth_enabled: boolean | null;
63
+ app_data: Record<string, any> | null;
64
+ }
65
+ interface Users {
66
+ pagination: Pagination;
67
+ users: User[];
68
+ }
69
+ interface VerificationRequest {
70
+ id: string;
71
+ identifier: string | null;
72
+ token: string | null;
73
+ email: string | null;
74
+ expires: number | null;
75
+ created_at: number | null;
76
+ updated_at: number | null;
77
+ nonce: string | null;
78
+ redirect_uri: string | null;
79
+ }
80
+ interface VerificationRequests {
81
+ pagination: Pagination;
82
+ verification_requests: VerificationRequest[];
83
+ }
84
+ interface AuthorizerError {
85
+ message: string;
86
+ reason: string;
87
+ }
88
+ interface AuthResponse {
89
+ message: string;
90
+ should_show_email_otp_screen: boolean | null;
91
+ should_show_mobile_otp_screen: boolean | null;
92
+ should_show_totp_screen: boolean | null;
93
+ access_token: string | null;
94
+ id_token: string | null;
95
+ refresh_token: string | null;
96
+ expires_in: number | null;
97
+ user: User | null;
98
+ authenticator_scanner_image: string | null;
99
+ authenticator_secret: string | null;
100
+ authenticator_recovery_codes: string[] | null;
101
+ }
102
+ type AuthToken = AuthResponse;
103
+ interface Response {
104
+ message: string;
105
+ }
106
+ type GenericResponse = Response;
107
+ interface ForgotPasswordResponse {
108
+ message: string;
109
+ should_show_mobile_otp_screen: boolean | null;
110
+ }
111
+ interface InviteMembersResponse {
112
+ message: string;
113
+ Users: User[];
114
+ }
115
+ interface LoginRequest {
116
+ email?: string | null;
117
+ phone_number?: string | null;
118
+ password: string;
119
+ roles?: string[] | null;
120
+ scope?: string[] | null;
121
+ state?: string | null;
122
+ }
123
+ interface SignUpRequest {
124
+ email?: string | null;
21
125
  given_name?: string | null;
22
126
  family_name?: string | null;
23
127
  middle_name?: string | null;
24
128
  nickname?: string | null;
25
- picture?: string | null;
26
129
  gender?: string | null;
27
130
  birthdate?: string | null;
28
131
  phone_number?: string | null;
29
- phone_number_verified?: boolean | null;
30
- roles?: string[];
31
- created_at: number;
32
- updated_at: number;
33
- is_multi_factor_auth_enabled?: boolean;
34
- app_data?: Record<string, any>;
35
- }
36
- interface AuthToken {
37
- message?: string;
38
- access_token: string;
39
- expires_in: number;
40
- id_token: string;
41
- refresh_token?: string;
42
- user?: User;
43
- should_show_email_otp_screen?: boolean;
44
- should_show_mobile_otp_screen?: boolean;
45
- should_show_totp_screen?: boolean;
46
- authenticator_scanner_image?: string;
47
- authenticator_secret?: string;
48
- authenticator_recovery_codes?: string[];
49
- }
50
- interface GenericResponse {
51
- message: string;
52
- }
53
- type Headers = Record<string, string>;
54
- interface LoginInput {
55
- email?: string;
56
- phone_number?: string;
57
- password: string;
58
- roles?: string[];
59
- scope?: string[];
60
- state?: string;
61
- }
62
- interface SignupInput {
63
- email?: string;
132
+ picture?: string | null;
64
133
  password: string;
65
134
  confirm_password: string;
66
- given_name?: string;
67
- family_name?: string;
68
- middle_name?: string;
69
- nickname?: string;
70
- picture?: string;
71
- gender?: string;
72
- birthdate?: string;
73
- phone_number?: string;
74
- roles?: string[];
75
- scope?: string[];
76
- redirect_uri?: string;
77
- is_multi_factor_auth_enabled?: boolean;
78
- state?: string;
79
- app_data?: Record<string, any>;
80
- }
81
- interface MagicLinkLoginInput {
135
+ roles?: string[] | null;
136
+ scope?: string[] | null;
137
+ redirect_uri?: string | null;
138
+ is_multi_factor_auth_enabled?: boolean | null;
139
+ state?: string | null;
140
+ app_data?: Record<string, any> | null;
141
+ }
142
+ type SignupRequest = SignUpRequest;
143
+ interface MagicLinkLoginRequest {
82
144
  email: string;
83
- roles?: string[];
84
- scopes?: string[];
85
- state?: string;
86
- redirect_uri?: string;
145
+ roles?: string[] | null;
146
+ scope?: string[] | null;
147
+ state?: string | null;
148
+ redirect_uri?: string | null;
87
149
  }
88
- interface VerifyEmailInput {
150
+ interface VerifyEmailRequest {
89
151
  token: string;
90
- state?: string;
152
+ state?: string | null;
91
153
  }
92
- interface ResendVerifyEmailInput {
154
+ interface ResendVerifyEmailRequest {
93
155
  email: string;
94
156
  identifier: string;
157
+ state?: string | null;
95
158
  }
96
- interface VerifyOtpInput {
97
- email?: string;
98
- phone_number?: string;
159
+ interface VerifyOTPRequest {
160
+ email?: string | null;
161
+ phone_number?: string | null;
99
162
  otp: string;
100
- state?: string;
101
- is_totp?: boolean;
163
+ is_totp?: boolean | null;
164
+ state?: string | null;
102
165
  }
103
- interface ResendOtpInput {
104
- email?: string;
105
- phone_number?: string;
106
- }
107
- interface GraphqlQueryInput {
108
- query: string;
109
- variables?: Record<string, any>;
110
- headers?: Headers;
111
- }
112
- interface MetaData {
113
- version: string;
114
- client_id: string;
115
- is_google_login_enabled: boolean;
116
- is_facebook_login_enabled: boolean;
117
- is_github_login_enabled: boolean;
118
- is_linkedin_login_enabled: boolean;
119
- is_apple_login_enabled: boolean;
120
- is_twitter_login_enabled: boolean;
121
- is_microsoft_login_enabled: boolean;
122
- is_twitch_login_enabled: boolean;
123
- is_email_verification_enabled: boolean;
124
- is_basic_authentication_enabled: boolean;
125
- is_magic_link_login_enabled: boolean;
126
- is_sign_up_enabled: boolean;
127
- is_strong_password_enabled: boolean;
128
- is_multi_factor_auth_enabled: boolean;
129
- is_mobile_basic_authentication_enabled: boolean;
130
- is_phone_verification_enabled: boolean;
166
+ type VerifyOtpRequest = VerifyOTPRequest;
167
+ interface ResendOTPRequest {
168
+ email?: string | null;
169
+ phone_number?: string | null;
170
+ state?: string | null;
171
+ }
172
+ type ResendOtpRequest = ResendOTPRequest;
173
+ interface UpdateProfileRequest {
174
+ old_password?: string | null;
175
+ new_password?: string | null;
176
+ confirm_new_password?: string | null;
177
+ email?: string | null;
178
+ given_name?: string | null;
179
+ family_name?: string | null;
180
+ middle_name?: string | null;
181
+ nickname?: string | null;
182
+ gender?: string | null;
183
+ birthdate?: string | null;
184
+ phone_number?: string | null;
185
+ picture?: string | null;
186
+ is_multi_factor_auth_enabled?: boolean | null;
187
+ app_data?: Record<string, any> | null;
131
188
  }
132
- interface UpdateProfileInput {
133
- old_password?: string;
134
- new_password?: string;
135
- confirm_new_password?: string;
136
- email?: string;
137
- given_name?: string;
138
- family_name?: string;
139
- middle_name?: string;
140
- nickname?: string;
141
- gender?: string;
142
- birthdate?: string;
143
- phone_number?: string;
144
- picture?: string;
145
- is_multi_factor_auth_enabled?: boolean;
146
- app_data?: Record<string, any>;
147
- }
148
- interface ForgotPasswordInput {
149
- email?: string;
150
- phone_number?: string;
151
- state?: string;
152
- redirect_uri?: string;
189
+ interface UpdateUserRequest {
190
+ id: string;
191
+ email?: string | null;
192
+ email_verified?: boolean | null;
193
+ given_name?: string | null;
194
+ family_name?: string | null;
195
+ middle_name?: string | null;
196
+ nickname?: string | null;
197
+ gender?: string | null;
198
+ birthdate?: string | null;
199
+ phone_number?: string | null;
200
+ phone_number_verified?: boolean | null;
201
+ picture?: string | null;
202
+ roles?: string[] | null;
203
+ is_multi_factor_auth_enabled?: boolean | null;
204
+ app_data?: Record<string, any> | null;
153
205
  }
154
- interface ForgotPasswordResponse {
155
- message: string;
156
- should_show_mobile_otp_screen?: boolean;
206
+ interface ForgotPasswordRequest {
207
+ email?: string | null;
208
+ phone_number?: string | null;
209
+ state?: string | null;
210
+ redirect_uri?: string | null;
157
211
  }
158
- interface ResetPasswordInput {
159
- token?: string;
160
- otp?: string;
161
- phone_number?: string;
212
+ interface ResetPasswordRequest {
213
+ token?: string | null;
214
+ otp?: string | null;
215
+ phone_number?: string | null;
162
216
  password: string;
163
217
  confirm_password: string;
164
218
  }
165
- interface SessionQueryInput {
166
- roles?: string[];
219
+ type ResetPasswordInput = ResetPasswordRequest;
220
+ interface DeleteUserRequest {
221
+ email: string;
167
222
  }
168
- interface IsValidJWTQueryInput {
169
- jwt: string;
170
- roles?: string[];
223
+ interface SessionQueryRequest {
224
+ roles?: string[] | null;
225
+ scope?: string[] | null;
171
226
  }
172
- interface ValidJWTResponse {
173
- valid: string;
174
- message: string;
227
+ type SessionQueryInput = SessionQueryRequest;
228
+ interface ValidateJWTTokenRequest {
229
+ token_type: string;
230
+ token: string;
231
+ roles?: string[] | null;
232
+ }
233
+ type ValidateJWTTokenInput = ValidateJWTTokenRequest;
234
+ interface ValidateJWTTokenResponse {
235
+ is_valid: boolean;
236
+ claims: Record<string, any>;
237
+ }
238
+ interface ValidateSessionRequest {
239
+ cookie: string;
240
+ roles?: string[] | null;
241
+ }
242
+ type ValidateSessionInput = ValidateSessionRequest;
243
+ interface ValidateSessionResponse {
244
+ is_valid: boolean;
245
+ user: User;
175
246
  }
176
247
  declare enum OAuthProviders {
177
248
  Apple = "apple",
@@ -181,17 +252,20 @@ declare enum OAuthProviders {
181
252
  LinkedIn = "linkedin",
182
253
  Twitter = "twitter",
183
254
  Microsoft = "microsoft",
184
- Twitch = "twitch"
255
+ Twitch = "twitch",
256
+ Roblox = "roblox",
257
+ Discord = "discord"
185
258
  }
186
259
  declare enum ResponseTypes {
187
260
  Code = "code",
188
261
  Token = "token"
189
262
  }
190
- interface AuthorizeInput {
263
+ interface AuthorizeRequest {
191
264
  response_type: ResponseTypes;
192
265
  use_refresh_token?: boolean;
193
266
  response_mode?: string;
194
267
  }
268
+ type AuthorizeInput = AuthorizeRequest;
195
269
  interface AuthorizeResponse {
196
270
  state: string;
197
271
  code?: string;
@@ -201,66 +275,66 @@ interface AuthorizeResponse {
201
275
  interface RevokeTokenInput {
202
276
  refresh_token: string;
203
277
  }
204
- interface GetTokenInput {
278
+ interface GetTokenRequest {
205
279
  code?: string;
206
280
  grant_type?: string;
207
281
  refresh_token?: string;
208
282
  }
283
+ type GetTokenInput = GetTokenRequest;
209
284
  interface GetTokenResponse {
210
285
  access_token: string;
211
286
  expires_in: number;
212
287
  id_token: string;
213
288
  refresh_token?: string;
214
289
  }
215
- interface ValidateJWTTokenInput {
216
- token_type: 'access_token' | 'id_token' | 'refresh_token';
217
- token: string;
218
- roles?: string[];
219
- }
220
- interface ValidateJWTTokenResponse {
221
- is_valid: boolean;
222
- claims: Record<string, any>;
290
+ type Headers = Record<string, string>;
291
+ interface GraphqlQueryRequest {
292
+ query: string;
293
+ variables?: Record<string, any>;
294
+ headers?: Headers;
223
295
  }
224
- interface ValidateSessionInput {
225
- cookie?: string;
296
+ interface IsValidJWTQueryInput {
297
+ jwt: string;
226
298
  roles?: string[];
227
299
  }
228
- interface ValidateSessionResponse {
229
- is_valid: boolean;
230
- user: User;
300
+ interface ValidJWTResponse {
301
+ valid: string;
302
+ message: string;
231
303
  }
304
+ type MetaDataResponse = Meta;
305
+ type MetaData = Meta;
232
306
 
233
307
  declare class Authorizer {
234
308
  config: ConfigType;
235
309
  codeVerifier: string;
236
310
  constructor(config: ConfigType);
237
- authorize: (data: AuthorizeInput) => Promise<ApiResponse<GetTokenResponse> | ApiResponse<AuthorizeResponse>>;
311
+ authorize: (data: AuthorizeRequest) => Promise<ApiResponse<GetTokenResponse> | ApiResponse<AuthorizeResponse>>;
238
312
  browserLogin: () => Promise<ApiResponse<AuthToken>>;
239
- forgotPassword: (data: ForgotPasswordInput) => Promise<ApiResponse<ForgotPasswordResponse>>;
313
+ forgotPassword: (data: ForgotPasswordRequest) => Promise<ApiResponse<ForgotPasswordResponse>>;
240
314
  getMetaData: () => Promise<ApiResponse<MetaData>>;
241
315
  getProfile: (headers?: Headers) => Promise<ApiResponse<User>>;
242
- getSession: (headers?: Headers, params?: SessionQueryInput) => Promise<ApiResponse<AuthToken>>;
243
- getToken: (data: GetTokenInput) => Promise<ApiResponse<GetTokenResponse>>;
244
- login: (data: LoginInput) => Promise<ApiResponse<AuthToken>>;
316
+ getSession: (headers?: Headers, params?: SessionQueryRequest) => Promise<ApiResponse<AuthToken>>;
317
+ getToken: (data: GetTokenRequest) => Promise<ApiResponse<GetTokenResponse>>;
318
+ login: (data: LoginRequest) => Promise<ApiResponse<AuthToken>>;
245
319
  logout: (headers?: Headers) => Promise<ApiResponse<GenericResponse>>;
246
- magicLinkLogin: (data: MagicLinkLoginInput) => Promise<ApiResponse<GenericResponse>>;
320
+ magicLinkLogin: (data: MagicLinkLoginRequest) => Promise<ApiResponse<GenericResponse>>;
247
321
  oauthLogin: (oauthProvider: string, roles?: string[], redirect_uri?: string, state?: string) => Promise<void>;
248
- resendOtp: (data: ResendOtpInput) => Promise<ApiResponse<GenericResponse>>;
249
- resetPassword: (data: ResetPasswordInput) => Promise<ApiResponse<GenericResponse>>;
322
+ resendOtp: (data: ResendOtpRequest) => Promise<ApiResponse<GenericResponse>>;
323
+ resetPassword: (data: ResetPasswordRequest) => Promise<ApiResponse<GenericResponse>>;
250
324
  revokeToken: (data: {
251
325
  refresh_token: string;
252
326
  }) => Promise<ApiResponse<any>>;
253
- signup: (data: SignupInput) => Promise<ApiResponse<AuthToken>>;
254
- updateProfile: (data: UpdateProfileInput, headers?: Headers) => Promise<ApiResponse<GenericResponse>>;
327
+ signup: (data: SignUpRequest) => Promise<ApiResponse<AuthToken>>;
328
+ updateProfile: (data: UpdateProfileRequest, headers?: Headers) => Promise<ApiResponse<GenericResponse>>;
255
329
  deactivateAccount: (headers?: Headers) => Promise<ApiResponse<GenericResponse>>;
256
- validateJWTToken: (params?: ValidateJWTTokenInput) => Promise<ApiResponse<ValidateJWTTokenResponse>>;
257
- validateSession: (params?: ValidateSessionInput) => Promise<ApiResponse<ValidateSessionResponse>>;
258
- verifyEmail: (data: VerifyEmailInput) => Promise<ApiResponse<AuthToken>>;
259
- resendVerifyEmail: (data: ResendVerifyEmailInput) => Promise<ApiResponse<GenericResponse>>;
260
- verifyOtp: (data: VerifyOtpInput) => Promise<ApiResponse<AuthToken>>;
261
- graphqlQuery: (data: GraphqlQueryInput) => Promise<GrapQlResponseType>;
330
+ validateJWTToken: (params?: ValidateJWTTokenRequest) => Promise<ApiResponse<ValidateJWTTokenResponse>>;
331
+ validateSession: (params?: ValidateSessionRequest) => Promise<ApiResponse<ValidateSessionResponse>>;
332
+ verifyEmail: (data: VerifyEmailRequest) => Promise<ApiResponse<AuthToken>>;
333
+ resendVerifyEmail: (data: ResendVerifyEmailRequest) => Promise<ApiResponse<GenericResponse>>;
334
+ verifyOtp: (data: VerifyOtpRequest) => Promise<ApiResponse<AuthToken>>;
335
+ graphqlQuery: (data: GraphqlQueryRequest) => Promise<GrapQlResponseType>;
262
336
  errorResponse: (errors: Error[]) => ApiResponse<any>;
263
337
  okResponse: (data: any) => ApiResponse<any>;
264
338
  }
265
339
 
266
- export { type ApiResponse, type AuthToken, type AuthorizeInput, type AuthorizeResponse, Authorizer, type ConfigType, type ForgotPasswordInput, type ForgotPasswordResponse, type GenericResponse, type GetTokenInput, type GetTokenResponse, type GrapQlResponseType, type GraphqlQueryInput, type Headers, type IsValidJWTQueryInput, type LoginInput, type MagicLinkLoginInput, type MetaData, OAuthProviders, type ResendOtpInput, type ResendVerifyEmailInput, type ResetPasswordInput, ResponseTypes, type RevokeTokenInput, type SessionQueryInput, type SignupInput, type UpdateProfileInput, type User, type ValidJWTResponse, type ValidateJWTTokenInput, type ValidateJWTTokenResponse, type ValidateSessionInput, type ValidateSessionResponse, type VerifyEmailInput, type VerifyOtpInput };
340
+ export { type ApiResponse, type AuthResponse, type AuthToken, type AuthorizeInput, type AuthorizeRequest, type AuthorizeResponse, Authorizer, type AuthorizerError, type ConfigType, type DeleteUserRequest, type ForgotPasswordRequest, type ForgotPasswordResponse, type GenericResponse, type GetTokenInput, type GetTokenRequest, type GetTokenResponse, type GrapQlResponseType, type GraphqlQueryRequest, type Headers, type InviteMembersResponse, type IsValidJWTQueryInput, type LoginRequest, type MagicLinkLoginRequest, type Meta, type MetaData, type MetaDataResponse, OAuthProviders, type Pagination, type ResendOTPRequest, type ResendOtpRequest, type ResendVerifyEmailRequest, type ResetPasswordInput, type ResetPasswordRequest, type Response, ResponseTypes, type RevokeTokenInput, type SessionQueryInput, type SessionQueryRequest, type SignUpRequest, type SignupRequest, type UpdateProfileRequest, type UpdateUserRequest, type User, type Users, type ValidJWTResponse, type ValidateJWTTokenInput, type ValidateJWTTokenRequest, type ValidateJWTTokenResponse, type ValidateSessionInput, type ValidateSessionRequest, type ValidateSessionResponse, type VerificationRequest, type VerificationRequests, type VerifyEmailRequest, type VerifyOTPRequest, type VerifyOtpRequest };