@teamvortexsoftware/vortex-nextjs-15-sdk 0.0.6 → 0.0.7
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 +66 -19
- package/dist/actions/autojoin.d.ts +52 -0
- package/dist/actions/autojoin.d.ts.map +1 -0
- package/dist/actions/autojoin.js +135 -0
- package/dist/config.d.ts +7 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/handlers/jwt.d.ts.map +1 -1
- package/dist/handlers/jwt.js +27 -8
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@ lib/
|
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
Each route file is just 3 lines:
|
|
40
|
+
|
|
40
41
|
```typescript
|
|
41
42
|
import '@/lib/vortex-config';
|
|
42
43
|
import { createVortexRoutes } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
|
|
@@ -47,13 +48,17 @@ export const { GET, DELETE } = createVortexRoutes().invitation;
|
|
|
47
48
|
## ⚙️ Configuration
|
|
48
49
|
|
|
49
50
|
### 1. Environment Variables
|
|
51
|
+
|
|
50
52
|
Add to your `.env.local`:
|
|
53
|
+
|
|
51
54
|
```bash
|
|
52
55
|
VORTEX_API_KEY=your_api_key_here
|
|
53
56
|
```
|
|
54
57
|
|
|
55
58
|
### 2. App Layout
|
|
59
|
+
|
|
56
60
|
Import the config in your `app/layout.tsx`:
|
|
61
|
+
|
|
57
62
|
```typescript
|
|
58
63
|
import '../lib/vortex-config'; // Add this line
|
|
59
64
|
|
|
@@ -71,22 +76,30 @@ export default function RootLayout({ children }) {
|
|
|
71
76
|
```
|
|
72
77
|
|
|
73
78
|
### 3. Customize Configuration
|
|
79
|
+
|
|
74
80
|
Edit `lib/vortex-config.ts` to implement your authentication and access control:
|
|
75
81
|
|
|
82
|
+
#### New Format (Recommended)
|
|
83
|
+
|
|
76
84
|
```typescript
|
|
77
|
-
import {
|
|
85
|
+
import {
|
|
86
|
+
configureVortexLazy,
|
|
87
|
+
createAllowAllAccessControl,
|
|
88
|
+
} from '@teamvortexsoftware/vortex-nextjs-15-sdk';
|
|
78
89
|
|
|
79
90
|
configureVortexLazy(async () => ({
|
|
80
91
|
apiKey: process.env.VORTEX_API_KEY!,
|
|
81
92
|
|
|
82
|
-
// Required: How to authenticate users
|
|
93
|
+
// Required: How to authenticate users (new format)
|
|
83
94
|
authenticateUser: async (request) => {
|
|
84
95
|
const user = await getCurrentUser(request); // Your auth logic
|
|
85
|
-
return user
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
return user
|
|
97
|
+
? {
|
|
98
|
+
userId: user.id,
|
|
99
|
+
userEmail: user.email,
|
|
100
|
+
adminScopes: user.isAdmin ? ['autojoin'] : [], // Optional: grant admin capabilities
|
|
101
|
+
}
|
|
102
|
+
: null;
|
|
90
103
|
},
|
|
91
104
|
|
|
92
105
|
// Simple: Allow all operations (customize for production)
|
|
@@ -94,6 +107,31 @@ configureVortexLazy(async () => ({
|
|
|
94
107
|
}));
|
|
95
108
|
```
|
|
96
109
|
|
|
110
|
+
#### Legacy Format (Deprecated)
|
|
111
|
+
|
|
112
|
+
The legacy format is still supported for backward compatibility:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
configureVortexLazy(async () => ({
|
|
116
|
+
apiKey: process.env.VORTEX_API_KEY!,
|
|
117
|
+
|
|
118
|
+
// Legacy format (deprecated)
|
|
119
|
+
authenticateUser: async (request) => {
|
|
120
|
+
const user = await getCurrentUser(request);
|
|
121
|
+
return user
|
|
122
|
+
? {
|
|
123
|
+
userId: user.id,
|
|
124
|
+
identifiers: [{ type: 'email', value: user.email }],
|
|
125
|
+
groups: user.groups, // [{ type: 'team', groupId: '123', name: 'My Team' }]
|
|
126
|
+
role: user.role,
|
|
127
|
+
}
|
|
128
|
+
: null;
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
...createAllowAllAccessControl(),
|
|
132
|
+
}));
|
|
133
|
+
```
|
|
134
|
+
|
|
97
135
|
## 🔧 Production Security
|
|
98
136
|
|
|
99
137
|
For production apps, replace `createAllowAllAccessControl()` with proper authorization:
|
|
@@ -101,7 +139,9 @@ For production apps, replace `createAllowAllAccessControl()` with proper authori
|
|
|
101
139
|
```typescript
|
|
102
140
|
configureVortexLazy(async () => ({
|
|
103
141
|
apiKey: process.env.VORTEX_API_KEY!,
|
|
104
|
-
authenticateUser: async (request) => {
|
|
142
|
+
authenticateUser: async (request) => {
|
|
143
|
+
/* your auth */
|
|
144
|
+
},
|
|
105
145
|
|
|
106
146
|
// Custom access control
|
|
107
147
|
canDeleteInvitation: async (request, user, resource) => {
|
|
@@ -109,8 +149,8 @@ configureVortexLazy(async () => ({
|
|
|
109
149
|
},
|
|
110
150
|
|
|
111
151
|
canAccessInvitationsByGroup: async (request, user, resource) => {
|
|
112
|
-
return user?.groups.some(
|
|
113
|
-
g.type === resource?.groupType && g.groupId === resource?.groupId
|
|
152
|
+
return user?.groups.some(
|
|
153
|
+
(g) => g.type === resource?.groupType && g.groupId === resource?.groupId
|
|
114
154
|
);
|
|
115
155
|
},
|
|
116
156
|
|
|
@@ -122,18 +162,19 @@ configureVortexLazy(async () => ({
|
|
|
122
162
|
|
|
123
163
|
Your app automatically gets these API routes:
|
|
124
164
|
|
|
125
|
-
| Endpoint
|
|
126
|
-
|
|
127
|
-
| `/api/vortex/jwt`
|
|
128
|
-
| `/api/vortex/invitations`
|
|
129
|
-
| `/api/vortex/invitations/accept`
|
|
130
|
-
| `/api/vortex/invitations/[id]`
|
|
131
|
-
| `/api/vortex/invitations/[id]/reinvite`
|
|
132
|
-
| `/api/vortex/invitations/by-group/[type]/[id]` | GET/DELETE | Group-based operations
|
|
165
|
+
| Endpoint | Method | Description |
|
|
166
|
+
| ---------------------------------------------- | ---------- | --------------------------------------- |
|
|
167
|
+
| `/api/vortex/jwt` | POST | Generate JWT for authenticated user |
|
|
168
|
+
| `/api/vortex/invitations` | GET | Get invitations by target (email/phone) |
|
|
169
|
+
| `/api/vortex/invitations/accept` | POST | Accept multiple invitations |
|
|
170
|
+
| `/api/vortex/invitations/[id]` | GET/DELETE | Get or delete specific invitation |
|
|
171
|
+
| `/api/vortex/invitations/[id]/reinvite` | POST | Resend invitation |
|
|
172
|
+
| `/api/vortex/invitations/by-group/[type]/[id]` | GET/DELETE | Group-based operations |
|
|
133
173
|
|
|
134
174
|
## 🎯 Common Use Cases
|
|
135
175
|
|
|
136
176
|
### Frontend: Get User's JWT
|
|
177
|
+
|
|
137
178
|
```typescript
|
|
138
179
|
import { useVortexJWT } from '@teamvortexsoftware/vortex-react-provider';
|
|
139
180
|
|
|
@@ -148,6 +189,7 @@ function MyComponent() {
|
|
|
148
189
|
```
|
|
149
190
|
|
|
150
191
|
### Frontend: Manage Invitations
|
|
192
|
+
|
|
151
193
|
```typescript
|
|
152
194
|
const { data: invitations } = useFetch('/api/vortex/invitations/by-group/team/my-team-id');
|
|
153
195
|
|
|
@@ -156,6 +198,7 @@ await fetch(`/api/vortex/invitations/${invitationId}`, { method: 'DELETE' });
|
|
|
156
198
|
```
|
|
157
199
|
|
|
158
200
|
### Backend: Direct SDK Usage
|
|
201
|
+
|
|
159
202
|
```typescript
|
|
160
203
|
import { Vortex } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
|
|
161
204
|
|
|
@@ -188,17 +231,21 @@ export async function GET(request: NextRequest) {
|
|
|
188
231
|
## 🆘 Troubleshooting
|
|
189
232
|
|
|
190
233
|
### Build Errors
|
|
234
|
+
|
|
191
235
|
If you see configuration errors during build:
|
|
236
|
+
|
|
192
237
|
- Make sure you're importing `'@/lib/vortex-config'` (or `'../lib/vortex-config'`) in your layout
|
|
193
238
|
- Check that your `.env.local` has `VORTEX_API_KEY`
|
|
194
239
|
- Ensure you're using lazy initialization (`configureVortexLazy`)
|
|
195
240
|
|
|
196
241
|
### Authentication Issues
|
|
242
|
+
|
|
197
243
|
- Verify your `authenticateUser` function returns the correct format
|
|
198
244
|
- Check that your authentication provider is working
|
|
199
245
|
- Make sure JWT requests include authentication cookies/headers
|
|
200
246
|
|
|
201
247
|
### TypeScript Errors
|
|
248
|
+
|
|
202
249
|
- All types are exported from the main package
|
|
203
250
|
- Resource parameters are fully typed for access control hooks
|
|
204
251
|
- Use the generated configuration template as a starting point
|
|
@@ -221,4 +268,4 @@ This SDK re-exports everything from `@teamvortexsoftware/vortex-node-22-sdk`, so
|
|
|
221
268
|
|
|
222
269
|
---
|
|
223
270
|
|
|
224
|
-
**Need help?** Open an issue or check the example implementation in `apps/demo-react
|
|
271
|
+
**Need help?** Open an issue or check the example implementation in `apps/demo-react`
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AutojoinDomainsResponse, ConfigureAutojoinRequest } from '@teamvortexsoftware/vortex-node-22-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Get autojoin domains configured for a specific scope
|
|
4
|
+
*
|
|
5
|
+
* This Server Action fetches the current autojoin domain configuration
|
|
6
|
+
* for an organization, team, or other scope type.
|
|
7
|
+
*
|
|
8
|
+
* @param scopeType - The type of scope (e.g., "organization", "team", "project")
|
|
9
|
+
* @param scope - The scope identifier (customer's group ID)
|
|
10
|
+
* @returns Autojoin domains and associated invitation
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { getAutojoinDomains } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
|
|
15
|
+
*
|
|
16
|
+
* // In a Server Component or Client Component
|
|
17
|
+
* const result = await getAutojoinDomains('organization', 'acme-org');
|
|
18
|
+
* console.log(result.autojoinDomains);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function getAutojoinDomains(scopeType: string, scope: string): Promise<AutojoinDomainsResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Configure autojoin domains for a specific scope
|
|
24
|
+
*
|
|
25
|
+
* This Server Action syncs autojoin domains - it will add new domains,
|
|
26
|
+
* remove domains not in the provided list, and deactivate the autojoin
|
|
27
|
+
* invitation if all domains are removed (empty array).
|
|
28
|
+
*
|
|
29
|
+
* @param params - Configuration parameters
|
|
30
|
+
* @param params.scope - The scope identifier (customer's group ID)
|
|
31
|
+
* @param params.scopeType - The type of scope (e.g., "organization", "team")
|
|
32
|
+
* @param params.scopeName - Optional display name for the scope
|
|
33
|
+
* @param params.domains - Array of domains to configure for autojoin
|
|
34
|
+
* @param params.widgetId - The widget configuration ID
|
|
35
|
+
* @returns Updated autojoin domains and associated invitation
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { configureAutojoin } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
|
|
40
|
+
*
|
|
41
|
+
* // In a Server Action or Client Component
|
|
42
|
+
* const result = await configureAutojoin({
|
|
43
|
+
* scope: 'acme-org',
|
|
44
|
+
* scopeType: 'organization',
|
|
45
|
+
* scopeName: 'Acme Corporation',
|
|
46
|
+
* domains: ['acme.com', 'acme.org'],
|
|
47
|
+
* widgetId: 'widget-123',
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function configureAutojoin(params: ConfigureAutojoinRequest): Promise<AutojoinDomainsResponse>;
|
|
52
|
+
//# sourceMappingURL=autojoin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autojoin.d.ts","sourceRoot":"","sources":["../../src/actions/autojoin.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,wCAAwC,CAAC;AAGhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,uBAAuB,CAAC,CASlC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CAoBlC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use server';
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
14
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.getAutojoinDomains = getAutojoinDomains;
|
|
41
|
+
exports.configureAutojoin = configureAutojoin;
|
|
42
|
+
var vortex_node_22_sdk_1 = require("@teamvortexsoftware/vortex-node-22-sdk");
|
|
43
|
+
var config_1 = require("../config");
|
|
44
|
+
/**
|
|
45
|
+
* Get autojoin domains configured for a specific scope
|
|
46
|
+
*
|
|
47
|
+
* This Server Action fetches the current autojoin domain configuration
|
|
48
|
+
* for an organization, team, or other scope type.
|
|
49
|
+
*
|
|
50
|
+
* @param scopeType - The type of scope (e.g., "organization", "team", "project")
|
|
51
|
+
* @param scope - The scope identifier (customer's group ID)
|
|
52
|
+
* @returns Autojoin domains and associated invitation
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* import { getAutojoinDomains } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
|
|
57
|
+
*
|
|
58
|
+
* // In a Server Component or Client Component
|
|
59
|
+
* const result = await getAutojoinDomains('organization', 'acme-org');
|
|
60
|
+
* console.log(result.autojoinDomains);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
function getAutojoinDomains(scopeType, scope) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var config, vortex;
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0: return [4 /*yield*/, (0, config_1.getVortexConfig)()];
|
|
69
|
+
case 1:
|
|
70
|
+
config = _a.sent();
|
|
71
|
+
if (!config.apiKey) {
|
|
72
|
+
throw new Error('Vortex API key not configured');
|
|
73
|
+
}
|
|
74
|
+
vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
|
|
75
|
+
return [2 /*return*/, vortex.getAutojoinDomains(scopeType, scope)];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Configure autojoin domains for a specific scope
|
|
82
|
+
*
|
|
83
|
+
* This Server Action syncs autojoin domains - it will add new domains,
|
|
84
|
+
* remove domains not in the provided list, and deactivate the autojoin
|
|
85
|
+
* invitation if all domains are removed (empty array).
|
|
86
|
+
*
|
|
87
|
+
* @param params - Configuration parameters
|
|
88
|
+
* @param params.scope - The scope identifier (customer's group ID)
|
|
89
|
+
* @param params.scopeType - The type of scope (e.g., "organization", "team")
|
|
90
|
+
* @param params.scopeName - Optional display name for the scope
|
|
91
|
+
* @param params.domains - Array of domains to configure for autojoin
|
|
92
|
+
* @param params.widgetId - The widget configuration ID
|
|
93
|
+
* @returns Updated autojoin domains and associated invitation
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* import { configureAutojoin } from '@teamvortexsoftware/vortex-nextjs-15-sdk';
|
|
98
|
+
*
|
|
99
|
+
* // In a Server Action or Client Component
|
|
100
|
+
* const result = await configureAutojoin({
|
|
101
|
+
* scope: 'acme-org',
|
|
102
|
+
* scopeType: 'organization',
|
|
103
|
+
* scopeName: 'Acme Corporation',
|
|
104
|
+
* domains: ['acme.com', 'acme.org'],
|
|
105
|
+
* widgetId: 'widget-123',
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
function configureAutojoin(params) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
var config, vortex;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0: return [4 /*yield*/, (0, config_1.getVortexConfig)()];
|
|
115
|
+
case 1:
|
|
116
|
+
config = _a.sent();
|
|
117
|
+
if (!config.apiKey) {
|
|
118
|
+
throw new Error('Vortex API key not configured');
|
|
119
|
+
}
|
|
120
|
+
// Validate required fields
|
|
121
|
+
if (!params.scope || !params.scopeType) {
|
|
122
|
+
throw new Error('scope and scopeType are required');
|
|
123
|
+
}
|
|
124
|
+
if (!params.domains) {
|
|
125
|
+
throw new Error('domains array is required');
|
|
126
|
+
}
|
|
127
|
+
if (!params.widgetId) {
|
|
128
|
+
throw new Error('widgetId is required');
|
|
129
|
+
}
|
|
130
|
+
vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
|
|
131
|
+
return [2 /*return*/, vortex.configureAutojoin(params)];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server';
|
|
2
2
|
export interface AuthenticatedUser {
|
|
3
3
|
userId: string;
|
|
4
|
-
|
|
4
|
+
userEmail?: string;
|
|
5
|
+
adminScopes?: string[];
|
|
6
|
+
identifiers?: {
|
|
5
7
|
type: 'email' | 'sms';
|
|
6
8
|
value: string;
|
|
7
9
|
}[];
|
|
8
|
-
groups
|
|
10
|
+
groups?: {
|
|
9
11
|
type: string;
|
|
10
12
|
id?: string;
|
|
11
13
|
groupId?: string;
|
|
@@ -40,9 +42,9 @@ export interface GroupAccessHook extends AccessControlHook<GroupResource> {
|
|
|
40
42
|
export interface BasicAccessHook extends AccessControlHook<void> {
|
|
41
43
|
}
|
|
42
44
|
export interface JwtContext {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
componentId?: string;
|
|
46
|
+
scope?: string;
|
|
47
|
+
scopeType?: string;
|
|
46
48
|
}
|
|
47
49
|
export interface VortexConfig {
|
|
48
50
|
apiKey: string;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE;QAAE,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/handlers/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1C,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/handlers/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1C,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,WAAW,wDAuF7D"}
|
package/dist/handlers/jwt.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -42,7 +53,7 @@ var config_1 = require("../config");
|
|
|
42
53
|
var utils_1 = require("../utils");
|
|
43
54
|
function handleJwtGeneration(request) {
|
|
44
55
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var config, authenticatedUser, context, body, err_1, attributes, vortex, jwt, error_1, message;
|
|
56
|
+
var config, authenticatedUser, context, body, err_1, attributes, vortex, jwtParams, jwt, error_1, message;
|
|
46
57
|
var _a;
|
|
47
58
|
return __generator(this, function (_b) {
|
|
48
59
|
switch (_b.label) {
|
|
@@ -104,13 +115,21 @@ function handleJwtGeneration(request) {
|
|
|
104
115
|
_b.label = 9;
|
|
105
116
|
case 9:
|
|
106
117
|
vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
// Validate required fields
|
|
119
|
+
if (!authenticatedUser.userId || !authenticatedUser.userEmail) {
|
|
120
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Invalid user format: must provide userId and userEmail', 500)];
|
|
121
|
+
}
|
|
122
|
+
jwtParams = {
|
|
123
|
+
user: __assign({ id: authenticatedUser.userId, email: authenticatedUser.userEmail }, (authenticatedUser.adminScopes && authenticatedUser.adminScopes.length > 0 && {
|
|
124
|
+
adminScopes: authenticatedUser.adminScopes
|
|
125
|
+
})),
|
|
126
|
+
};
|
|
127
|
+
// Add attributes if present
|
|
128
|
+
if (attributes && Object.keys(attributes).length > 0) {
|
|
129
|
+
jwtParams.attributes = attributes;
|
|
130
|
+
}
|
|
131
|
+
jwt = vortex.generateJwt(jwtParams);
|
|
132
|
+
console.log('[handleJwtGeneration] Generated JWT with new format');
|
|
114
133
|
console.log('[handleJwtGeneration] Generated JWT - attributes included:', {
|
|
115
134
|
hasAttributes: !!attributes && Object.keys(attributes).length > 0,
|
|
116
135
|
jwtLength: jwt.length,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { configureVortex, configureVortexAsync, configureVortexLazy, getVortexConfig, authenticateRequest, createAllowAllAccessControl } from './config';
|
|
1
|
+
export { configureVortex, configureVortexAsync, configureVortexLazy, getVortexConfig, authenticateRequest, createAllowAllAccessControl, } from './config';
|
|
2
2
|
export type { VortexConfig, AuthenticatedUser, AccessControlHook, InvitationResource, InvitationTargetResource, GroupResource, InvitationAccessHook, InvitationTargetAccessHook, GroupAccessHook, BasicAccessHook, JwtContext, } from './config';
|
|
3
3
|
export { createVortexJwtRoute, createVortexInvitationsRoute, createVortexInvitationRoute, createVortexInvitationsAcceptRoute, createVortexInvitationsByGroupRoute, createVortexReinviteRoute, createVortexRoutes, VORTEX_ROUTES, NEXTJS_FILE_STRUCTURE, createVortexApiPath, } from './routes';
|
|
4
|
-
export { handleJwtGeneration
|
|
4
|
+
export { handleJwtGeneration } from './handlers/jwt';
|
|
5
5
|
export { handleGetInvitationsByTarget, handleGetInvitation, handleRevokeInvitation, handleAcceptInvitations, handleGetInvitationsByGroup, handleDeleteInvitationsByGroup, handleReinvite, } from './handlers/invitations';
|
|
6
6
|
export { createApiResponse, createErrorResponse, parseRequestBody, getQueryParam, validateRequiredFields, sanitizeInput, } from './utils';
|
|
7
|
+
export { getAutojoinDomains, configureAutojoin } from './actions/autojoin';
|
|
7
8
|
export * from '@teamvortexsoftware/vortex-node-22-sdk';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,aAAa,EACb,oBAAoB,EACpB,0BAA0B,EAC1B,eAAe,EACf,eAAe,EACf,UAAU,GACX,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,2BAA2B,EAC3B,kCAAkC,EAClC,mCAAmC,EACnC,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,2BAA2B,EAC3B,8BAA8B,EAC9B,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,aAAa,GACd,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE3E,cAAc,wCAAwC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.sanitizeInput = exports.validateRequiredFields = exports.getQueryParam = exports.parseRequestBody = exports.createErrorResponse = exports.createApiResponse = exports.handleReinvite = exports.handleDeleteInvitationsByGroup = exports.handleGetInvitationsByGroup = exports.handleAcceptInvitations = exports.handleRevokeInvitation = exports.handleGetInvitation = exports.handleGetInvitationsByTarget = exports.handleJwtGeneration = exports.createVortexApiPath = exports.NEXTJS_FILE_STRUCTURE = exports.VORTEX_ROUTES = exports.createVortexRoutes = exports.createVortexReinviteRoute = exports.createVortexInvitationsByGroupRoute = exports.createVortexInvitationsAcceptRoute = exports.createVortexInvitationRoute = exports.createVortexInvitationsRoute = exports.createVortexJwtRoute = exports.createAllowAllAccessControl = exports.authenticateRequest = exports.getVortexConfig = exports.configureVortexLazy = exports.configureVortexAsync = exports.configureVortex = void 0;
|
|
17
|
+
exports.configureAutojoin = exports.getAutojoinDomains = exports.sanitizeInput = exports.validateRequiredFields = exports.getQueryParam = exports.parseRequestBody = exports.createErrorResponse = exports.createApiResponse = exports.handleReinvite = exports.handleDeleteInvitationsByGroup = exports.handleGetInvitationsByGroup = exports.handleAcceptInvitations = exports.handleRevokeInvitation = exports.handleGetInvitation = exports.handleGetInvitationsByTarget = exports.handleJwtGeneration = exports.createVortexApiPath = exports.NEXTJS_FILE_STRUCTURE = exports.VORTEX_ROUTES = exports.createVortexRoutes = exports.createVortexReinviteRoute = exports.createVortexInvitationsByGroupRoute = exports.createVortexInvitationsAcceptRoute = exports.createVortexInvitationRoute = exports.createVortexInvitationsRoute = exports.createVortexJwtRoute = exports.createAllowAllAccessControl = exports.authenticateRequest = exports.getVortexConfig = exports.configureVortexLazy = exports.configureVortexAsync = exports.configureVortex = void 0;
|
|
18
18
|
var config_1 = require("./config");
|
|
19
19
|
Object.defineProperty(exports, "configureVortex", { enumerable: true, get: function () { return config_1.configureVortex; } });
|
|
20
20
|
Object.defineProperty(exports, "configureVortexAsync", { enumerable: true, get: function () { return config_1.configureVortexAsync; } });
|
|
@@ -50,4 +50,8 @@ Object.defineProperty(exports, "parseRequestBody", { enumerable: true, get: func
|
|
|
50
50
|
Object.defineProperty(exports, "getQueryParam", { enumerable: true, get: function () { return utils_1.getQueryParam; } });
|
|
51
51
|
Object.defineProperty(exports, "validateRequiredFields", { enumerable: true, get: function () { return utils_1.validateRequiredFields; } });
|
|
52
52
|
Object.defineProperty(exports, "sanitizeInput", { enumerable: true, get: function () { return utils_1.sanitizeInput; } });
|
|
53
|
+
// Server Actions for admin operations (autojoin)
|
|
54
|
+
var autojoin_1 = require("./actions/autojoin");
|
|
55
|
+
Object.defineProperty(exports, "getAutojoinDomains", { enumerable: true, get: function () { return autojoin_1.getAutojoinDomains; } });
|
|
56
|
+
Object.defineProperty(exports, "configureAutojoin", { enumerable: true, get: function () { return autojoin_1.configureAutojoin; } });
|
|
53
57
|
__exportStar(require("@teamvortexsoftware/vortex-node-22-sdk"), exports);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@teamvortexsoftware/vortex-nextjs-15-sdk",
|
|
3
3
|
"description": "Drop-in Next.js module for Vortex API integration",
|
|
4
4
|
"author": "@teamvortexsoftware",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.7",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"bin/"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
|
-
"build:stg": "pnpm run distclean &&
|
|
23
|
+
"build:stg": "pnpm run distclean && turbo run build --filter=@teamvortexsoftware/vortex-nextjs-15-sdk && mkdir -p dist.d/stg && mv dist dist.d/stg && echo && echo 'Build in ./dist.d/stg'",
|
|
24
24
|
"prepublish:stg": "cp ./LICENSE ./README.md ./dist.d/stg/ && cp -r ./bin ./dist.d/stg/ && NODE_SDK_VERSION=$(jq -r '.version' ../vortex-node-22-sdk/package.json) && jq --arg nodeVer \"^$NODE_SDK_VERSION\" '.name = \"@teamvortexsoftware/vortex-nextjs-15-sdk-stg\" | .description = \"Vortex NextJS 15 SDK (STG)\" | del(.devDependencies.\"@teamvortexsoftware/eslint-config\") | del(.devDependencies.\"@teamvortexsoftware/typescript-config\") | .dependencies.\"@teamvortexsoftware/vortex-node-22-sdk\" = $nodeVer | del(.scripts.prepack)' ./package.json > ./dist.d/stg/package.json",
|
|
25
|
-
"publish:stg": "pnpm run prepublish:stg &&
|
|
26
|
-
"build:prod": "pnpm run distclean &&
|
|
25
|
+
"publish:stg": "pnpm run prepublish:stg && pnpm publish --access restricted ./dist.d/stg",
|
|
26
|
+
"build:prod": "pnpm run distclean && turbo run build --filter=@teamvortexsoftware/vortex-nextjs-15-sdk && mkdir -p dist.d/prod && mv dist dist.d/prod && echo && echo 'Build in ./dist.d/prod'",
|
|
27
27
|
"prepublish:prod": "cp ./LICENSE ./README.md ./dist.d/prod/ && cp -r ./bin ./dist.d/prod/ && NODE_SDK_VERSION=$(jq -r '.version' ../vortex-node-22-sdk/package.json) && jq --arg nodeVer \"^$NODE_SDK_VERSION\" 'del(.devDependencies.\"@teamvortexsoftware/eslint-config\") | del(.devDependencies.\"@teamvortexsoftware/typescript-config\") | .dependencies.\"@teamvortexsoftware/vortex-node-22-sdk\" = $nodeVer | del(.scripts.prepack)' ./package.json > ./dist.d/prod/package.json",
|
|
28
|
-
"publish:prod": "pnpm run prepublish:prod &&
|
|
28
|
+
"publish:prod": "pnpm run prepublish:prod && pnpm publish --access public ./dist.d/prod",
|
|
29
29
|
"check-types": "tsc --noEmit",
|
|
30
30
|
"distclean": "rm -rf ./dist ./dist.d",
|
|
31
31
|
"clean": "rm -rf ./dist",
|
|
32
|
-
"dev": "",
|
|
32
|
+
"dev": "tsc -b tsconfig.json --watch",
|
|
33
33
|
"test": "jest",
|
|
34
34
|
"package": "pnpm run build && cd dist/vortex-nextjs-15-sdk && npm pack",
|
|
35
|
-
"build": "
|
|
35
|
+
"build": "tsc -b tsconfig.json"
|
|
36
36
|
},
|
|
37
37
|
"jest": {
|
|
38
38
|
"rootDir": "__tests__",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
"testEnvironment": "node"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@eslint/js": "
|
|
50
|
+
"@eslint/js": "catalog:",
|
|
51
51
|
"@jest/globals": "29.7.0",
|
|
52
|
-
"
|
|
52
|
+
"@types/node": "catalog:",
|
|
53
|
+
"eslint": "catalog:",
|
|
53
54
|
"jest": "29.7.0",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"typescript": "^5.0.0"
|
|
55
|
+
"next": "^15.5.9",
|
|
56
|
+
"ts-jest": "catalog:",
|
|
57
|
+
"typescript-eslint": "catalog:"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@teamvortexsoftware/vortex-node-22-sdk": "^0.0
|
|
60
|
+
"@teamvortexsoftware/vortex-node-22-sdk": "^0.1.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"next": ">=13.0.0"
|