@omnibase/core-js 0.7.6 → 0.8.0
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/dist/chunk-5B37CXXH.js +447 -0
- package/dist/index.cjs +87 -18
- package/dist/index.js +1 -1
- package/dist/payments/index.d.cts +156 -89
- package/dist/payments/index.d.ts +156 -89
- package/dist/permissions/index.cjs +87 -18
- package/dist/permissions/index.js +1 -1
- package/package.json +1 -1
|
@@ -316,25 +316,56 @@ var PermissionsClient = class {
|
|
|
316
316
|
* on an object. This API handles read operations and is optimized for fast
|
|
317
317
|
* permission checks in your application logic.
|
|
318
318
|
*
|
|
319
|
+
* All operations are proxied through Omnibase's API at `/api/v1/permissions/read`.
|
|
320
|
+
*
|
|
319
321
|
* Key methods:
|
|
320
|
-
* - `checkPermission()` - Checks if a subject has permission on an object
|
|
321
|
-
* - `checkPermissionOrError()` - Same as above but throws error if denied
|
|
322
|
-
* - `expandPermissions()` - Expands relationships to show all granted permissions
|
|
322
|
+
* - `checkPermission(params)` - Checks if a subject has permission on an object
|
|
323
|
+
* - `checkPermissionOrError(params)` - Same as above but throws error if denied
|
|
324
|
+
* - `expandPermissions(namespace, object, relation, maxDepth?)` - Expands relationships to show all granted permissions
|
|
325
|
+
* - `postCheckPermission(maxDepth?, body)` - POST variant of permission check
|
|
323
326
|
*
|
|
324
327
|
* @example
|
|
328
|
+
* Check a single permission:
|
|
325
329
|
* ```typescript
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
+
* const result = await omnibase.permissions.permissions.checkPermission({
|
|
331
|
+
* namespace: 'Tenant',
|
|
332
|
+
* object: 'tenant_123',
|
|
333
|
+
* relation: 'view',
|
|
334
|
+
* subjectId: 'user_456'
|
|
335
|
+
* });
|
|
336
|
+
*
|
|
337
|
+
* if (result.data.allowed) {
|
|
338
|
+
* console.log('User has permission');
|
|
339
|
+
* }
|
|
340
|
+
* ```
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* Expand permission tree:
|
|
344
|
+
* ```typescript
|
|
345
|
+
* const tree = await omnibase.permissions.permissions.expandPermissions(
|
|
346
|
+
* 'Tenant',
|
|
347
|
+
* 'tenant_123',
|
|
348
|
+
* 'view'
|
|
349
|
+
* );
|
|
350
|
+
*
|
|
351
|
+
* console.log('Permission tree:', tree.data);
|
|
352
|
+
* ```
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* Check permission or throw error:
|
|
356
|
+
* ```typescript
|
|
357
|
+
* try {
|
|
358
|
+
* await omnibase.permissions.permissions.checkPermissionOrError({
|
|
330
359
|
* namespace: 'Tenant',
|
|
331
360
|
* object: 'tenant_123',
|
|
332
|
-
* relation: '
|
|
361
|
+
* relation: 'edit',
|
|
333
362
|
* subjectId: 'user_456'
|
|
334
|
-
* }
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
363
|
+
* });
|
|
364
|
+
* // Permission granted
|
|
365
|
+
* } catch (error) {
|
|
366
|
+
* // Permission denied
|
|
367
|
+
* console.error('Access denied');
|
|
368
|
+
* }
|
|
338
369
|
* ```
|
|
339
370
|
*
|
|
340
371
|
* @since 1.0.0
|
|
@@ -348,20 +379,34 @@ var PermissionsClient = class {
|
|
|
348
379
|
* and managing role assignments. Works alongside the Keto-based
|
|
349
380
|
* permissions system to provide dynamic RBAC capabilities.
|
|
350
381
|
*
|
|
382
|
+
* Roles are stored in the database and automatically synchronized with
|
|
383
|
+
* Ory Keto relationships, providing a higher-level abstraction over
|
|
384
|
+
* raw relationship tuples.
|
|
385
|
+
*
|
|
351
386
|
* @example
|
|
387
|
+
* Create a custom role:
|
|
352
388
|
* ```typescript
|
|
353
|
-
* // Create a custom role
|
|
354
389
|
* const role = await omnibase.permissions.roles.create({
|
|
355
390
|
* role_name: 'billing_manager',
|
|
356
391
|
* permissions: ['tenant#manage_billing', 'tenant#view_invoices']
|
|
357
392
|
* });
|
|
393
|
+
* ```
|
|
358
394
|
*
|
|
359
|
-
*
|
|
395
|
+
* @example
|
|
396
|
+
* Assign role to a user:
|
|
397
|
+
* ```typescript
|
|
360
398
|
* await omnibase.permissions.roles.assign('user_123', {
|
|
361
399
|
* role_id: role.id
|
|
362
400
|
* });
|
|
363
401
|
* ```
|
|
364
402
|
*
|
|
403
|
+
* @example
|
|
404
|
+
* List all roles:
|
|
405
|
+
* ```typescript
|
|
406
|
+
* const roles = await omnibase.permissions.roles.list();
|
|
407
|
+
* console.log('Available roles:', roles);
|
|
408
|
+
* ```
|
|
409
|
+
*
|
|
365
410
|
* @since 0.7.0
|
|
366
411
|
* @group Roles
|
|
367
412
|
*/
|
|
@@ -370,19 +415,43 @@ var PermissionsClient = class {
|
|
|
370
415
|
* Creates a new PermissionsClient instance
|
|
371
416
|
*
|
|
372
417
|
* Initializes the client with separate endpoints for read and write operations.
|
|
373
|
-
* The client automatically
|
|
374
|
-
*
|
|
418
|
+
* The client automatically configures the Ory Keto client libraries to use
|
|
419
|
+
* Omnibase's permission proxy endpoints:
|
|
420
|
+
* - Write endpoint: `${apiBaseUrl}/api/v1/permissions/write`
|
|
421
|
+
* - Read endpoint: `${apiBaseUrl}/api/v1/permissions/read`
|
|
375
422
|
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
423
|
+
* This separation follows Ory Keto's recommended architecture for optimal
|
|
424
|
+
* performance and security.
|
|
425
|
+
*
|
|
426
|
+
* @param apiBaseUrl - The base URL for your Omnibase API instance (e.g., 'https://api.example.com')
|
|
427
|
+
* @param client - The main OmnibaseClient instance (required for roles handler)
|
|
378
428
|
*
|
|
379
429
|
* @throws {Error} When the base URL is invalid or cannot be reached
|
|
380
430
|
*
|
|
381
431
|
* @example
|
|
432
|
+
* Direct instantiation (not recommended - use OmnibaseClient instead):
|
|
382
433
|
* ```typescript
|
|
383
434
|
* const client = new PermissionsClient('https://api.example.com', omnibaseClient);
|
|
384
435
|
* ```
|
|
385
436
|
*
|
|
437
|
+
* @example
|
|
438
|
+
* Recommended usage via OmnibaseClient:
|
|
439
|
+
* ```typescript
|
|
440
|
+
* import { OmnibaseClient } from '@omnibase/core-js';
|
|
441
|
+
*
|
|
442
|
+
* const omnibase = new OmnibaseClient({
|
|
443
|
+
* apiUrl: 'https://api.example.com'
|
|
444
|
+
* });
|
|
445
|
+
*
|
|
446
|
+
* // Use the permissions client
|
|
447
|
+
* await omnibase.permissions.permissions.checkPermission({
|
|
448
|
+
* namespace: 'Tenant',
|
|
449
|
+
* object: 'tenant_123',
|
|
450
|
+
* relation: 'view',
|
|
451
|
+
* subjectId: 'user_456'
|
|
452
|
+
* });
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
386
455
|
* @since 1.0.0
|
|
387
456
|
* @group Client
|
|
388
457
|
*/
|