@allanfsouza/aether-sdk 2.5.1 → 2.5.2

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/src/index.ts CHANGED
@@ -1,12 +1,25 @@
1
1
  // src/index.ts
2
+ // =============================================================================
3
+ // AETHER SDK - Cliente Principal
4
+ // =============================================================================
5
+ // SEGURANÇA: AuthModule foi REMOVIDO do SDK público.
6
+ // O módulo auth é exclusivo para o painel administrativo do Aether (web-admin).
7
+ // Apps client-side devem usar APENAS tenantAuth para autenticar seus usuários.
8
+ // =============================================================================
9
+
2
10
  import type { AxiosInstance } from "axios";
3
11
  import { createHttpClient } from "./http-client.js";
4
- import { AuthModule, User } from "./auth.js";
5
12
  import { DatabaseModule } from "./database.js";
6
13
  import { StorageModule } from "./storage.js";
7
14
  import { FunctionsModule } from "./functions.js";
8
15
  import { PushModule } from "./push.js";
9
- import { TenantAuthModule, TenantUser, TenantLoginResponse, TenantRegisterCredentials, TenantLoginCredentials } from "./tenant-auth.js";
16
+ import {
17
+ TenantAuthModule,
18
+ TenantUser,
19
+ TenantLoginResponse,
20
+ TenantRegisterCredentials,
21
+ TenantLoginCredentials,
22
+ } from "./tenant-auth.js";
10
23
  import { AIModule } from "./ai.js";
11
24
 
12
25
  // =============================================================================
@@ -54,7 +67,15 @@ function isBrowser(): boolean {
54
67
  }
55
68
 
56
69
  export class PlataformaClient {
57
- public auth: AuthModule;
70
+ // =========================================================================
71
+ // MÓDULOS PÚBLICOS
72
+ // =========================================================================
73
+ // NOTA DE SEGURANÇA: AuthModule foi REMOVIDO intencionalmente.
74
+ // Ele gerencia a tabela GLOBAL 'users' (donos de projetos Aether).
75
+ // Apps client-side NÃO devem ter acesso a essa funcionalidade.
76
+ // Use tenantAuth para autenticar usuários dos seus apps.
77
+ // =========================================================================
78
+
58
79
  public db: DatabaseModule;
59
80
  public storage: StorageModule;
60
81
  public functions: FunctionsModule;
@@ -96,8 +117,12 @@ export class PlataformaClient {
96
117
 
97
118
  this.http = createHttpClient(this);
98
119
 
99
- // Inicializa módulos
100
- this.auth = new AuthModule(this, this.http);
120
+ // =========================================================================
121
+ // INICIALIZAÇÃO DOS MÓDULOS
122
+ // =========================================================================
123
+ // SEGURANÇA: AuthModule NÃO é inicializado aqui.
124
+ // Apenas módulos seguros para client-side são expostos.
125
+ // =========================================================================
101
126
  this.db = new DatabaseModule(this, this.http);
102
127
  this.storage = new StorageModule(this, this.http);
103
128
  this.functions = new FunctionsModule(this, this.http);
@@ -142,7 +167,7 @@ export class PlataformaClient {
142
167
 
143
168
  /**
144
169
  * Salva o refresh token.
145
- * Usado internamente pelo AuthModule após login.
170
+ * Usado internamente pelo TenantAuthModule após login.
146
171
  */
147
172
  setRefreshToken(token: string | null): void {
148
173
  if (this._persistSession && isBrowser()) {
@@ -158,20 +183,21 @@ export class PlataformaClient {
158
183
  * Retorna o refresh token salvo no localStorage.
159
184
  */
160
185
  getRefreshToken(): string | null {
161
- if (this._persistSession && isBrowser()) {
186
+ if (isBrowser()) {
162
187
  return localStorage.getItem(STORAGE_KEYS.REFRESH_TOKEN);
163
188
  }
164
189
  return null;
165
190
  }
166
191
 
167
192
  // ===========================================================================
168
- // DADOS DO USUÁRIO
193
+ // USER DATA (TENANT USER)
169
194
  // ===========================================================================
170
195
 
171
196
  /**
172
- * Salva dados do usuário logado no localStorage.
197
+ * Salva dados do usuário tenant no localStorage.
198
+ * Usado internamente pelo TenantAuthModule após login.
173
199
  */
174
- setUser(user: User | null): void {
200
+ setUser(user: TenantUser | null): void {
175
201
  if (this._persistSession && isBrowser()) {
176
202
  if (user) {
177
203
  localStorage.setItem(STORAGE_KEYS.USER, JSON.stringify(user));
@@ -182,19 +208,18 @@ export class PlataformaClient {
182
208
  }
183
209
 
184
210
  /**
185
- * Retorna dados do usuário salvo no localStorage.
211
+ * Retorna dados do usuário tenant salvos no localStorage.
186
212
  */
187
- getUser(): User | null {
188
- if (this._persistSession && isBrowser()) {
189
- const saved = localStorage.getItem(STORAGE_KEYS.USER);
190
- if (saved) {
191
- try {
192
- return JSON.parse(saved) as User;
193
- } catch {
194
- // JSON corrompido - limpa
195
- localStorage.removeItem(STORAGE_KEYS.USER);
196
- return null;
213
+ getUser(): TenantUser | null {
214
+ if (isBrowser()) {
215
+ try {
216
+ const raw = localStorage.getItem(STORAGE_KEYS.USER);
217
+ if (raw) {
218
+ return JSON.parse(raw) as TenantUser;
197
219
  }
220
+ } catch {
221
+ // JSON inválido - limpa o dado corrompido
222
+ localStorage.removeItem(STORAGE_KEYS.USER);
198
223
  }
199
224
  }
200
225
  return null;
@@ -241,9 +266,14 @@ export class PlataformaClient {
241
266
  }
242
267
  }
243
268
 
244
- // ===== EXPORTS =====
269
+ // =============================================================================
270
+ // EXPORTS PÚBLICOS
271
+ // =============================================================================
272
+ // NOTA: Tipos do auth.ts (User, LoginResponse, Session) foram REMOVIDOS
273
+ // pois pertencem ao módulo administrativo, não ao SDK público.
274
+ // =============================================================================
275
+
245
276
  export { AetherError } from "./errors.js";
246
- export type { LoginResponse, Session, User } from "./auth.js";
247
277
  export type { ListOptions } from "./database.js";
248
278
  export type {
249
279
  PushPlatform,
package/tsconfig.json CHANGED
@@ -1,21 +1,29 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2020",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "node",
6
+ "lib": [
7
+ "ES2020",
8
+ "DOM"
9
+ ],
6
10
  "declaration": true,
11
+ "declarationMap": true,
12
+ "sourceMap": true,
7
13
  "outDir": "./dist",
8
14
  "rootDir": "./src",
9
15
  "strict": true,
16
+ "esModuleInterop": true,
10
17
  "skipLibCheck": true,
11
18
  "forceConsistentCasingInFileNames": true,
12
- // Adicionado DOM para reconhecer 'File', 'Blob' e 'WebSocket' nativos
13
- "lib": [
14
- "ES2020",
15
- "DOM"
16
- ]
19
+ "resolveJsonModule": true,
20
+ "allowSyntheticDefaultImports": true
17
21
  },
18
22
  "include": [
19
- "src"
23
+ "src/**/*.ts"
24
+ ],
25
+ "exclude": [
26
+ "node_modules",
27
+ "dist"
20
28
  ]
21
29
  }