@omnibase/core-js 0.6.0 → 0.7.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/README.md +64 -198
- package/dist/chunk-6OGESVXW.js +651 -0
- package/dist/chunk-QPW6G4PA.js +490 -0
- package/dist/database/index.cjs +214 -0
- package/dist/database/index.d.cts +194 -1
- package/dist/database/index.d.ts +194 -1
- package/dist/database/index.js +213 -0
- package/dist/index.cjs +150 -174
- package/dist/index.js +85 -2
- package/dist/payments/index.cjs +22 -74
- package/dist/payments/index.d.cts +230 -249
- package/dist/payments/index.d.ts +230 -249
- package/dist/payments/index.js +1 -1
- package/dist/tenants/index.cjs +45 -100
- package/dist/tenants/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
# @omnibase/core-js
|
|
2
2
|
|
|
3
|
+
**Comprehensive authentication and multi-tenant platform integration**
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
The OmniBase Core SDK provides everything you need to integrate with the OmniBase platform, including comprehensive authentication flows via Ory Kratos, multi-tenant management, user invitations, and database operations. Built for both browser and Node.js environments with full TypeScript support.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
The OmniBase Core SDK provides everything you need to integrate with the OmniBase platform,
|
|
10
|
-
including comprehensive authentication flows via Ory Kratos, multi-tenant management, user
|
|
11
|
-
invitations, and database operations. Built for both browser and Node.js environments with
|
|
12
|
-
full TypeScript support.
|
|
13
|
-
|
|
14
|
-
[](https://badge.fury.io/js/%40omnibase%2Fcore-js)
|
|
15
|
-
[](https://opensource.org/licenses/MIT)
|
|
16
|
-
[](http://www.typescriptlang.org/)
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
17
10
|
|
|
18
11
|
## Features
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
| Feature | Description | Documentation |
|
|
14
|
+
|---------|-------------|---------------|
|
|
15
|
+
| Authentication Flows | Complete Ory Kratos integration with login, registration, recovery, settings, and verification | [Auth Docs](https://docs.omnibase.dev) |
|
|
16
|
+
| Multi-tenant Management | Organization lifecycle management with billing integration | [Tenant Docs](https://docs.omnibase.dev) |
|
|
17
|
+
| User Invitations | Secure tenant user invitation and acceptance workflows | [Invitation Docs](https://docs.omnibase.dev) |
|
|
18
|
+
| Tenant Switching | Seamless switching between multiple tenant contexts | [Context Docs](https://docs.omnibase.dev) |
|
|
19
|
+
| Database Integration | Supabase PostgREST client for advanced database operations | [Database Docs](https://docs.omnibase.dev) |
|
|
20
|
+
| Type Safety | Full TypeScript definitions with comprehensive type coverage | [API Reference](https://docs.omnibase.dev) |
|
|
28
21
|
|
|
29
22
|
## Quick Start
|
|
30
23
|
|
|
@@ -61,60 +54,28 @@ if (tenant.status === 200 && tenant.data) {
|
|
|
61
54
|
## Installation
|
|
62
55
|
|
|
63
56
|
```bash
|
|
57
|
+
# npm
|
|
64
58
|
npm install @omnibase/core-js
|
|
65
|
-
|
|
59
|
+
|
|
60
|
+
# yarn
|
|
66
61
|
yarn add @omnibase/core-js
|
|
67
|
-
|
|
62
|
+
|
|
63
|
+
# pnpm
|
|
68
64
|
pnpm add @omnibase/core-js
|
|
69
|
-
|
|
65
|
+
|
|
66
|
+
# bun
|
|
70
67
|
bun add @omnibase/core-js
|
|
71
68
|
```
|
|
72
69
|
|
|
73
|
-
## Modules
|
|
74
|
-
|
|
75
|
-
- **Authentication** - Ory Kratos flow management for login, registration, recovery, settings, and verification flows
|
|
76
|
-
- **Tenants** - Multi-tenant organization management including creation, deletion, user invitations, and tenant switching
|
|
77
|
-
- **Database** - Supabase PostgREST client for direct database access and advanced queries
|
|
78
|
-
|
|
79
|
-
## Authentication Integration
|
|
80
|
-
|
|
81
|
-
The SDK integrates seamlessly with Ory Kratos self-service authentication flows:
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
import type {
|
|
85
|
-
LoginFlow,
|
|
86
|
-
RegistrationFlow,
|
|
87
|
-
RecoveryFlow,
|
|
88
|
-
SettingsFlow,
|
|
89
|
-
VerificationFlow,
|
|
90
|
-
Session,
|
|
91
|
-
FlowType
|
|
92
|
-
} from '@omnibase/core-js';
|
|
93
|
-
|
|
94
|
-
// Type-safe flow handling
|
|
95
|
-
function handleAuthFlow(flow: FlowType) {
|
|
96
|
-
switch (flow.type) {
|
|
97
|
-
case 'login':
|
|
98
|
-
return processLoginFlow(flow as LoginFlow);
|
|
99
|
-
case 'registration':
|
|
100
|
-
return processRegistrationFlow(flow as RegistrationFlow);
|
|
101
|
-
case 'recovery':
|
|
102
|
-
return processRecoveryFlow(flow as RecoveryFlow);
|
|
103
|
-
default:
|
|
104
|
-
throw new Error(`Unsupported flow type: ${flow.type}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
70
|
+
## Modules Overview
|
|
107
71
|
|
|
108
|
-
|
|
109
|
-
function isSessionValid(session: Session): boolean {
|
|
110
|
-
return session.active === true &&
|
|
111
|
-
session.expires_at ? new Date(session.expires_at) > new Date() : false;
|
|
112
|
-
}
|
|
113
|
-
```
|
|
72
|
+
The SDK is organized into three main modules:
|
|
114
73
|
|
|
115
|
-
|
|
74
|
+
- **Authentication** - Ory Kratos flow management for login, registration, recovery, settings, and verification flows with type-safe session handling
|
|
75
|
+
- **Tenants** - Multi-tenant organization management including creation, deletion, user invitations, and tenant switching with billing integration
|
|
76
|
+
- **Database** - Supabase PostgREST client for direct database access and advanced queries with row-level security support
|
|
116
77
|
|
|
117
|
-
|
|
78
|
+
## Complete Workflow Example
|
|
118
79
|
|
|
119
80
|
```typescript
|
|
120
81
|
import {
|
|
@@ -162,169 +123,74 @@ if (newTenant.status === 200 && newTenant.data) {
|
|
|
162
123
|
}
|
|
163
124
|
```
|
|
164
125
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
```typescript
|
|
168
|
-
import { deleteTenant, type ApiResponse } from '@omnibase/core-js';
|
|
169
|
-
|
|
170
|
-
// Delete a tenant
|
|
171
|
-
const deleteResult = await deleteTenant('tenant-uuid');
|
|
172
|
-
if (deleteResult.status === 200) {
|
|
173
|
-
console.log('Tenant successfully deleted');
|
|
174
|
-
} else {
|
|
175
|
-
console.error('Failed to delete tenant:', deleteResult.error);
|
|
176
|
-
}
|
|
177
|
-
```
|
|
126
|
+
## Error Handling
|
|
178
127
|
|
|
179
|
-
|
|
128
|
+
All SDK functions return consistent `ApiResponse` types:
|
|
180
129
|
|
|
181
130
|
```typescript
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
url: process.env.DATABASE_URL || 'your-database-url',
|
|
187
|
-
// additional PostgREST client options
|
|
131
|
+
const result = await createTenant({
|
|
132
|
+
name: 'My Tenant',
|
|
133
|
+
billing_email: 'billing@example.com',
|
|
134
|
+
user_id: 'user-123'
|
|
188
135
|
});
|
|
189
136
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
.from('tenants')
|
|
193
|
-
.select('*')
|
|
194
|
-
.eq('active', true);
|
|
195
|
-
|
|
196
|
-
if (error) {
|
|
197
|
-
console.error('Database query failed:', error);
|
|
137
|
+
if (result.status === 200 && result.data) {
|
|
138
|
+
console.log('Tenant created:', result.data.tenant);
|
|
198
139
|
} else {
|
|
199
|
-
console.
|
|
200
|
-
}
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
## Type Definitions
|
|
204
|
-
|
|
205
|
-
The SDK provides comprehensive TypeScript types for all operations:
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
import type {
|
|
209
|
-
// Authentication types
|
|
210
|
-
LoginFlow,
|
|
211
|
-
RegistrationFlow,
|
|
212
|
-
RecoveryFlow,
|
|
213
|
-
SettingsFlow,
|
|
214
|
-
VerificationFlow,
|
|
215
|
-
LogoutFlow,
|
|
216
|
-
Session,
|
|
217
|
-
FlowType,
|
|
218
|
-
|
|
219
|
-
// Tenant types
|
|
220
|
-
Tenant,
|
|
221
|
-
CreateTenantRequest,
|
|
222
|
-
CreateTenantResponse,
|
|
223
|
-
CreateTenantUserInviteRequest,
|
|
224
|
-
CreateTenantUserInviteResponse,
|
|
225
|
-
AcceptTenantInviteResponse,
|
|
226
|
-
SwitchActiveTenantResponse,
|
|
227
|
-
DeleteTenantResponse,
|
|
228
|
-
ApiResponse
|
|
229
|
-
} from '@omnibase/core-js';
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## Error Handling
|
|
233
|
-
|
|
234
|
-
All SDK functions return consistent `ApiResponse` types with proper error handling:
|
|
235
|
-
|
|
236
|
-
```typescript
|
|
237
|
-
try {
|
|
238
|
-
const result = await createTenant({
|
|
239
|
-
name: 'My Tenant',
|
|
240
|
-
billing_email: 'billing@example.com',
|
|
241
|
-
user_id: 'user-123'
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
if (result.status === 200 && result.data) {
|
|
245
|
-
console.log('Tenant created:', result.data.tenant);
|
|
246
|
-
} else {
|
|
247
|
-
console.error('Failed to create tenant:', result.error);
|
|
248
|
-
}
|
|
249
|
-
} catch (error) {
|
|
250
|
-
console.error('Network or unexpected error:', error);
|
|
140
|
+
console.error('Failed:', result.error);
|
|
251
141
|
}
|
|
252
142
|
```
|
|
253
143
|
|
|
254
144
|
## Environment Configuration
|
|
255
145
|
|
|
256
|
-
The SDK requires environment configuration for proper operation:
|
|
257
|
-
|
|
258
146
|
```bash
|
|
259
|
-
# Required
|
|
147
|
+
# Required: OmniBase authentication endpoint
|
|
260
148
|
OMNIBASE_AUTH_URL=https://your-auth-endpoint.com
|
|
261
149
|
|
|
262
|
-
# Optional
|
|
150
|
+
# Optional: Database configuration for PostgREST client
|
|
263
151
|
DATABASE_URL=postgresql://user:pass@host:5432/dbname
|
|
264
152
|
```
|
|
265
153
|
|
|
266
154
|
## Security Features
|
|
267
155
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
-
|
|
271
|
-
|
|
272
|
-
|
|
156
|
+
| Feature | Description |
|
|
157
|
+
|---------|-------------|
|
|
158
|
+
| HTTP-only Cookies | Secure session management resistant to XSS attacks |
|
|
159
|
+
| JWT Tokens | Row-level security policy support for database operations |
|
|
160
|
+
| CSRF Protection | Built-in protection against cross-site request forgery |
|
|
161
|
+
| Flow-based Authentication | Secure, stateful authentication flows via Ory Kratos |
|
|
162
|
+
| Token Expiration | Automatic handling of invitation token expiration |
|
|
273
163
|
|
|
274
164
|
## Environment Support
|
|
275
165
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
166
|
+
| Environment | Status | Notes |
|
|
167
|
+
|-------------|--------|-------|
|
|
168
|
+
| Browser | ✅ | All modern browsers with CORS support |
|
|
169
|
+
| Node.js | ✅ | Version 16+ required |
|
|
170
|
+
| React/Vue/Angular | ✅ | Framework agnostic |
|
|
171
|
+
| TypeScript | ✅ | Full type definitions included |
|
|
172
|
+
| ESM/CJS | ✅ | Both module formats supported |
|
|
173
|
+
| Edge Runtime | ✅ | Vercel Edge, Cloudflare Workers compatible |
|
|
282
174
|
|
|
283
175
|
## Related Packages
|
|
284
176
|
|
|
285
|
-
- [
|
|
286
|
-
- [
|
|
177
|
+
- **[@omnibase/sdk-nextjs](https://www.npmjs.com/package/@omnibase/sdk-nextjs)** - Next.js optimized SDK with middleware and server components
|
|
178
|
+
- **[@omnibase/sdk-shadcn](https://www.npmjs.com/package/@omnibase/sdk-shadcn)** - Pre-built UI components with shadcn/ui integration
|
|
287
179
|
|
|
288
180
|
## Architecture
|
|
289
181
|
|
|
290
|
-
The SDK is built around three core
|
|
182
|
+
The SDK is built around three core concepts:
|
|
291
183
|
|
|
292
184
|
1. **Authentication Flows** - Comprehensive Ory Kratos integration handling all user authentication states and transitions
|
|
293
185
|
2. **Multi-tenant Context** - Complete organizational boundary management with billing integration and user access control
|
|
294
186
|
3. **Database Integration** - Direct Supabase PostgREST access for advanced queries and data operations
|
|
295
187
|
|
|
296
|
-
Each module
|
|
297
|
-
|
|
298
|
-
##
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
##
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
- [LogoutFlow](type-aliases/LogoutFlow.md)
|
|
306
|
-
- [LoginFlow](type-aliases/LoginFlow.md)
|
|
307
|
-
- [RecoveryFlow](type-aliases/RecoveryFlow.md)
|
|
308
|
-
- [VerificationFlow](type-aliases/VerificationFlow.md)
|
|
309
|
-
- [RegistrationFlow](type-aliases/RegistrationFlow.md)
|
|
310
|
-
- [SettingsFlow](type-aliases/SettingsFlow.md)
|
|
311
|
-
- [Session](type-aliases/Session.md)
|
|
312
|
-
- [AcceptTenantInviteRequest](type-aliases/AcceptTenantInviteRequest.md)
|
|
313
|
-
- [AcceptTenantInviteResponse](type-aliases/AcceptTenantInviteResponse.md)
|
|
314
|
-
- [CreateTenantUserInviteResponse](type-aliases/CreateTenantUserInviteResponse.md)
|
|
315
|
-
- [CreateTenantUserInviteRequest](type-aliases/CreateTenantUserInviteRequest.md)
|
|
316
|
-
- [CreateTenantResponse](type-aliases/CreateTenantResponse.md)
|
|
317
|
-
- [Tenant](type-aliases/Tenant.md)
|
|
318
|
-
- [CreateTenantRequest](type-aliases/CreateTenantRequest.md)
|
|
319
|
-
- [DeleteTenantResponse](type-aliases/DeleteTenantResponse.md)
|
|
320
|
-
- [SwitchActiveTenantResponse](type-aliases/SwitchActiveTenantResponse.md)
|
|
321
|
-
- [ApiResponse](type-aliases/ApiResponse.md)
|
|
322
|
-
|
|
323
|
-
## Functions
|
|
324
|
-
|
|
325
|
-
- [createClient](functions/createClient.md)
|
|
326
|
-
- [acceptTenantInvite](functions/acceptTenantInvite.md)
|
|
327
|
-
- [createTenantUserInvite](functions/createTenantUserInvite.md)
|
|
328
|
-
- [createTenant](functions/createTenant.md)
|
|
329
|
-
- [deleteTenant](functions/deleteTenant.md)
|
|
330
|
-
- [switchActiveTenant](functions/switchActiveTenant.md)
|
|
188
|
+
Each module works independently or together, allowing you to use only what you need. The SDK maintains consistency across all operations with standardized response types and error handling patterns.
|
|
189
|
+
|
|
190
|
+
## API Reference
|
|
191
|
+
|
|
192
|
+
For detailed API documentation including all types, interfaces, and functions, visit the [full API reference](https://docs.omnibase.dev).
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT
|