@anzar-auth/client 1.3.6

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.
@@ -0,0 +1,465 @@
1
+ import * as axios from 'axios';
2
+ import { AxiosInstance, RawAxiosRequestConfig } from 'axios';
3
+ import { S as SessionTokens, B as BaseStorage } from './base_storage-BnHsA4fU.cjs';
4
+ import { U as User, V as Verification, A as AuthResult } from './index-BZFSacf5.cjs';
5
+
6
+ /**
7
+ * Anzar Software API
8
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
9
+ *
10
+ * The version of the OpenAPI document: 0.6.2
11
+ * Contact: dev@anzar.io
12
+ *
13
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
14
+ * https://openapi-generator.tech
15
+ * Do not edit the class manually.
16
+ */
17
+ interface AWSv4Configuration {
18
+ options?: {
19
+ region?: string;
20
+ service?: string;
21
+ };
22
+ credentials?: {
23
+ accessKeyId?: string;
24
+ secretAccessKey?: string;
25
+ sessionToken?: string;
26
+ };
27
+ }
28
+ interface ConfigurationParameters {
29
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
30
+ username?: string;
31
+ password?: string;
32
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
33
+ awsv4?: AWSv4Configuration;
34
+ basePath?: string;
35
+ serverIndex?: number;
36
+ baseOptions?: any;
37
+ formDataCtor?: new () => any;
38
+ }
39
+ declare class Configuration {
40
+ /**
41
+ * parameter for apiKey security
42
+ * @param name security name
43
+ */
44
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
45
+ /**
46
+ * parameter for basic security
47
+ */
48
+ username?: string;
49
+ /**
50
+ * parameter for basic security
51
+ */
52
+ password?: string;
53
+ /**
54
+ * parameter for oauth2 security
55
+ * @param name security name
56
+ * @param scopes oauth2 scope
57
+ */
58
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
59
+ /**
60
+ * parameter for aws4 signature security
61
+ * @param {Object} AWS4Signature - AWS4 Signature security
62
+ * @param {string} options.region - aws region
63
+ * @param {string} options.service - name of the service.
64
+ * @param {string} credentials.accessKeyId - aws access key id
65
+ * @param {string} credentials.secretAccessKey - aws access key
66
+ * @param {string} credentials.sessionToken - aws session token
67
+ * @memberof Configuration
68
+ */
69
+ awsv4?: AWSv4Configuration;
70
+ /**
71
+ * override base path
72
+ */
73
+ basePath?: string;
74
+ /**
75
+ * override server index
76
+ */
77
+ serverIndex?: number;
78
+ /**
79
+ * base options for axios calls
80
+ */
81
+ baseOptions?: any;
82
+ /**
83
+ * The FormData constructor that will be used to create multipart form data
84
+ * requests. You can inject this here so that execution environments that
85
+ * do not support the FormData class can still run the generated client.
86
+ *
87
+ * @type {new () => FormData}
88
+ */
89
+ formDataCtor?: new () => any;
90
+ constructor(param?: ConfigurationParameters);
91
+ /**
92
+ * Check if the given MIME is a JSON MIME.
93
+ * JSON MIME examples:
94
+ * application/json
95
+ * application/json; charset=UTF8
96
+ * APPLICATION/JSON
97
+ * application/vnd.company+json
98
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
99
+ * @return True if the given MIME is JSON, false otherwise.
100
+ */
101
+ isJsonMime(mime: string): boolean;
102
+ }
103
+
104
+ /**
105
+ * Anzar Software API
106
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
107
+ *
108
+ * The version of the OpenAPI document: 0.6.2
109
+ * Contact: dev@anzar.io
110
+ *
111
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
112
+ * https://openapi-generator.tech
113
+ * Do not edit the class manually.
114
+ */
115
+
116
+ declare class BaseAPI {
117
+ protected basePath: string;
118
+ protected axios: AxiosInstance;
119
+ protected configuration: Configuration | undefined;
120
+ constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
121
+ }
122
+
123
+ /**
124
+ * Anzar Software API
125
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
126
+ *
127
+ * The version of the OpenAPI document: 0.6.2
128
+ * Contact: dev@anzar.io
129
+ *
130
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
131
+ * https://openapi-generator.tech
132
+ * Do not edit the class manually.
133
+ */
134
+
135
+ interface AuthResponse {
136
+ 'tokens'?: SessionTokens | null;
137
+ 'user': User;
138
+ 'verification'?: Verification | null;
139
+ }
140
+
141
+ /**
142
+ * Anzar Software API
143
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
144
+ *
145
+ * The version of the OpenAPI document: 0.6.2
146
+ * Contact: dev@anzar.io
147
+ *
148
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
149
+ * https://openapi-generator.tech
150
+ * Do not edit the class manually.
151
+ */
152
+ interface EmailRequest {
153
+ 'email': string;
154
+ }
155
+
156
+ /**
157
+ * Anzar Software API
158
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
159
+ *
160
+ * The version of the OpenAPI document: 0.6.2
161
+ * Contact: dev@anzar.io
162
+ *
163
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
164
+ * https://openapi-generator.tech
165
+ * Do not edit the class manually.
166
+ */
167
+ interface LoginRequest {
168
+ 'email': string;
169
+ 'password': string;
170
+ }
171
+
172
+ /**
173
+ * Anzar Software API
174
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
175
+ *
176
+ * The version of the OpenAPI document: 0.6.2
177
+ * Contact: dev@anzar.io
178
+ *
179
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
180
+ * https://openapi-generator.tech
181
+ * Do not edit the class manually.
182
+ */
183
+ interface RefreshTokenRequest {
184
+ 'refresh_token': string;
185
+ }
186
+
187
+ /**
188
+ * Anzar Software API
189
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
190
+ *
191
+ * The version of the OpenAPI document: 0.6.2
192
+ * Contact: dev@anzar.io
193
+ *
194
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
195
+ * https://openapi-generator.tech
196
+ * Do not edit the class manually.
197
+ */
198
+ interface RegisterRequest {
199
+ 'email': string;
200
+ 'password': string;
201
+ 'username': string;
202
+ }
203
+
204
+ /**
205
+ * Anzar Software API
206
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
207
+ *
208
+ * The version of the OpenAPI document: 0.6.2
209
+ * Contact: dev@anzar.io
210
+ *
211
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
212
+ * https://openapi-generator.tech
213
+ * Do not edit the class manually.
214
+ */
215
+ interface ResetLink {
216
+ 'expires_at': string;
217
+ 'link': string;
218
+ }
219
+
220
+ /**
221
+ * Anzar Software API
222
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
223
+ *
224
+ * The version of the OpenAPI document: 0.6.2
225
+ * Contact: dev@anzar.io
226
+ *
227
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
228
+ * https://openapi-generator.tech
229
+ * Do not edit the class manually.
230
+ */
231
+ interface ResetPasswordRequest {
232
+ 'csrf_token': string;
233
+ 'password': string;
234
+ 'token': string;
235
+ }
236
+
237
+ /**
238
+ * Anzar Software API
239
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
240
+ *
241
+ * The version of the OpenAPI document: 0.6.2
242
+ * Contact: dev@anzar.io
243
+ *
244
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
245
+ * https://openapi-generator.tech
246
+ * Do not edit the class manually.
247
+ */
248
+ interface Session {
249
+ '_id'?: string | null;
250
+ 'expiresAt': string;
251
+ 'issuedAt': string;
252
+ 'token': string;
253
+ 'usedAt'?: string | null;
254
+ 'userId'?: string;
255
+ }
256
+
257
+ /**
258
+ * Anzar Software API
259
+ * REST API for the Anzar platform. All protected routes require a Bearer token.
260
+ *
261
+ * The version of the OpenAPI document: 0.6.2
262
+ * Contact: dev@anzar.io
263
+ *
264
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
265
+ * https://openapi-generator.tech
266
+ * Do not edit the class manually.
267
+ */
268
+ interface TokenQuery {
269
+ 'token': string;
270
+ }
271
+
272
+ /**
273
+ * AuthApi - object-oriented interface
274
+ */
275
+ declare class AuthApi extends BaseAPI {
276
+ /**
277
+ * Returns the currently authenticated user\'s session data. Requires a valid Bearer token.
278
+ * @summary Get current session
279
+ * @param {*} [options] Override http request option.
280
+ * @throws {RequiredError}
281
+ */
282
+ getSession(options?: RawAxiosRequestConfig): Promise<axios.AxiosResponse<Session, any, {}>>;
283
+ /**
284
+ * Authenticates a user with email and password. Returns an access token and refresh token on success.
285
+ * @summary User login
286
+ * @param {LoginRequest} loginRequest User login credentials
287
+ * @param {*} [options] Override http request option.
288
+ * @throws {RequiredError}
289
+ */
290
+ login(loginRequest: LoginRequest, options?: RawAxiosRequestConfig): Promise<axios.AxiosResponse<AuthResponse, any, {}>>;
291
+ /**
292
+ * Invalidates the current session and refresh token. The client should discard stored tokens.
293
+ * @summary Logout
294
+ * @param {RefreshTokenRequest} refreshTokenRequest
295
+ * @param {*} [options] Override http request option.
296
+ * @throws {RequiredError}
297
+ */
298
+ logout(refreshTokenRequest: RefreshTokenRequest, options?: RawAxiosRequestConfig): Promise<axios.AxiosResponse<void, any, {}>>;
299
+ /**
300
+ * Issues a new access token using a valid refresh token. Rotate refresh tokens on each call.
301
+ * @summary Refresh access token
302
+ * @param {RefreshTokenRequest} refreshTokenRequest
303
+ * @param {*} [options] Override http request option.
304
+ * @throws {RequiredError}
305
+ */
306
+ refreshToken(refreshTokenRequest: RefreshTokenRequest, options?: RawAxiosRequestConfig): Promise<axios.AxiosResponse<AuthResponse, any, {}>>;
307
+ /**
308
+ * Creates a new user account. Sends a verification email upon successful registration.
309
+ * @summary Register a new user
310
+ * @param {RegisterRequest} registerRequest User register credentials
311
+ * @param {*} [options] Override http request option.
312
+ * @throws {RequiredError}
313
+ */
314
+ register(registerRequest: RegisterRequest, options?: RawAxiosRequestConfig): Promise<axios.AxiosResponse<AuthResponse, any, {}>>;
315
+ /**
316
+ * Validates the reset token from the email link and renders the password reset form.
317
+ * @summary Render password reset form
318
+ * @param {TokenQuery} token Password reset token
319
+ * @param {*} [options] Override http request option.
320
+ * @throws {RequiredError}
321
+ */
322
+ renderResetForm(token: TokenQuery, options?: RawAxiosRequestConfig): Promise<axios.AxiosResponse<string, any, {}>>;
323
+ /**
324
+ * Sends a password reset link to the provided email address if an account exists.
325
+ * @summary Request a password reset
326
+ * @param {EmailRequest} emailRequest Email address to send the reset link to
327
+ * @param {*} [options] Override http request option.
328
+ * @throws {RequiredError}
329
+ */
330
+ requestPasswordReset(emailRequest: EmailRequest, options?: RawAxiosRequestConfig): Promise<axios.AxiosResponse<ResetLink, any, {}>>;
331
+ /**
332
+ * Submits a new password using a valid reset token. Invalidates the token after use.
333
+ * @summary Submit new password
334
+ * @param {ResetPasswordRequest} resetPasswordRequest Reset token and the new password
335
+ * @param {*} [options] Override http request option.
336
+ * @throws {RequiredError}
337
+ */
338
+ submitNewPassword(resetPasswordRequest: ResetPasswordRequest, options?: RawAxiosRequestConfig): Promise<axios.AxiosResponse<void, any, {}>>;
339
+ }
340
+
341
+ /**
342
+ * EmailApi - object-oriented interface
343
+ */
344
+ declare class EmailApi extends BaseAPI {
345
+ /**
346
+ * Validates the email token and update the user account.
347
+ * @summary Verify user email
348
+ * @param {TokenQuery} token Email Verification Token
349
+ * @param {*} [options] Override http request option.
350
+ * @throws {RequiredError}
351
+ */
352
+ verifyEmail(token: TokenQuery, options?: RawAxiosRequestConfig): Promise<axios.AxiosResponse<void, any, {}>>;
353
+ }
354
+
355
+ /**
356
+ * UsersApi - object-oriented interface
357
+ */
358
+ declare class UsersApi extends BaseAPI {
359
+ /**
360
+ * Returns the currently authenticated user\'s data. Requires a valid Bearer token.
361
+ * @summary Get current User
362
+ * @param {*} [options] Override http request option.
363
+ * @throws {RequiredError}
364
+ */
365
+ findUser(options?: RawAxiosRequestConfig): Promise<axios.AxiosResponse<User, any, {}>>;
366
+ }
367
+
368
+ declare enum DatabaseDriver {
369
+ SQLite = "SQLite",
370
+ PostgreSQL = "PostgreSQL",
371
+ MongoDB = "MongoDB"
372
+ }
373
+ type Database = {
374
+ driver: DatabaseDriver;
375
+ connection_string: string;
376
+ };
377
+ type HttpsConfig = {
378
+ enabled: boolean;
379
+ port: number;
380
+ cert_path: string | null;
381
+ key_path: string | null;
382
+ };
383
+ type CorsConfig = {
384
+ allowed_origins: string[];
385
+ };
386
+ type Server = {
387
+ https: HttpsConfig | null;
388
+ cors: CorsConfig | null;
389
+ };
390
+ declare enum AuthStrategy {
391
+ Jwt = "Jwt",
392
+ Session = "Session"
393
+ }
394
+ type JWT = {
395
+ expires_in: number | null;
396
+ refresh_expires_in: number | null;
397
+ };
398
+ type EmailVerification = {
399
+ required: boolean | null;
400
+ token_expires_in: number | null;
401
+ };
402
+ type EmailConfig = {
403
+ verification: EmailVerification | null;
404
+ };
405
+ type PasswordRequirements = {
406
+ min_length: number | null;
407
+ max_length: number | null;
408
+ };
409
+ type PasswordReset = {
410
+ token_expires_in: number | null;
411
+ };
412
+ type PasswordSecurity = {
413
+ max_failed_login_attempts: number | null;
414
+ lockout_duration: number | null;
415
+ };
416
+ type PasswordConfig = {
417
+ requirements: PasswordRequirements | null;
418
+ reset: PasswordReset | null;
419
+ security: PasswordSecurity | null;
420
+ };
421
+ type Authentication = {
422
+ strategy: AuthStrategy | null;
423
+ jwt: JWT | null;
424
+ email: EmailConfig | null;
425
+ password: PasswordConfig | null;
426
+ };
427
+ type Security = {
428
+ secret_key: string;
429
+ };
430
+ type AnzarConfig = {
431
+ api_url: string;
432
+ database: Database;
433
+ security: Security;
434
+ server: Server | null;
435
+ auth: Authentication | null;
436
+ };
437
+
438
+ interface SdkOptions {
439
+ storage: BaseStorage;
440
+ }
441
+
442
+ declare class AuthModule {
443
+ private readonly authApi;
444
+ private readonly userApi;
445
+ private readonly strategy;
446
+ private readonly options?;
447
+ constructor(authApi: AuthApi, userApi: UsersApi, strategy: AuthStrategy, options?: SdkOptions | undefined);
448
+ login(body: LoginRequest): Promise<AuthResult>;
449
+ register(body: RegisterRequest): Promise<AuthResult>;
450
+ logout(): Promise<void>;
451
+ resetPassword(body: EmailRequest): void;
452
+ isAuthenticated(): Promise<boolean>;
453
+ session(): Promise<Session>;
454
+ }
455
+
456
+ declare class Anzar {
457
+ Auth: AuthModule;
458
+ User: UsersApi;
459
+ Email: EmailApi;
460
+ constructor(anzarConfig: AnzarConfig, options?: SdkOptions);
461
+ private createAxiosInstance;
462
+ private createApis;
463
+ }
464
+
465
+ export { Anzar };