@authorizerdev/authorizer-js 2.0.3 → 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,107 +9,16 @@ 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 User {
16
- id: string;
17
- email: string;
18
- preferred_username: string;
19
- email_verified: boolean;
20
- signup_methods: string;
21
- given_name?: string | null;
22
- family_name?: string | null;
23
- middle_name?: string | null;
24
- nickname?: string | null;
25
- picture?: string | null;
26
- gender?: string | null;
27
- birthdate?: string | null;
28
- 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>;
15
+ interface Pagination {
16
+ limit: number;
17
+ page: number;
18
+ offset: number;
19
+ total: number;
35
20
  }
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;
64
- password: string;
65
- 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 {
82
- email: string;
83
- roles?: string[];
84
- scopes?: string[];
85
- state?: string;
86
- redirect_uri?: string;
87
- }
88
- interface VerifyEmailInput {
89
- token: string;
90
- state?: string;
91
- }
92
- interface ResendVerifyEmailInput {
93
- email: string;
94
- identifier: string;
95
- }
96
- interface VerifyOtpInput {
97
- email?: string;
98
- phone_number?: string;
99
- otp: string;
100
- state?: string;
101
- is_totp?: boolean;
102
- }
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 {
21
+ interface Meta {
113
22
  version: string;
114
23
  client_id: string;
115
24
  is_google_login_enabled: boolean;
@@ -117,6 +26,7 @@ interface MetaData {
117
26
  is_github_login_enabled: boolean;
118
27
  is_linkedin_login_enabled: boolean;
119
28
  is_apple_login_enabled: boolean;
29
+ is_discord_login_enabled: boolean;
120
30
  is_twitter_login_enabled: boolean;
121
31
  is_microsoft_login_enabled: boolean;
122
32
  is_twitch_login_enabled: boolean;
@@ -130,49 +40,209 @@ interface MetaData {
130
40
  is_mobile_basic_authentication_enabled: boolean;
131
41
  is_phone_verification_enabled: boolean;
132
42
  }
133
- interface UpdateProfileInput {
134
- old_password?: string;
135
- new_password?: string;
136
- confirm_new_password?: string;
137
- email?: string;
138
- given_name?: string;
139
- family_name?: string;
140
- middle_name?: string;
141
- nickname?: string;
142
- gender?: string;
143
- birthdate?: string;
144
- phone_number?: string;
145
- picture?: string;
146
- is_multi_factor_auth_enabled?: boolean;
147
- app_data?: Record<string, any>;
148
- }
149
- interface ForgotPasswordInput {
150
- email?: string;
151
- phone_number?: string;
152
- state?: string;
153
- redirect_uri?: string;
43
+ interface User {
44
+ id: string;
45
+ email: string | null;
46
+ email_verified: boolean;
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;
154
105
  }
106
+ type GenericResponse = Response;
155
107
  interface ForgotPasswordResponse {
156
108
  message: string;
157
- should_show_mobile_otp_screen?: boolean;
109
+ should_show_mobile_otp_screen: boolean | null;
110
+ }
111
+ interface InviteMembersResponse {
112
+ message: string;
113
+ Users: User[];
158
114
  }
159
- interface ResetPasswordInput {
160
- token?: string;
161
- otp?: string;
162
- phone_number?: string;
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;
125
+ given_name?: string | null;
126
+ family_name?: string | null;
127
+ middle_name?: string | null;
128
+ nickname?: string | null;
129
+ gender?: string | null;
130
+ birthdate?: string | null;
131
+ phone_number?: string | null;
132
+ picture?: string | null;
163
133
  password: string;
164
134
  confirm_password: string;
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 {
144
+ email: string;
145
+ roles?: string[] | null;
146
+ scope?: string[] | null;
147
+ state?: string | null;
148
+ redirect_uri?: string | null;
165
149
  }
166
- interface SessionQueryInput {
167
- roles?: string[];
150
+ interface VerifyEmailRequest {
151
+ token: string;
152
+ state?: string | null;
168
153
  }
169
- interface IsValidJWTQueryInput {
170
- jwt: string;
171
- roles?: string[];
154
+ interface ResendVerifyEmailRequest {
155
+ email: string;
156
+ identifier: string;
157
+ state?: string | null;
172
158
  }
173
- interface ValidJWTResponse {
174
- valid: string;
175
- message: string;
159
+ interface VerifyOTPRequest {
160
+ email?: string | null;
161
+ phone_number?: string | null;
162
+ otp: string;
163
+ is_totp?: boolean | null;
164
+ state?: string | null;
165
+ }
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;
188
+ }
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;
205
+ }
206
+ interface ForgotPasswordRequest {
207
+ email?: string | null;
208
+ phone_number?: string | null;
209
+ state?: string | null;
210
+ redirect_uri?: string | null;
211
+ }
212
+ interface ResetPasswordRequest {
213
+ token?: string | null;
214
+ otp?: string | null;
215
+ phone_number?: string | null;
216
+ password: string;
217
+ confirm_password: string;
218
+ }
219
+ type ResetPasswordInput = ResetPasswordRequest;
220
+ interface DeleteUserRequest {
221
+ email: string;
222
+ }
223
+ interface SessionQueryRequest {
224
+ roles?: string[] | null;
225
+ scope?: string[] | null;
226
+ }
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;
176
246
  }
177
247
  declare enum OAuthProviders {
178
248
  Apple = "apple",
@@ -183,17 +253,19 @@ declare enum OAuthProviders {
183
253
  Twitter = "twitter",
184
254
  Microsoft = "microsoft",
185
255
  Twitch = "twitch",
186
- Roblox = "roblox"
256
+ Roblox = "roblox",
257
+ Discord = "discord"
187
258
  }
188
259
  declare enum ResponseTypes {
189
260
  Code = "code",
190
261
  Token = "token"
191
262
  }
192
- interface AuthorizeInput {
263
+ interface AuthorizeRequest {
193
264
  response_type: ResponseTypes;
194
265
  use_refresh_token?: boolean;
195
266
  response_mode?: string;
196
267
  }
268
+ type AuthorizeInput = AuthorizeRequest;
197
269
  interface AuthorizeResponse {
198
270
  state: string;
199
271
  code?: string;
@@ -203,66 +275,66 @@ interface AuthorizeResponse {
203
275
  interface RevokeTokenInput {
204
276
  refresh_token: string;
205
277
  }
206
- interface GetTokenInput {
278
+ interface GetTokenRequest {
207
279
  code?: string;
208
280
  grant_type?: string;
209
281
  refresh_token?: string;
210
282
  }
283
+ type GetTokenInput = GetTokenRequest;
211
284
  interface GetTokenResponse {
212
285
  access_token: string;
213
286
  expires_in: number;
214
287
  id_token: string;
215
288
  refresh_token?: string;
216
289
  }
217
- interface ValidateJWTTokenInput {
218
- token_type: 'access_token' | 'id_token' | 'refresh_token';
219
- token: string;
220
- roles?: string[];
221
- }
222
- interface ValidateJWTTokenResponse {
223
- is_valid: boolean;
224
- claims: Record<string, any>;
290
+ type Headers = Record<string, string>;
291
+ interface GraphqlQueryRequest {
292
+ query: string;
293
+ variables?: Record<string, any>;
294
+ headers?: Headers;
225
295
  }
226
- interface ValidateSessionInput {
227
- cookie?: string;
296
+ interface IsValidJWTQueryInput {
297
+ jwt: string;
228
298
  roles?: string[];
229
299
  }
230
- interface ValidateSessionResponse {
231
- is_valid: boolean;
232
- user: User;
300
+ interface ValidJWTResponse {
301
+ valid: string;
302
+ message: string;
233
303
  }
304
+ type MetaDataResponse = Meta;
305
+ type MetaData = Meta;
234
306
 
235
307
  declare class Authorizer {
236
308
  config: ConfigType;
237
309
  codeVerifier: string;
238
310
  constructor(config: ConfigType);
239
- authorize: (data: AuthorizeInput) => Promise<ApiResponse<GetTokenResponse> | ApiResponse<AuthorizeResponse>>;
311
+ authorize: (data: AuthorizeRequest) => Promise<ApiResponse<GetTokenResponse> | ApiResponse<AuthorizeResponse>>;
240
312
  browserLogin: () => Promise<ApiResponse<AuthToken>>;
241
- forgotPassword: (data: ForgotPasswordInput) => Promise<ApiResponse<ForgotPasswordResponse>>;
313
+ forgotPassword: (data: ForgotPasswordRequest) => Promise<ApiResponse<ForgotPasswordResponse>>;
242
314
  getMetaData: () => Promise<ApiResponse<MetaData>>;
243
315
  getProfile: (headers?: Headers) => Promise<ApiResponse<User>>;
244
- getSession: (headers?: Headers, params?: SessionQueryInput) => Promise<ApiResponse<AuthToken>>;
245
- getToken: (data: GetTokenInput) => Promise<ApiResponse<GetTokenResponse>>;
246
- 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>>;
247
319
  logout: (headers?: Headers) => Promise<ApiResponse<GenericResponse>>;
248
- magicLinkLogin: (data: MagicLinkLoginInput) => Promise<ApiResponse<GenericResponse>>;
320
+ magicLinkLogin: (data: MagicLinkLoginRequest) => Promise<ApiResponse<GenericResponse>>;
249
321
  oauthLogin: (oauthProvider: string, roles?: string[], redirect_uri?: string, state?: string) => Promise<void>;
250
- resendOtp: (data: ResendOtpInput) => Promise<ApiResponse<GenericResponse>>;
251
- resetPassword: (data: ResetPasswordInput) => Promise<ApiResponse<GenericResponse>>;
322
+ resendOtp: (data: ResendOtpRequest) => Promise<ApiResponse<GenericResponse>>;
323
+ resetPassword: (data: ResetPasswordRequest) => Promise<ApiResponse<GenericResponse>>;
252
324
  revokeToken: (data: {
253
325
  refresh_token: string;
254
326
  }) => Promise<ApiResponse<any>>;
255
- signup: (data: SignupInput) => Promise<ApiResponse<AuthToken>>;
256
- updateProfile: (data: UpdateProfileInput, headers?: Headers) => Promise<ApiResponse<GenericResponse>>;
327
+ signup: (data: SignUpRequest) => Promise<ApiResponse<AuthToken>>;
328
+ updateProfile: (data: UpdateProfileRequest, headers?: Headers) => Promise<ApiResponse<GenericResponse>>;
257
329
  deactivateAccount: (headers?: Headers) => Promise<ApiResponse<GenericResponse>>;
258
- validateJWTToken: (params?: ValidateJWTTokenInput) => Promise<ApiResponse<ValidateJWTTokenResponse>>;
259
- validateSession: (params?: ValidateSessionInput) => Promise<ApiResponse<ValidateSessionResponse>>;
260
- verifyEmail: (data: VerifyEmailInput) => Promise<ApiResponse<AuthToken>>;
261
- resendVerifyEmail: (data: ResendVerifyEmailInput) => Promise<ApiResponse<GenericResponse>>;
262
- verifyOtp: (data: VerifyOtpInput) => Promise<ApiResponse<AuthToken>>;
263
- 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>;
264
336
  errorResponse: (errors: Error[]) => ApiResponse<any>;
265
337
  okResponse: (data: any) => ApiResponse<any>;
266
338
  }
267
339
 
268
- 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 };