dominus-sdk-nodejs-dev 1.2.4

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.
Files changed (75) hide show
  1. package/LLM-GUIDE.md +537 -0
  2. package/README.md +585 -0
  3. package/dist/index.d.ts +191 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +224 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/cache.d.ts +112 -0
  8. package/dist/lib/cache.d.ts.map +1 -0
  9. package/dist/lib/cache.js +237 -0
  10. package/dist/lib/cache.js.map +1 -0
  11. package/dist/lib/client.d.ts +38 -0
  12. package/dist/lib/client.d.ts.map +1 -0
  13. package/dist/lib/client.js +425 -0
  14. package/dist/lib/client.js.map +1 -0
  15. package/dist/lib/config.d.ts +20 -0
  16. package/dist/lib/config.d.ts.map +1 -0
  17. package/dist/lib/config.js +32 -0
  18. package/dist/lib/config.js.map +1 -0
  19. package/dist/lib/crypto.d.ts +70 -0
  20. package/dist/lib/crypto.d.ts.map +1 -0
  21. package/dist/lib/crypto.js +95 -0
  22. package/dist/lib/crypto.js.map +1 -0
  23. package/dist/lib/errors.d.ts +77 -0
  24. package/dist/lib/errors.d.ts.map +1 -0
  25. package/dist/lib/errors.js +134 -0
  26. package/dist/lib/errors.js.map +1 -0
  27. package/dist/namespaces/auth.d.ts +237 -0
  28. package/dist/namespaces/auth.d.ts.map +1 -0
  29. package/dist/namespaces/auth.js +785 -0
  30. package/dist/namespaces/auth.js.map +1 -0
  31. package/dist/namespaces/courier.d.ts +67 -0
  32. package/dist/namespaces/courier.d.ts.map +1 -0
  33. package/dist/namespaces/courier.js +90 -0
  34. package/dist/namespaces/courier.js.map +1 -0
  35. package/dist/namespaces/db.d.ts +117 -0
  36. package/dist/namespaces/db.d.ts.map +1 -0
  37. package/dist/namespaces/db.js +149 -0
  38. package/dist/namespaces/db.js.map +1 -0
  39. package/dist/namespaces/ddl.d.ts +84 -0
  40. package/dist/namespaces/ddl.d.ts.map +1 -0
  41. package/dist/namespaces/ddl.js +211 -0
  42. package/dist/namespaces/ddl.js.map +1 -0
  43. package/dist/namespaces/files.d.ts +107 -0
  44. package/dist/namespaces/files.d.ts.map +1 -0
  45. package/dist/namespaces/files.js +161 -0
  46. package/dist/namespaces/files.js.map +1 -0
  47. package/dist/namespaces/health.d.ts +30 -0
  48. package/dist/namespaces/health.d.ts.map +1 -0
  49. package/dist/namespaces/health.js +66 -0
  50. package/dist/namespaces/health.js.map +1 -0
  51. package/dist/namespaces/logs.d.ts +97 -0
  52. package/dist/namespaces/logs.d.ts.map +1 -0
  53. package/dist/namespaces/logs.js +194 -0
  54. package/dist/namespaces/logs.js.map +1 -0
  55. package/dist/namespaces/open.d.ts +27 -0
  56. package/dist/namespaces/open.d.ts.map +1 -0
  57. package/dist/namespaces/open.js +46 -0
  58. package/dist/namespaces/open.js.map +1 -0
  59. package/dist/namespaces/portal.d.ts +172 -0
  60. package/dist/namespaces/portal.d.ts.map +1 -0
  61. package/dist/namespaces/portal.js +332 -0
  62. package/dist/namespaces/portal.js.map +1 -0
  63. package/dist/namespaces/redis.d.ts +144 -0
  64. package/dist/namespaces/redis.d.ts.map +1 -0
  65. package/dist/namespaces/redis.js +218 -0
  66. package/dist/namespaces/redis.js.map +1 -0
  67. package/dist/namespaces/secrets.d.ts +50 -0
  68. package/dist/namespaces/secrets.d.ts.map +1 -0
  69. package/dist/namespaces/secrets.js +93 -0
  70. package/dist/namespaces/secrets.js.map +1 -0
  71. package/dist/namespaces/secure.d.ts +102 -0
  72. package/dist/namespaces/secure.d.ts.map +1 -0
  73. package/dist/namespaces/secure.js +151 -0
  74. package/dist/namespaces/secure.js.map +1 -0
  75. package/package.json +45 -0
@@ -0,0 +1,785 @@
1
+ /**
2
+ * Auth Namespace - Guardian authentication/authorization management.
3
+ *
4
+ * Provides RESTful access to users, roles, scopes, clients, tenants, etc.
5
+ */
6
+ export class AuthNamespace {
7
+ client;
8
+ _publicKeyCache = null;
9
+ constructor(client) {
10
+ this.client = client;
11
+ }
12
+ // ========================================
13
+ // USERS
14
+ // ========================================
15
+ async createUser(params) {
16
+ return this.client.request({
17
+ endpoint: '/api/guardian/users',
18
+ body: {
19
+ username: params.username,
20
+ email: params.email,
21
+ password: params.password,
22
+ status: params.status || 'active',
23
+ },
24
+ });
25
+ }
26
+ async getUser(userId) {
27
+ return this.client.request({
28
+ endpoint: `/api/guardian/users/${userId}`,
29
+ method: 'GET',
30
+ });
31
+ }
32
+ async listUsers(params) {
33
+ const { status, limit = 100, offset = 0, orderBy = 'created_at', orderDesc = true } = params || {};
34
+ let queryParams = `?limit=${limit}&offset=${offset}&order_by=${orderBy}&order_desc=${orderDesc}`;
35
+ if (status) {
36
+ queryParams += `&status=${status}`;
37
+ }
38
+ return this.client.request({
39
+ endpoint: `/api/guardian/users${queryParams}`,
40
+ method: 'GET',
41
+ });
42
+ }
43
+ async updateUser(userId, data) {
44
+ return this.client.request({
45
+ endpoint: `/api/guardian/users/${userId}`,
46
+ method: 'PUT',
47
+ body: data,
48
+ });
49
+ }
50
+ async deleteUser(userId) {
51
+ return this.client.request({
52
+ endpoint: `/api/guardian/users/${userId}`,
53
+ method: 'DELETE',
54
+ });
55
+ }
56
+ async updatePassword(userId, password) {
57
+ return this.client.request({
58
+ endpoint: `/api/guardian/users/${userId}/password`,
59
+ method: 'PUT',
60
+ body: { password },
61
+ });
62
+ }
63
+ async verifyPassword(userId, password) {
64
+ return this.client.request({
65
+ endpoint: `/api/guardian/users/${userId}/verify-password`,
66
+ body: { password },
67
+ });
68
+ }
69
+ // User junction tables
70
+ async getUserRoles(userId) {
71
+ return this.client.request({
72
+ endpoint: `/api/guardian/users/${userId}/roles`,
73
+ method: 'GET',
74
+ });
75
+ }
76
+ async addUserRoles(userId, roleIds) {
77
+ return this.client.request({
78
+ endpoint: `/api/guardian/users/${userId}/roles`,
79
+ body: { role_ids: roleIds },
80
+ });
81
+ }
82
+ async removeUserRoles(userId, roleIds) {
83
+ return this.client.request({
84
+ endpoint: `/api/guardian/users/${userId}/roles`,
85
+ method: 'DELETE',
86
+ body: { role_ids: roleIds },
87
+ });
88
+ }
89
+ async getUserScopes(userId) {
90
+ return this.client.request({
91
+ endpoint: `/api/guardian/users/${userId}/scopes`,
92
+ method: 'GET',
93
+ });
94
+ }
95
+ async addUserScopes(userId, scopeIds) {
96
+ return this.client.request({
97
+ endpoint: `/api/guardian/users/${userId}/scopes`,
98
+ body: { scope_ids: scopeIds },
99
+ });
100
+ }
101
+ async removeUserScopes(userId, scopeIds) {
102
+ return this.client.request({
103
+ endpoint: `/api/guardian/users/${userId}/scopes`,
104
+ method: 'DELETE',
105
+ body: { scope_ids: scopeIds },
106
+ });
107
+ }
108
+ async getUserTenants(userId) {
109
+ return this.client.request({
110
+ endpoint: `/api/guardian/users/${userId}/tenants`,
111
+ method: 'GET',
112
+ });
113
+ }
114
+ async addUserTenants(userId, tenantIds) {
115
+ return this.client.request({
116
+ endpoint: `/api/guardian/users/${userId}/tenants`,
117
+ body: { tenant_ids: tenantIds },
118
+ });
119
+ }
120
+ async removeUserTenants(userId, tenantIds) {
121
+ return this.client.request({
122
+ endpoint: `/api/guardian/users/${userId}/tenants`,
123
+ method: 'DELETE',
124
+ body: { tenant_ids: tenantIds },
125
+ });
126
+ }
127
+ async getUserSubtypes(userId) {
128
+ return this.client.request({
129
+ endpoint: `/api/guardian/users/${userId}/subtypes`,
130
+ method: 'GET',
131
+ });
132
+ }
133
+ async addUserSubtypes(userId, subtypeIds) {
134
+ return this.client.request({
135
+ endpoint: `/api/guardian/users/${userId}/subtypes`,
136
+ body: { subtype_ids: subtypeIds },
137
+ });
138
+ }
139
+ async removeUserSubtypes(userId, subtypeIds) {
140
+ return this.client.request({
141
+ endpoint: `/api/guardian/users/${userId}/subtypes`,
142
+ method: 'DELETE',
143
+ body: { subtype_ids: subtypeIds },
144
+ });
145
+ }
146
+ // ========================================
147
+ // ROLES
148
+ // ========================================
149
+ async createRole(params) {
150
+ return this.client.request({
151
+ endpoint: '/api/guardian/roles',
152
+ body: {
153
+ name: params.name,
154
+ description: params.description,
155
+ },
156
+ });
157
+ }
158
+ async getRole(roleId) {
159
+ return this.client.request({
160
+ endpoint: `/api/guardian/roles/${roleId}`,
161
+ method: 'GET',
162
+ });
163
+ }
164
+ async listRoles(params) {
165
+ const { limit = 100, offset = 0 } = params || {};
166
+ return this.client.request({
167
+ endpoint: `/api/guardian/roles?limit=${limit}&offset=${offset}`,
168
+ method: 'GET',
169
+ });
170
+ }
171
+ async updateRole(roleId, data) {
172
+ return this.client.request({
173
+ endpoint: `/api/guardian/roles/${roleId}`,
174
+ method: 'PUT',
175
+ body: data,
176
+ });
177
+ }
178
+ async deleteRole(roleId) {
179
+ return this.client.request({
180
+ endpoint: `/api/guardian/roles/${roleId}`,
181
+ method: 'DELETE',
182
+ });
183
+ }
184
+ async getRoleScopes(roleId) {
185
+ return this.client.request({
186
+ endpoint: `/api/guardian/roles/${roleId}/scopes`,
187
+ method: 'GET',
188
+ });
189
+ }
190
+ async addRoleScopes(roleId, scopeIds) {
191
+ return this.client.request({
192
+ endpoint: `/api/guardian/roles/${roleId}/scopes`,
193
+ body: { scope_ids: scopeIds },
194
+ });
195
+ }
196
+ async removeRoleScopes(roleId, scopeIds) {
197
+ return this.client.request({
198
+ endpoint: `/api/guardian/roles/${roleId}/scopes`,
199
+ method: 'DELETE',
200
+ body: { scope_ids: scopeIds },
201
+ });
202
+ }
203
+ // ========================================
204
+ // SCOPES
205
+ // ========================================
206
+ async createScope(params) {
207
+ return this.client.request({
208
+ endpoint: '/api/guardian/scopes',
209
+ body: {
210
+ slug: params.slug,
211
+ display_name: params.displayName,
212
+ description: params.description,
213
+ },
214
+ });
215
+ }
216
+ async getScope(scopeId) {
217
+ return this.client.request({
218
+ endpoint: `/api/guardian/scopes/${scopeId}`,
219
+ method: 'GET',
220
+ });
221
+ }
222
+ async listScopes(params) {
223
+ const { limit = 100, offset = 0 } = params || {};
224
+ return this.client.request({
225
+ endpoint: `/api/guardian/scopes?limit=${limit}&offset=${offset}`,
226
+ method: 'GET',
227
+ });
228
+ }
229
+ async updateScope(scopeId, data) {
230
+ const body = {};
231
+ if (data.slug !== undefined)
232
+ body.slug = data.slug;
233
+ if (data.displayName !== undefined)
234
+ body.display_name = data.displayName;
235
+ if (data.description !== undefined)
236
+ body.description = data.description;
237
+ return this.client.request({
238
+ endpoint: `/api/guardian/scopes/${scopeId}`,
239
+ method: 'PUT',
240
+ body,
241
+ });
242
+ }
243
+ async deleteScope(scopeId) {
244
+ return this.client.request({
245
+ endpoint: `/api/guardian/scopes/${scopeId}`,
246
+ method: 'DELETE',
247
+ });
248
+ }
249
+ // ========================================
250
+ // CLIENTS (PSK/Machine Auth)
251
+ // ========================================
252
+ async createClient(params) {
253
+ return this.client.request({
254
+ endpoint: '/api/guardian/clients',
255
+ body: {
256
+ label: params.label,
257
+ description: params.description,
258
+ },
259
+ });
260
+ }
261
+ async getClient(clientId) {
262
+ return this.client.request({
263
+ endpoint: `/api/guardian/clients/${clientId}`,
264
+ method: 'GET',
265
+ });
266
+ }
267
+ async listClients(params) {
268
+ const { limit = 100, offset = 0 } = params || {};
269
+ return this.client.request({
270
+ endpoint: `/api/guardian/clients?limit=${limit}&offset=${offset}`,
271
+ method: 'GET',
272
+ });
273
+ }
274
+ async updateClient(clientId, data) {
275
+ return this.client.request({
276
+ endpoint: `/api/guardian/clients/${clientId}`,
277
+ method: 'PUT',
278
+ body: data,
279
+ });
280
+ }
281
+ async deleteClient(clientId) {
282
+ return this.client.request({
283
+ endpoint: `/api/guardian/clients/${clientId}`,
284
+ method: 'DELETE',
285
+ });
286
+ }
287
+ async regeneratePsk(clientId) {
288
+ return this.client.request({
289
+ endpoint: `/api/guardian/clients/${clientId}/regenerate-psk`,
290
+ body: {},
291
+ });
292
+ }
293
+ async verifyPsk(clientId, psk) {
294
+ return this.client.request({
295
+ endpoint: `/api/guardian/clients/${clientId}/verify-psk`,
296
+ body: { psk },
297
+ });
298
+ }
299
+ async getClientTenants(clientId) {
300
+ return this.client.request({
301
+ endpoint: `/api/guardian/clients/${clientId}/tenants`,
302
+ method: 'GET',
303
+ });
304
+ }
305
+ async addClientTenants(clientId, tenantIds) {
306
+ return this.client.request({
307
+ endpoint: `/api/guardian/clients/${clientId}/tenants`,
308
+ body: { tenant_ids: tenantIds },
309
+ });
310
+ }
311
+ async removeClientTenants(clientId, tenantIds) {
312
+ return this.client.request({
313
+ endpoint: `/api/guardian/clients/${clientId}/tenants`,
314
+ method: 'DELETE',
315
+ body: { tenant_ids: tenantIds },
316
+ });
317
+ }
318
+ // ========================================
319
+ // TENANTS
320
+ // ========================================
321
+ async createTenant(params) {
322
+ const body = {
323
+ name: params.name,
324
+ slug: params.slug,
325
+ };
326
+ if (params.categoryId)
327
+ body.category_id = params.categoryId;
328
+ if (params.displayName)
329
+ body.display_name = params.displayName;
330
+ if (params.description)
331
+ body.description = params.description;
332
+ return this.client.request({
333
+ endpoint: '/api/guardian/tenants',
334
+ body,
335
+ });
336
+ }
337
+ async getTenant(tenantId) {
338
+ return this.client.request({
339
+ endpoint: `/api/guardian/tenants/${tenantId}`,
340
+ method: 'GET',
341
+ });
342
+ }
343
+ async listTenants(params) {
344
+ const { status, categoryId, limit = 100, offset = 0 } = params || {};
345
+ let queryParams = `?limit=${limit}&offset=${offset}`;
346
+ if (status)
347
+ queryParams += `&status=${status}`;
348
+ if (categoryId)
349
+ queryParams += `&category_id=${categoryId}`;
350
+ return this.client.request({
351
+ endpoint: `/api/guardian/tenants${queryParams}`,
352
+ method: 'GET',
353
+ });
354
+ }
355
+ async updateTenant(tenantId, data) {
356
+ const body = {};
357
+ if (data.name !== undefined)
358
+ body.name = data.name;
359
+ if (data.displayName !== undefined)
360
+ body.display_name = data.displayName;
361
+ if (data.status !== undefined)
362
+ body.status = data.status;
363
+ return this.client.request({
364
+ endpoint: `/api/guardian/tenants/${tenantId}`,
365
+ method: 'PUT',
366
+ body,
367
+ });
368
+ }
369
+ async deleteTenant(tenantId) {
370
+ return this.client.request({
371
+ endpoint: `/api/guardian/tenants/${tenantId}`,
372
+ method: 'DELETE',
373
+ });
374
+ }
375
+ // ========================================
376
+ // TENANT CATEGORIES
377
+ // ========================================
378
+ async createTenantCategory(params) {
379
+ return this.client.request({
380
+ endpoint: '/api/guardian/tenant-categories',
381
+ body: {
382
+ name: params.name,
383
+ slug: params.slug,
384
+ description: params.description,
385
+ color: params.color || '#3B82F6',
386
+ },
387
+ });
388
+ }
389
+ async getTenantCategory(categoryId) {
390
+ return this.client.request({
391
+ endpoint: `/api/guardian/tenant-categories/${categoryId}`,
392
+ method: 'GET',
393
+ });
394
+ }
395
+ async listTenantCategories(params) {
396
+ const { limit = 100, offset = 0 } = params || {};
397
+ return this.client.request({
398
+ endpoint: `/api/guardian/tenant-categories?limit=${limit}&offset=${offset}`,
399
+ method: 'GET',
400
+ });
401
+ }
402
+ async updateTenantCategory(categoryId, data) {
403
+ return this.client.request({
404
+ endpoint: `/api/guardian/tenant-categories/${categoryId}`,
405
+ method: 'PUT',
406
+ body: data,
407
+ });
408
+ }
409
+ async deleteTenantCategory(categoryId) {
410
+ return this.client.request({
411
+ endpoint: `/api/guardian/tenant-categories/${categoryId}`,
412
+ method: 'DELETE',
413
+ });
414
+ }
415
+ // ========================================
416
+ // SUBTYPES
417
+ // ========================================
418
+ async createSubtype(params) {
419
+ return this.client.request({
420
+ endpoint: '/api/guardian/subtypes',
421
+ body: {
422
+ name: params.name,
423
+ slug: params.slug,
424
+ description: params.description,
425
+ },
426
+ });
427
+ }
428
+ async getSubtype(subtypeId) {
429
+ return this.client.request({
430
+ endpoint: `/api/guardian/subtypes/${subtypeId}`,
431
+ method: 'GET',
432
+ });
433
+ }
434
+ async listSubtypes(params) {
435
+ const { limit = 100, offset = 0 } = params || {};
436
+ return this.client.request({
437
+ endpoint: `/api/guardian/subtypes?limit=${limit}&offset=${offset}`,
438
+ method: 'GET',
439
+ });
440
+ }
441
+ async updateSubtype(subtypeId, data) {
442
+ return this.client.request({
443
+ endpoint: `/api/guardian/subtypes/${subtypeId}`,
444
+ method: 'PUT',
445
+ body: data,
446
+ });
447
+ }
448
+ async deleteSubtype(subtypeId) {
449
+ return this.client.request({
450
+ endpoint: `/api/guardian/subtypes/${subtypeId}`,
451
+ method: 'DELETE',
452
+ });
453
+ }
454
+ // ========================================
455
+ // PAGES
456
+ // ========================================
457
+ async createPage(params) {
458
+ return this.client.request({
459
+ endpoint: '/api/guardian/pages',
460
+ body: {
461
+ path: params.path,
462
+ name: params.name,
463
+ description: params.description,
464
+ is_active: params.isActive ?? true,
465
+ show_in_nav: params.showInNav ?? true,
466
+ },
467
+ });
468
+ }
469
+ async getPage(pageId) {
470
+ return this.client.request({
471
+ endpoint: `/api/guardian/pages/${pageId}`,
472
+ method: 'GET',
473
+ });
474
+ }
475
+ async listPages(params) {
476
+ const { isActive, limit = 100, offset = 0 } = params || {};
477
+ let queryParams = `?limit=${limit}&offset=${offset}`;
478
+ if (isActive !== undefined)
479
+ queryParams += `&is_active=${isActive}`;
480
+ return this.client.request({
481
+ endpoint: `/api/guardian/pages${queryParams}`,
482
+ method: 'GET',
483
+ });
484
+ }
485
+ async updatePage(pageId, data) {
486
+ const body = {};
487
+ if (data.path !== undefined)
488
+ body.path = data.path;
489
+ if (data.name !== undefined)
490
+ body.name = data.name;
491
+ if (data.description !== undefined)
492
+ body.description = data.description;
493
+ if (data.isActive !== undefined)
494
+ body.is_active = data.isActive;
495
+ if (data.showInNav !== undefined)
496
+ body.show_in_nav = data.showInNav;
497
+ return this.client.request({
498
+ endpoint: `/api/guardian/pages/${pageId}`,
499
+ method: 'PUT',
500
+ body,
501
+ });
502
+ }
503
+ async deletePage(pageId) {
504
+ return this.client.request({
505
+ endpoint: `/api/guardian/pages/${pageId}`,
506
+ method: 'DELETE',
507
+ });
508
+ }
509
+ async getPageTenants(pageId) {
510
+ return this.client.request({
511
+ endpoint: `/api/guardian/pages/${pageId}/tenants`,
512
+ method: 'GET',
513
+ });
514
+ }
515
+ async addPageTenants(pageId, tenantIds) {
516
+ return this.client.request({
517
+ endpoint: `/api/guardian/pages/${pageId}/tenants`,
518
+ body: { tenant_ids: tenantIds },
519
+ });
520
+ }
521
+ async removePageTenants(pageId, tenantIds) {
522
+ return this.client.request({
523
+ endpoint: `/api/guardian/pages/${pageId}/tenants`,
524
+ method: 'DELETE',
525
+ body: { tenant_ids: tenantIds },
526
+ });
527
+ }
528
+ async getPageScopes(pageId) {
529
+ return this.client.request({
530
+ endpoint: `/api/guardian/pages/${pageId}/scopes`,
531
+ method: 'GET',
532
+ });
533
+ }
534
+ async addPageScopes(pageId, scopeIds) {
535
+ return this.client.request({
536
+ endpoint: `/api/guardian/pages/${pageId}/scopes`,
537
+ body: { scope_ids: scopeIds },
538
+ });
539
+ }
540
+ async removePageScopes(pageId, scopeIds) {
541
+ return this.client.request({
542
+ endpoint: `/api/guardian/pages/${pageId}/scopes`,
543
+ method: 'DELETE',
544
+ body: { scope_ids: scopeIds },
545
+ });
546
+ }
547
+ async setPageScopes(pageId, scopeIds) {
548
+ return this.client.request({
549
+ endpoint: `/api/guardian/pages/${pageId}/scopes`,
550
+ method: 'PUT',
551
+ body: { scope_ids: scopeIds },
552
+ });
553
+ }
554
+ // ========================================
555
+ // NAVIGATION
556
+ // ========================================
557
+ async createNavItem(params) {
558
+ const body = {
559
+ tenant_id: params.tenantId,
560
+ title: params.title,
561
+ sort_order: params.sortOrder ?? 0,
562
+ is_header: params.isHeader ?? false,
563
+ is_active: params.isActive ?? true,
564
+ is_expanded_default: params.isExpandedDefault ?? false,
565
+ };
566
+ if (params.icon)
567
+ body.icon = params.icon;
568
+ if (params.description)
569
+ body.description = params.description;
570
+ if (params.pageId)
571
+ body.page_id = params.pageId;
572
+ if (params.parentId)
573
+ body.parent_id = params.parentId;
574
+ return this.client.request({
575
+ endpoint: '/api/guardian/nav-items',
576
+ body,
577
+ });
578
+ }
579
+ async getNavItem(navId) {
580
+ return this.client.request({
581
+ endpoint: `/api/guardian/nav-items/${navId}`,
582
+ method: 'GET',
583
+ });
584
+ }
585
+ async listNavItems(params) {
586
+ const queryParams = new URLSearchParams();
587
+ if (params?.tenantId)
588
+ queryParams.append('tenant_id', params.tenantId);
589
+ if (params?.parentId)
590
+ queryParams.append('parent_id', params.parentId);
591
+ if (params?.isActive !== undefined)
592
+ queryParams.append('is_active', String(params.isActive));
593
+ queryParams.append('limit', String(params?.limit ?? 100));
594
+ queryParams.append('offset', String(params?.offset ?? 0));
595
+ if (params?.orderBy)
596
+ queryParams.append('order_by', params.orderBy);
597
+ if (params?.orderDesc !== undefined)
598
+ queryParams.append('order_desc', String(params.orderDesc));
599
+ return this.client.request({
600
+ endpoint: `/api/guardian/nav-items?${queryParams.toString()}`,
601
+ method: 'GET',
602
+ });
603
+ }
604
+ async updateNavItem(navId, data) {
605
+ const body = {};
606
+ if (data.title !== undefined)
607
+ body.title = data.title;
608
+ if (data.icon !== undefined)
609
+ body.icon = data.icon;
610
+ if (data.description !== undefined)
611
+ body.description = data.description;
612
+ if (data.pageId !== undefined)
613
+ body.page_id = data.pageId;
614
+ if (data.parentId !== undefined)
615
+ body.parent_id = data.parentId;
616
+ if (data.isHeader !== undefined)
617
+ body.is_header = data.isHeader;
618
+ if (data.isActive !== undefined)
619
+ body.is_active = data.isActive;
620
+ if (data.sortOrder !== undefined)
621
+ body.sort_order = data.sortOrder;
622
+ if (data.isExpandedDefault !== undefined)
623
+ body.is_expanded_default = data.isExpandedDefault;
624
+ return this.client.request({
625
+ endpoint: `/api/guardian/nav-items/${navId}`,
626
+ method: 'PUT',
627
+ body,
628
+ });
629
+ }
630
+ async deleteNavItem(navId) {
631
+ return this.client.request({
632
+ endpoint: `/api/guardian/nav-items/${navId}`,
633
+ method: 'DELETE',
634
+ });
635
+ }
636
+ // Navigation Scopes
637
+ async getNavScopes(navId) {
638
+ return this.client.request({
639
+ endpoint: `/api/guardian/nav-items/${navId}/scopes`,
640
+ method: 'GET',
641
+ });
642
+ }
643
+ async addNavScopes(navId, scopeIds) {
644
+ return this.client.request({
645
+ endpoint: `/api/guardian/nav-items/${navId}/scopes`,
646
+ body: { scope_ids: scopeIds },
647
+ });
648
+ }
649
+ async removeNavScopes(navId, scopeIds) {
650
+ return this.client.request({
651
+ endpoint: `/api/guardian/nav-items/${navId}/scopes`,
652
+ method: 'DELETE',
653
+ body: { scope_ids: scopeIds },
654
+ });
655
+ }
656
+ // Navigation Roles
657
+ async getNavRoles(navId) {
658
+ return this.client.request({
659
+ endpoint: `/api/guardian/nav-items/${navId}/roles`,
660
+ method: 'GET',
661
+ });
662
+ }
663
+ async addNavRoles(navId, roleIds) {
664
+ return this.client.request({
665
+ endpoint: `/api/guardian/nav-items/${navId}/roles`,
666
+ body: { role_ids: roleIds },
667
+ });
668
+ }
669
+ async removeNavRoles(navId, roleIds) {
670
+ return this.client.request({
671
+ endpoint: `/api/guardian/nav-items/${navId}/roles`,
672
+ method: 'DELETE',
673
+ body: { role_ids: roleIds },
674
+ });
675
+ }
676
+ // Navigation Subtypes
677
+ async getNavSubtypes(navId) {
678
+ return this.client.request({
679
+ endpoint: `/api/guardian/nav-items/${navId}/subtypes`,
680
+ method: 'GET',
681
+ });
682
+ }
683
+ async addNavSubtypes(navId, subtypeIds) {
684
+ return this.client.request({
685
+ endpoint: `/api/guardian/nav-items/${navId}/subtypes`,
686
+ body: { subtype_ids: subtypeIds },
687
+ });
688
+ }
689
+ async removeNavSubtypes(navId, subtypeIds) {
690
+ return this.client.request({
691
+ endpoint: `/api/guardian/nav-items/${navId}/subtypes`,
692
+ method: 'DELETE',
693
+ body: { subtype_ids: subtypeIds },
694
+ });
695
+ }
696
+ // ========================================
697
+ // SECURE TABLES
698
+ // ========================================
699
+ async createSecureTable(params) {
700
+ return this.client.request({
701
+ endpoint: '/api/guardian/secure-tables',
702
+ body: {
703
+ table_name: params.tableName,
704
+ schema_name: params.schemaName || 'public',
705
+ },
706
+ });
707
+ }
708
+ async getSecureTable(secureTableId) {
709
+ return this.client.request({
710
+ endpoint: `/api/guardian/secure-tables/${secureTableId}`,
711
+ method: 'GET',
712
+ });
713
+ }
714
+ async listSecureTables(params) {
715
+ const { limit = 100, offset = 0 } = params || {};
716
+ return this.client.request({
717
+ endpoint: `/api/guardian/secure-tables?limit=${limit}&offset=${offset}`,
718
+ method: 'GET',
719
+ });
720
+ }
721
+ async deleteSecureTable(secureTableId) {
722
+ return this.client.request({
723
+ endpoint: `/api/guardian/secure-tables/${secureTableId}`,
724
+ method: 'DELETE',
725
+ });
726
+ }
727
+ async getSecureTableScopes(secureTableId) {
728
+ return this.client.request({
729
+ endpoint: `/api/guardian/secure-tables/${secureTableId}/scopes`,
730
+ method: 'GET',
731
+ });
732
+ }
733
+ async addSecureTableScopes(secureTableId, scopeIds) {
734
+ return this.client.request({
735
+ endpoint: `/api/guardian/secure-tables/${secureTableId}/scopes`,
736
+ body: { scope_ids: scopeIds },
737
+ });
738
+ }
739
+ async removeSecureTableScopes(secureTableId, scopeIds) {
740
+ return this.client.request({
741
+ endpoint: `/api/guardian/secure-tables/${secureTableId}/scopes`,
742
+ method: 'DELETE',
743
+ body: { scope_ids: scopeIds },
744
+ });
745
+ }
746
+ // ========================================
747
+ // JWT OPERATIONS (via Warden)
748
+ // ========================================
749
+ async getJwks() {
750
+ if (this._publicKeyCache) {
751
+ return this._publicKeyCache;
752
+ }
753
+ const result = await this.client.request({
754
+ endpoint: '/api/warden/jwks',
755
+ method: 'GET',
756
+ });
757
+ this._publicKeyCache = result;
758
+ return result;
759
+ }
760
+ async validateJwt(token) {
761
+ // Ensure JWKS is cached for future signature verification
762
+ await this.getJwks();
763
+ // Decode JWT without verification to get claims
764
+ // For full signature validation, use a JWT library like jsonwebtoken
765
+ const parts = token.split('.');
766
+ if (parts.length !== 3) {
767
+ throw new Error('Invalid JWT format');
768
+ }
769
+ try {
770
+ const payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf-8'));
771
+ // Check expiration
772
+ if (payload.exp && payload.exp < Math.floor(Date.now() / 1000)) {
773
+ throw new Error('Token has expired');
774
+ }
775
+ return payload;
776
+ }
777
+ catch (e) {
778
+ if (e instanceof Error && e.message === 'Token has expired') {
779
+ throw e;
780
+ }
781
+ throw new Error(`Invalid token: ${e}`);
782
+ }
783
+ }
784
+ }
785
+ //# sourceMappingURL=auth.js.map