@zuzjs/flare-admin 0.1.3 → 0.1.5

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.
@@ -12,6 +12,10 @@ export interface FlareAdminConfig {
12
12
  * Keep in an environment variable — NEVER expose to the browser.
13
13
  */
14
14
  adminKey: string;
15
+ /** Optional gRPC endpoint, e.g. "127.0.0.1:5051". */
16
+ grpcUrl?: string;
17
+ /** Transport preference for supported operations. */
18
+ transport?: "auto" | "http" | "grpc";
15
19
  /** Default token TTL, e.g. "24h" */
16
20
  defaultTtl?: string;
17
21
  /**
@@ -89,6 +93,322 @@ export interface FlareAdminNotifications {
89
93
  tokens: AdminPushToken[];
90
94
  }>;
91
95
  }
96
+ export interface AdminStorageServer {
97
+ id: string;
98
+ name: string;
99
+ kind: string;
100
+ endpoint: string;
101
+ bucket: string;
102
+ region: string;
103
+ prefix?: string;
104
+ dataDir?: string;
105
+ forcePathStyle?: boolean;
106
+ frozen?: boolean;
107
+ readOnly?: boolean;
108
+ createdAt?: unknown;
109
+ updatedAt?: unknown;
110
+ }
111
+ export interface AdminStorageServerInput {
112
+ name: string;
113
+ kind?: string;
114
+ endpoint?: string;
115
+ bucket: string;
116
+ region?: string;
117
+ accessKey?: string;
118
+ secretKey?: string;
119
+ prefix?: string;
120
+ dataDir?: string;
121
+ forcePathStyle?: boolean;
122
+ frozen?: boolean;
123
+ readOnly?: boolean;
124
+ }
125
+ export interface AdminStorageServerPatchInput {
126
+ name?: string;
127
+ endpoint?: string;
128
+ bucket?: string;
129
+ region?: string;
130
+ accessKey?: string;
131
+ secretKey?: string;
132
+ prefix?: string;
133
+ dataDir?: string;
134
+ forcePathStyle?: boolean;
135
+ frozen?: boolean;
136
+ readOnly?: boolean;
137
+ }
138
+ export interface AdminStorageUploadInput {
139
+ serverId: string;
140
+ path: string;
141
+ contentBase64: string;
142
+ contentType?: string;
143
+ encrypt?: boolean;
144
+ }
145
+ export interface AdminStorageDownloadInput {
146
+ serverId: string;
147
+ path: string;
148
+ decrypt?: boolean;
149
+ }
150
+ export interface AdminStorageDeleteInput {
151
+ serverId: string;
152
+ path: string;
153
+ }
154
+ export interface AdminStorageObjectResult {
155
+ ok: boolean;
156
+ path: string;
157
+ key: string;
158
+ encrypted?: boolean;
159
+ size?: number;
160
+ contentBase64?: string;
161
+ contentType?: string;
162
+ }
163
+ export declare enum AdminStorageSignedAction {
164
+ Upload = "upload",
165
+ Download = "download",
166
+ Delete = "delete",
167
+ Edit = "edit"
168
+ }
169
+ export interface AdminStorageSignedUrlInput {
170
+ bucket: string;
171
+ key: string;
172
+ action: AdminStorageSignedAction;
173
+ expiresInSeconds?: number;
174
+ sizeBytes?: number;
175
+ contentType?: string;
176
+ encrypt?: boolean;
177
+ decrypt?: boolean;
178
+ forceDownload?: boolean;
179
+ allowedOrigins?: string[];
180
+ embedOnly?: boolean;
181
+ }
182
+ export interface AdminStorageSignedUrlResult {
183
+ ok: boolean;
184
+ action: AdminStorageSignedAction;
185
+ method: "PUT" | "PATCH" | "GET" | "DELETE";
186
+ token: string;
187
+ urlPath: string;
188
+ url: string;
189
+ expiresInSeconds?: number;
190
+ expiresAt: number;
191
+ forceDownload?: boolean;
192
+ allowedOrigins?: string[];
193
+ embedOnly?: boolean;
194
+ }
195
+ export interface AdminGetObjectUrlInput {
196
+ bucket: string;
197
+ key: string;
198
+ decrypt?: boolean;
199
+ expiresInSeconds?: number;
200
+ forceDownload?: boolean;
201
+ allowedOrigins?: string[];
202
+ embedOnly?: boolean;
203
+ }
204
+ export interface AdminDownloadObjectInput extends AdminGetObjectUrlInput {
205
+ filename?: string;
206
+ openInNewTab?: boolean;
207
+ }
208
+ export interface AdminDownloadObjectResult {
209
+ ok: boolean;
210
+ url: string;
211
+ filename: string;
212
+ triggered: boolean;
213
+ }
214
+ export interface AdminStorageAwsConfig {
215
+ kind: string;
216
+ endpoint: string;
217
+ region: string;
218
+ bucket: string;
219
+ prefix?: string;
220
+ dataDir?: string;
221
+ forcePathStyle?: boolean;
222
+ accessKeyId: string;
223
+ secretAccessKey: string;
224
+ }
225
+ export interface AdminStorageRulesPolicy {
226
+ maxEntries?: number;
227
+ maxAgeDays?: number;
228
+ }
229
+ export interface AdminStorageRulesHistoryResult {
230
+ history: unknown[];
231
+ policy: AdminStorageRulesPolicy;
232
+ restoreEvents: unknown[];
233
+ }
234
+ export interface FlareAdminStorage {
235
+ servers(): Promise<AdminStorageServer[]>;
236
+ createServer(input: AdminStorageServerInput): Promise<{
237
+ ok: boolean;
238
+ serverId: string;
239
+ }>;
240
+ patchServer(serverId: string, input: AdminStorageServerPatchInput): Promise<{
241
+ ok: boolean;
242
+ serverId: string;
243
+ }>;
244
+ deleteServer(serverId: string): Promise<{
245
+ ok: boolean;
246
+ serverId: string;
247
+ removedObjects: number;
248
+ }>;
249
+ awsConfig(serverId: string): Promise<AdminStorageAwsConfig>;
250
+ uploadObject(input: AdminStorageUploadInput): Promise<AdminStorageObjectResult>;
251
+ downloadObject(input: AdminStorageDownloadInput): Promise<AdminStorageObjectResult>;
252
+ deleteObject(input: AdminStorageDeleteInput | AdminDeleteObjectsInput): Promise<AdminStorageObjectResult | {
253
+ ok: boolean;
254
+ deleted: string[];
255
+ errors: Record<string, string>;
256
+ }>;
257
+ createSignedUrl(input: AdminStorageSignedUrlInput): Promise<AdminStorageSignedUrlResult>;
258
+ setRules(input: {
259
+ rules?: Record<string, unknown>;
260
+ rulesDsl?: string;
261
+ rulesHistoryPolicy?: AdminStorageRulesPolicy;
262
+ }): Promise<{
263
+ id: string;
264
+ }>;
265
+ validateRules(rulesDsl: string): Promise<{
266
+ valid: boolean;
267
+ diagnostics: unknown[];
268
+ rulesCount: number;
269
+ }>;
270
+ rulesHistory(): Promise<AdminStorageRulesHistoryResult>;
271
+ restoreRules(historyId: string): Promise<{
272
+ id: string;
273
+ rulesText: string;
274
+ }>;
275
+ createBucket(name: string, options?: AdminStorageBucketInput): Promise<AdminStorageBucket>;
276
+ listBuckets(): Promise<AdminStorageBucket[]>;
277
+ deleteBucket(name: string): Promise<{
278
+ ok: boolean;
279
+ removedObjects: number;
280
+ }>;
281
+ deleteBuckets(names: string[]): Promise<{
282
+ ok: boolean;
283
+ deleted: string[];
284
+ errors: Record<string, string>;
285
+ }>;
286
+ getBucketLocation(name: string): Promise<{
287
+ bucket: string;
288
+ kind: string;
289
+ region?: string;
290
+ endpoint?: string;
291
+ }>;
292
+ putObject(input: AdminPutObjectInput): Promise<AdminPutObjectResult>;
293
+ getObject(input: AdminGetObjectInput): Promise<AdminGetObjectResult>;
294
+ getObjectUrl(input: AdminGetObjectUrlInput): Promise<string>;
295
+ downloadObject(input: AdminDownloadObjectInput): Promise<AdminDownloadObjectResult>;
296
+ headObject(input: AdminHeadObjectInput): Promise<AdminStorageObjectMeta>;
297
+ headObjects(input: AdminHeadObjectsInput): Promise<AdminStorageObjectMeta[]>;
298
+ listObjects(input: AdminListObjectsInput): Promise<AdminListObjectsResult>;
299
+ copyObject(input: AdminCopyObjectInput): Promise<{
300
+ ok: boolean;
301
+ }>;
302
+ copyObjects(inputs: AdminCopyObjectInput[]): Promise<{
303
+ ok: boolean;
304
+ errors: Record<string, string>;
305
+ }>;
306
+ deleteObjects(input: AdminDeleteObjectsInput): Promise<{
307
+ ok: boolean;
308
+ deleted: string[];
309
+ errors: Record<string, string>;
310
+ }>;
311
+ }
312
+ export interface AdminStorageBucket {
313
+ id: string;
314
+ name: string;
315
+ bucket: string;
316
+ kind: string;
317
+ region?: string;
318
+ endpoint?: string;
319
+ prefix?: string;
320
+ frozen?: boolean;
321
+ readOnly?: boolean;
322
+ createdAt?: unknown;
323
+ updatedAt?: unknown;
324
+ }
325
+ export interface AdminStorageBucketInput {
326
+ kind?: string;
327
+ prefix?: string;
328
+ region?: string;
329
+ endpoint?: string;
330
+ accessKey?: string;
331
+ secretKey?: string;
332
+ dataDir?: string;
333
+ forcePathStyle?: boolean;
334
+ }
335
+ export interface AdminStorageObjectMeta {
336
+ key: string;
337
+ bucket: string;
338
+ size: number;
339
+ contentType: string;
340
+ encrypted: boolean;
341
+ createdAt?: unknown;
342
+ updatedAt?: unknown;
343
+ }
344
+ export interface AdminPutObjectInput {
345
+ bucket: string;
346
+ key: string;
347
+ body?: string | Uint8Array | ArrayBuffer | Buffer;
348
+ /** Pre-encoded base64 body. Mutually exclusive with `body`. Always uses base64 path. */
349
+ contentBase64?: string;
350
+ contentType?: string;
351
+ /** Encrypt at rest with AES-256-GCM. Defaults to true. */
352
+ encrypt?: boolean;
353
+ /**
354
+ * Max payload bytes for the base64-over-JSON upload path.
355
+ * Payloads larger than this are uploaded via a signed URL (raw binary PUT).
356
+ * Default: 4 MiB.
357
+ */
358
+ base64MaxBytes?: number;
359
+ }
360
+ export interface AdminPutObjectResult {
361
+ ok: boolean;
362
+ bucket: string;
363
+ key: string;
364
+ size: number;
365
+ encrypted: boolean;
366
+ }
367
+ export interface AdminGetObjectInput {
368
+ bucket: string;
369
+ key: string;
370
+ decrypt?: boolean;
371
+ }
372
+ export interface AdminGetObjectResult {
373
+ ok: boolean;
374
+ bucket: string;
375
+ key: string;
376
+ contentBase64: string;
377
+ contentType: string;
378
+ size: number;
379
+ encrypted: boolean;
380
+ }
381
+ export interface AdminHeadObjectInput {
382
+ bucket: string;
383
+ key: string;
384
+ }
385
+ export interface AdminHeadObjectsInput {
386
+ bucket: string;
387
+ keys: string[];
388
+ }
389
+ export interface AdminListObjectsInput {
390
+ bucket: string;
391
+ prefix?: string;
392
+ limit?: number;
393
+ cursor?: string;
394
+ }
395
+ export interface AdminListObjectsResult {
396
+ bucket: string;
397
+ objects: AdminStorageObjectMeta[];
398
+ count: number;
399
+ hasMore: boolean;
400
+ cursor?: string;
401
+ }
402
+ export interface AdminCopyObjectInput {
403
+ sourceBucket: string;
404
+ sourceKey: string;
405
+ destBucket: string;
406
+ destKey: string;
407
+ }
408
+ export interface AdminDeleteObjectsInput {
409
+ bucket: string;
410
+ keys: string[];
411
+ }
92
412
  export type QueryOperator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any" | "elem-match" | "like" | "not-like" | "contains" | "exists" | "not-exists";
93
413
  export interface WhereFilter {
94
414
  field: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuzjs/flare-admin",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Privileged server-side access for Flare. Designed for secure environments to perform administrative tasks, manage user identities at scale, and orchestrate system-wide notifications with full bypass of client-side security rules.",
5
5
  "keywords": [
6
6
  "flare",
@@ -30,9 +30,12 @@
30
30
  },
31
31
  "files": [
32
32
  "dist",
33
+ "proto",
33
34
  "README.md"
34
35
  ],
35
36
  "dependencies": {
37
+ "@grpc/grpc-js": "^1.14.0",
38
+ "@grpc/proto-loader": "^0.8.0",
36
39
  "ws": "^8.19.0"
37
40
  }
38
41
  }
@@ -0,0 +1,129 @@
1
+ syntax = "proto3";
2
+
3
+ package flare;
4
+
5
+ import "query.proto";
6
+
7
+ service AdminService {
8
+ rpc AdminQuery (AdminQueryRequest) returns (AdminQueryResponse);
9
+ rpc CreateCustomToken (CreateCustomTokenRequest) returns (CreateCustomTokenResponse);
10
+ rpc CreateAuthTicket (CreateAuthTicketRequest) returns (CreateAuthTicketResponse);
11
+ rpc GetDocument (AdminDocumentRequest) returns (AdminDocumentResponse);
12
+ rpc CreateDocument (AdminCreateDocumentRequest) returns (AdminMutationResponse);
13
+ rpc ReplaceDocument (AdminUpsertDocumentRequest) returns (AdminMutationResponse);
14
+ rpc UpdateDocument (AdminUpsertDocumentRequest) returns (AdminMutationResponse);
15
+ rpc DeleteDocument (AdminDocumentRequest) returns (AdminDeleteDocumentResponse);
16
+ rpc DeleteMany (AdminDeleteManyRequest) returns (AdminDeleteManyResponse);
17
+ }
18
+
19
+ message AdminQueryRequest {
20
+ string app_id = 1;
21
+ string admin_key = 2;
22
+ string collection = 3;
23
+ StructuredQuery query = 4;
24
+ }
25
+
26
+ message AdminQueryResponse {
27
+ string collection = 1;
28
+ StructuredQuery query = 2;
29
+ int32 count = 3;
30
+ string data_json = 4;
31
+ string error = 5;
32
+ string error_description = 6;
33
+ }
34
+
35
+ message CreateCustomTokenRequest {
36
+ string app_id = 1;
37
+ string admin_key = 2;
38
+ string uid = 3;
39
+ string role = 4;
40
+ string claims_json = 5;
41
+ string ttl = 6;
42
+ }
43
+
44
+ message CreateCustomTokenResponse {
45
+ string token = 1;
46
+ string error = 2;
47
+ string error_description = 3;
48
+ }
49
+
50
+ message CreateAuthTicketRequest {
51
+ string app_id = 1;
52
+ string admin_key = 2;
53
+ string uid = 3;
54
+ string role = 4;
55
+ string email = 5;
56
+ string sid = 6;
57
+ string tag = 7;
58
+ int64 ttl_seconds = 8;
59
+ string ip = 9;
60
+ }
61
+
62
+ message CreateAuthTicketResponse {
63
+ string ticket = 1;
64
+ string tag = 2;
65
+ string uuid = 3;
66
+ string expires_at = 4;
67
+ bool one_time = 5;
68
+ string uid = 6;
69
+ string role = 7;
70
+ string ip = 8;
71
+ string error = 9;
72
+ string error_description = 10;
73
+ }
74
+
75
+ message AdminDocumentRequest {
76
+ string app_id = 1;
77
+ string admin_key = 2;
78
+ string collection = 3;
79
+ string doc_id = 4;
80
+ }
81
+
82
+ message AdminDocumentResponse {
83
+ string collection = 1;
84
+ string doc_id = 2;
85
+ string data_json = 3;
86
+ bool found = 4;
87
+ string error = 5;
88
+ string error_description = 6;
89
+ }
90
+
91
+ message AdminCreateDocumentRequest {
92
+ string app_id = 1;
93
+ string admin_key = 2;
94
+ string collection = 3;
95
+ string data_json = 4;
96
+ }
97
+
98
+ message AdminUpsertDocumentRequest {
99
+ string app_id = 1;
100
+ string admin_key = 2;
101
+ string collection = 3;
102
+ string doc_id = 4;
103
+ string data_json = 5;
104
+ }
105
+
106
+ message AdminMutationResponse {
107
+ string id = 1;
108
+ string error = 2;
109
+ string error_description = 3;
110
+ }
111
+
112
+ message AdminDeleteDocumentResponse {
113
+ bool deleted = 1;
114
+ string error = 2;
115
+ string error_description = 3;
116
+ }
117
+
118
+ message AdminDeleteManyRequest {
119
+ string app_id = 1;
120
+ string admin_key = 2;
121
+ string collection = 3;
122
+ repeated AnyFilter where = 4;
123
+ }
124
+
125
+ message AdminDeleteManyResponse {
126
+ int64 deleted = 1;
127
+ string error = 2;
128
+ string error_description = 3;
129
+ }
@@ -0,0 +1,69 @@
1
+ syntax = "proto3";
2
+
3
+ package flare;
4
+
5
+ service AppService {
6
+ rpc CreateApp (CreateAppRequest) returns (CreateAppResponse);
7
+ rpc GetApp (GetAppRequest) returns (GetAppResponse);
8
+ }
9
+
10
+ message CreateAppRequest {
11
+ string name = 1;
12
+ string owner_uid = 2;
13
+ string app_id = 3;
14
+ string api_key = 4;
15
+ string admin_key = 5;
16
+ string jwt_secret = 6;
17
+ string db_name = 7;
18
+ string public_key = 8;
19
+ string private_key = 9;
20
+ AppSettings settings = 10;
21
+ }
22
+
23
+ message AppSettings {
24
+ int32 max_connections = 1;
25
+ bool enable_encryption = 2;
26
+ string rules_dsl = 3;
27
+ string rules_history_policy = 4;
28
+ repeated string rules_restore_events = 5;
29
+ PushSettings push = 6;
30
+ }
31
+
32
+ message PushSettings {
33
+ string vapid_public_key = 1;
34
+ string vapid_private_key = 2;
35
+ string vapid_subject = 3;
36
+ string welcome_notification = 4;
37
+ }
38
+
39
+ message CreateAppResponse {
40
+ string app_id = 1;
41
+ string db_name = 2;
42
+ string name = 3;
43
+ string owner_uid = 4;
44
+ string api_key = 5;
45
+ string admin_key = 6;
46
+ string jwt_secret = 7;
47
+ string public_key = 8;
48
+ string private_key = 9;
49
+ AppSettings settings = 10;
50
+ string created_at = 11;
51
+ }
52
+
53
+ message GetAppRequest {
54
+ string app_id = 1;
55
+ }
56
+
57
+ message GetAppResponse {
58
+ string app_id = 1;
59
+ string db_name = 2;
60
+ string name = 3;
61
+ string owner_uid = 4;
62
+ string api_key = 5;
63
+ string admin_key = 6;
64
+ string jwt_secret = 7;
65
+ string public_key = 8;
66
+ string private_key = 9;
67
+ AppSettings settings = 10;
68
+ string created_at = 11;
69
+ }
@@ -0,0 +1,70 @@
1
+ syntax = "proto3";
2
+
3
+ package flare;
4
+
5
+ service AuthService {
6
+ rpc Login (LoginRequest) returns (LoginResponse);
7
+ rpc Register (RegisterRequest) returns (RegisterResponse);
8
+ }
9
+
10
+ message LoginRequest {
11
+ string app_id = 1;
12
+ string client_id = 2;
13
+ string email = 3;
14
+ string username = 4;
15
+ string password = 5;
16
+ }
17
+
18
+ message LoginResponse {
19
+ string user_id = 1;
20
+ string token = 2;
21
+ string refresh_token = 3;
22
+ string role = 4;
23
+ string error = 5;
24
+ string error_description = 6;
25
+ }
26
+
27
+ message RegisterRequest {
28
+ string app_id = 1;
29
+ string client_id = 2;
30
+ string email = 3;
31
+ string username = 4;
32
+ string password = 5;
33
+ }
34
+
35
+ message RegisterResponse {
36
+ string user_id = 1;
37
+ string token = 2;
38
+ string role = 3;
39
+ string error = 4;
40
+ string error_description = 5;
41
+ }
42
+
43
+ message TokenRequest {
44
+ string app_id = 1;
45
+ string client_id = 2;
46
+ string grant_type = 3;
47
+ string username = 4;
48
+ string email = 5;
49
+ string password = 6;
50
+ string scope = 7;
51
+ }
52
+
53
+ message TokenResponse {
54
+ string access_token = 1;
55
+ string refresh_token = 2;
56
+ string csrf_token = 3;
57
+ string error = 4;
58
+ string error_description = 5;
59
+ }
60
+
61
+ message LogoutRequest {
62
+ string app_id = 1;
63
+ string sid = 2;
64
+ }
65
+
66
+ message LogoutResponse {
67
+ bool success = 1;
68
+ string error = 2;
69
+ string error_description = 3;
70
+ }
@@ -0,0 +1,11 @@
1
+ // flare.proto: root import for all flare gRPC services
2
+ syntax = "proto3";
3
+
4
+ package flare;
5
+
6
+ import "app.proto";
7
+ import "auth.proto";
8
+ import "admin.proto";
9
+ import "query.proto";
10
+
11
+ // Add more imports/services as needed