@flashbacktech/flashbackclient 0.0.83 → 0.0.85

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.
@@ -1,6 +1,6 @@
1
1
  import { CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, StorageUnit, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoRequest, UpdateRepoResponse, UpdateRepoKeyRequest, UpdateRepoKeyResponse, ValidateUnitRequest, ValidateUnitResponse, ValidateRepoUnitsRequest, ValidateRepoUnitsResponse, StorageUnitStatusResponse } from './types/storage';
2
2
  import { IApiClient, ProviderType } from './interfaces';
3
- import { OAuth2ResponseDTO, RefreshTokenResponse } from './types/auth';
3
+ import { ActivateResponse, DeactivateResponse, LoginBody, LoginResponse, LogoutResponse, OAuth2ResponseDTO, RefreshTokenResponse, RegisterBody, RegisterResponse } from './types/auth';
4
4
  interface ErrorResponse {
5
5
  message?: string;
6
6
  [key: string]: any;
@@ -52,5 +52,11 @@ export declare class ApiClient implements IApiClient {
52
52
  getRepoKeys: (repoId: string) => Promise<GetRepoKeysResponse>;
53
53
  updateRepoKey: (repoId: string, keyId: string, data: UpdateRepoKeyRequest) => Promise<UpdateRepoKeyResponse>;
54
54
  deleteRepoKey: (repoId: string, keyId: string) => Promise<ActionResponse>;
55
+ userRegister: (data: RegisterBody) => Promise<RegisterResponse>;
56
+ userLogin: (data: LoginBody) => Promise<LoginResponse>;
57
+ userRefresh: (refreshToken: string) => Promise<RefreshTokenResponse>;
58
+ userLogout: (refreshToken: string) => Promise<LogoutResponse>;
59
+ userActivate: () => Promise<ActivateResponse>;
60
+ userDeactivate: () => Promise<DeactivateResponse>;
55
61
  }
56
62
  export {};
@@ -34,6 +34,8 @@ class ApiClient {
34
34
  return this.authenticateGithub(token);
35
35
  case interfaces_1.ProviderType.WEB3_STELLAR:
36
36
  return this.authenticateWeb3Stellar(token);
37
+ case interfaces_1.ProviderType.LOCAL:
38
+ throw new Error('Call userLogin for local authentication');
37
39
  default:
38
40
  throw new Error(`Unsupported provider: ${provider}`);
39
41
  }
@@ -69,6 +71,8 @@ class ApiClient {
69
71
  case interfaces_1.ProviderType.GITHUB:
70
72
  // TODO: Implement refresh token for Github
71
73
  throw new Error('Not implemented');
74
+ case interfaces_1.ProviderType.LOCAL:
75
+ return this.userRefresh(refreshToken);
72
76
  default:
73
77
  throw new Error(`Unsupported provider: ${provider}`);
74
78
  }
@@ -192,6 +196,25 @@ class ApiClient {
192
196
  this.deleteRepoKey = async (repoId, keyId) => {
193
197
  return this.makeRequest(`repo/${repoId}/apikey/${keyId}`, 'DELETE', null);
194
198
  };
199
+ ////// User API
200
+ this.userRegister = async (data) => {
201
+ return this.makeRequest('user/register', 'POST', data);
202
+ };
203
+ this.userLogin = async (data) => {
204
+ return this.makeRequest('user/login', 'POST', data);
205
+ };
206
+ this.userRefresh = async (refreshToken) => {
207
+ return this.makeRequest('user/refresh', 'POST', { refresh_token: refreshToken });
208
+ };
209
+ this.userLogout = async (refreshToken) => {
210
+ return this.makeRequest('user/logout', 'POST', { refresh_token: refreshToken });
211
+ };
212
+ this.userActivate = async () => {
213
+ return this.makeRequest('user/activate', 'POST', null);
214
+ };
215
+ this.userDeactivate = async () => {
216
+ return this.makeRequest('user/deactivate', 'POST', null);
217
+ };
195
218
  this.baseURL = baseURL;
196
219
  this.headers = {};
197
220
  this.debug = false;
@@ -1,8 +1,10 @@
1
1
  import { StorageUnit, CreateUnitRequest, CreateUnitResponse, CreateRepoRequest, CreateRepoResponse, CreateRepoKeyRequest, CreateRepoKeyResponse, GetUnitsResponse, GetReposResponse, GetRepoKeysResponse, UpdateUnitRequest, UpdateUnitResponse, ActionResponse, UpdateRepoResponse, UpdateRepoRequest, UpdateRepoKeyRequest, UpdateRepoKeyResponse, ValidateUnitRequest, ValidateUnitResponse, ValidateRepoUnitsRequest, ValidateRepoUnitsResponse } from "./types/storage";
2
+ import { RegisterBody, LoginBody, RegisterResponse, LoginResponse, LogoutResponse, ActivateResponse, DeactivateResponse, RefreshTokenResponse } from "./types/auth";
2
3
  export declare enum ProviderType {
3
4
  GOOGLE = "GOOGLE",
4
5
  GITHUB = "GITHUB",
5
- WEB3_STELLAR = "WEB3_STELLAR"
6
+ WEB3_STELLAR = "WEB3_STELLAR",
7
+ LOCAL = "LOCAL"
6
8
  }
7
9
  export interface IApiClient {
8
10
  authenticate(token: string, provider: ProviderType): Promise<any>;
@@ -22,4 +24,10 @@ export interface IApiClient {
22
24
  deleteRepoKey(repoId: string, keyId: string): Promise<ActionResponse>;
23
25
  validateNewRepoUnits(data: ValidateRepoUnitsRequest): Promise<ValidateRepoUnitsResponse>;
24
26
  validateUpdateRepoUnits(data: ValidateRepoUnitsRequest): Promise<ValidateRepoUnitsResponse>;
27
+ userRegister(registerBody: RegisterBody): Promise<RegisterResponse>;
28
+ userLogin(loginBody: LoginBody): Promise<LoginResponse>;
29
+ userRefresh(refreshToken: string): Promise<RefreshTokenResponse>;
30
+ userLogout(refreshToken: string): Promise<LogoutResponse>;
31
+ userActivate(): Promise<ActivateResponse>;
32
+ userDeactivate(): Promise<DeactivateResponse>;
25
33
  }
@@ -6,4 +6,5 @@ var ProviderType;
6
6
  ProviderType["GOOGLE"] = "GOOGLE";
7
7
  ProviderType["GITHUB"] = "GITHUB";
8
8
  ProviderType["WEB3_STELLAR"] = "WEB3_STELLAR";
9
+ ProviderType["LOCAL"] = "LOCAL";
9
10
  })(ProviderType || (exports.ProviderType = ProviderType = {}));
@@ -22,3 +22,55 @@ export interface RefreshTokenResponse {
22
22
  refreshToken: string;
23
23
  expiresAt: number;
24
24
  }
25
+ export interface JwtPayload {
26
+ userId: string;
27
+ email: string;
28
+ orgId?: string;
29
+ type?: string;
30
+ iat?: number;
31
+ exp?: number;
32
+ }
33
+ export interface RegisterBody {
34
+ email: string;
35
+ password: string;
36
+ companyName: string;
37
+ companyDomain: string;
38
+ companyWebsite: string;
39
+ }
40
+ export interface LoginBody {
41
+ email: string;
42
+ password: string;
43
+ }
44
+ export interface LogoutBody {
45
+ refreshToken: string;
46
+ }
47
+ export interface RegisterResponse {
48
+ success: boolean;
49
+ accessToken?: string;
50
+ refreshToken?: string;
51
+ user?: {
52
+ id: string;
53
+ email: string;
54
+ name: string;
55
+ orgId?: string;
56
+ };
57
+ error_code?: string;
58
+ message?: string;
59
+ }
60
+ export interface LoginResponse extends RegisterResponse {
61
+ }
62
+ export interface LogoutResponse {
63
+ success: boolean;
64
+ error_code?: string;
65
+ message?: string;
66
+ }
67
+ export interface ActivateResponse {
68
+ success: boolean;
69
+ error_code?: string;
70
+ message?: string;
71
+ }
72
+ export interface DeactivateResponse {
73
+ success: boolean;
74
+ error_code?: string;
75
+ message?: string;
76
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flashbacktech/flashbackclient",
3
- "version": "0.0.83",
3
+ "version": "0.0.85",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },