@teamvortexsoftware/vortex-fastify-5-sdk 0.0.2 → 0.0.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.
package/README.md CHANGED
@@ -12,22 +12,28 @@ npm install @teamvortexsoftware/vortex-fastify-5-sdk @teamvortexsoftware/vortex-
12
12
 
13
13
  ```typescript
14
14
  import Fastify from 'fastify';
15
- import { vortexPlugin, configureVortex, createAllowAllAccessControl } from '@teamvortexsoftware/vortex-fastify-5-sdk';
15
+ import {
16
+ vortexPlugin,
17
+ configureVortex,
18
+ createAllowAllAccessControl,
19
+ } from '@teamvortexsoftware/vortex-fastify-5-sdk';
16
20
 
17
21
  const fastify = Fastify();
18
22
 
19
- // Configure Vortex
23
+ // Configure Vortex with new simplified format (recommended)
20
24
  configureVortex({
21
25
  apiKey: process.env.VORTEX_API_KEY!,
22
26
 
23
- // Required: How to authenticate users
27
+ // Required: How to authenticate users (new simplified format)
24
28
  authenticateUser: async (request, reply) => {
25
29
  const user = await getCurrentUser(request); // Your auth logic
26
- return user ? {
27
- userId: user.id,
28
- identifiers: [{ type: 'email', value: user.email }],
29
- groups: user.groups, // [{ type: 'team', groupId: '123', name: 'My Team' }]
30
- } : null;
30
+ return user
31
+ ? {
32
+ userId: user.id,
33
+ userEmail: user.email,
34
+ adminScopes: user.isAdmin ? ['autojoin'] : [], // Optional: grant admin capabilities
35
+ }
36
+ : null;
31
37
  },
32
38
 
33
39
  // Simple: Allow all operations (customize for production)
@@ -55,14 +61,14 @@ That's it! Your Fastify app now has all Vortex API endpoints.
55
61
 
56
62
  Your app automatically gets these API routes:
57
63
 
58
- | Endpoint | Method | Description |
59
- |----------|--------|-------------|
60
- | `/api/vortex/jwt` | POST | Generate JWT for authenticated user |
61
- | `/api/vortex/invitations` | GET | Get invitations by target (email/phone) |
62
- | `/api/vortex/invitations/accept` | POST | Accept multiple invitations |
63
- | `/api/vortex/invitations/:id` | GET/DELETE | Get or delete specific invitation |
64
- | `/api/vortex/invitations/:id/reinvite` | POST | Resend invitation |
65
- | `/api/vortex/invitations/by-group/:type/:id` | GET/DELETE | Group-based operations |
64
+ | Endpoint | Method | Description |
65
+ | -------------------------------------------- | ---------- | --------------------------------------- |
66
+ | `/api/vortex/jwt` | POST | Generate JWT for authenticated user |
67
+ | `/api/vortex/invitations` | GET | Get invitations by target (email/phone) |
68
+ | `/api/vortex/invitations/accept` | POST | Accept multiple invitations |
69
+ | `/api/vortex/invitations/:id` | GET/DELETE | Get or delete specific invitation |
70
+ | `/api/vortex/invitations/:id/reinvite` | POST | Resend invitation |
71
+ | `/api/vortex/invitations/by-group/:type/:id` | GET/DELETE | Group-based operations |
66
72
 
67
73
  ## 🛠️ Setup Options
68
74
 
@@ -112,26 +118,34 @@ fastify.delete('/api/vortex/invitations/:invitationId', routes.invitation.delete
112
118
  ### 1. Environment Variables
113
119
 
114
120
  Add to your `.env`:
121
+
115
122
  ```bash
116
123
  VORTEX_API_KEY=your_api_key_here
117
124
  ```
118
125
 
119
126
  ### 2. Basic Configuration
120
127
 
128
+ #### New Simplified Format (Recommended)
129
+
121
130
  ```typescript
122
- import { configureVortex, createAllowAllAccessControl } from '@teamvortexsoftware/vortex-fastify-5-sdk';
131
+ import {
132
+ configureVortex,
133
+ createAllowAllAccessControl,
134
+ } from '@teamvortexsoftware/vortex-fastify-5-sdk';
123
135
 
124
136
  configureVortex({
125
137
  apiKey: process.env.VORTEX_API_KEY!,
126
138
 
127
- // Required: How to authenticate users
139
+ // Required: How to authenticate users (new simplified format)
128
140
  authenticateUser: async (request, reply) => {
129
141
  const user = await getCurrentUser(request); // Your auth logic
130
- return user ? {
131
- userId: user.id,
132
- identifiers: [{ type: 'email', value: user.email }],
133
- groups: user.groups, // [{ type: 'team', groupId: '123', name: 'My Team' }]
134
- } : null;
142
+ return user
143
+ ? {
144
+ userId: user.id,
145
+ userEmail: user.email,
146
+ adminScopes: user.isAdmin ? ['autojoin'] : [], // Optional: grant admin capabilities
147
+ }
148
+ : null;
135
149
  },
136
150
 
137
151
  // Simple: Allow all operations (customize for production)
@@ -139,6 +153,30 @@ configureVortex({
139
153
  });
140
154
  ```
141
155
 
156
+ #### Legacy Format (Deprecated)
157
+
158
+ The legacy format is still supported for backward compatibility:
159
+
160
+ ```typescript
161
+ configureVortex({
162
+ apiKey: process.env.VORTEX_API_KEY!,
163
+
164
+ authenticateUser: async (request, reply) => {
165
+ const user = await getCurrentUser(request);
166
+ return user
167
+ ? {
168
+ userId: user.id,
169
+ identifiers: [{ type: 'email', value: user.email }],
170
+ groups: user.groups, // [{ type: 'team', groupId: '123', name: 'My Team' }]
171
+ role: user.role, // Optional
172
+ }
173
+ : null;
174
+ },
175
+
176
+ ...createAllowAllAccessControl(),
177
+ });
178
+ ```
179
+
142
180
  ### 3. Lazy Configuration (Advanced)
143
181
 
144
182
  Use this if your configuration depends on database connections or other async setup:
@@ -152,11 +190,13 @@ configureVortexLazy(async () => ({
152
190
  authenticateUser: async (request, reply) => {
153
191
  // This can make database calls, etc.
154
192
  const user = await getUserFromDatabase(request);
155
- return user ? {
156
- userId: user.id,
157
- identifiers: [{ type: 'email', value: user.email }],
158
- groups: await getUserGroups(user.id),
159
- } : null;
193
+ return user
194
+ ? {
195
+ userId: user.id,
196
+ userEmail: user.email,
197
+ adminScopes: (await checkUserAdminStatus(user.id)) ? ['autojoin'] : [],
198
+ }
199
+ : null;
160
200
  },
161
201
 
162
202
  ...createAllowAllAccessControl(),
@@ -170,7 +210,9 @@ For production apps, replace `createAllowAllAccessControl()` with proper authori
170
210
  ```typescript
171
211
  configureVortex({
172
212
  apiKey: process.env.VORTEX_API_KEY!,
173
- authenticateUser: async (request, reply) => { /* your auth */ },
213
+ authenticateUser: async (request, reply) => {
214
+ /* your auth */
215
+ },
174
216
 
175
217
  // Custom access control
176
218
  canDeleteInvitation: async (request, reply, user, resource) => {
@@ -178,8 +220,8 @@ configureVortex({
178
220
  },
179
221
 
180
222
  canAccessInvitationsByGroup: async (request, reply, user, resource) => {
181
- return user?.groups.some(g =>
182
- g.type === resource?.groupType && g.groupId === resource?.groupId
223
+ return user?.groups.some(
224
+ (g) => g.type === resource?.groupType && g.groupId === resource?.groupId
183
225
  );
184
226
  },
185
227
 
@@ -233,12 +275,13 @@ await fetch(`/api/vortex/invitations/${invitationId}`, { method: 'DELETE' });
233
275
  ## 🚀 Fastify-Specific Features
234
276
 
235
277
  ### Plugin Architecture
278
+
236
279
  The Fastify SDK leverages Fastify's native plugin system for optimal performance and encapsulation:
237
280
 
238
281
  ```typescript
239
282
  // Clean plugin registration
240
283
  await fastify.register(vortexPlugin, {
241
- prefix: '/api/vortex'
284
+ prefix: '/api/vortex',
242
285
  });
243
286
 
244
287
  // Or with encapsulation
@@ -251,6 +294,7 @@ await fastify.register(async function (fastify) {
251
294
  ```
252
295
 
253
296
  ### Performance Benefits
297
+
254
298
  - **Native Fastify Integration**: Uses FastifyRequest and FastifyReply directly
255
299
  - **Automatic JSON Parsing**: Body parsing handled by Fastify automatically
256
300
  - **Optimized Routing**: Leverages Fastify's high-performance router
@@ -258,14 +302,14 @@ await fastify.register(async function (fastify) {
258
302
 
259
303
  ## 🔄 Comparison with Other SDKs
260
304
 
261
- | Feature | Fastify SDK | Express SDK | Next.js SDK |
262
- |---------|-------------|-------------|-------------|
263
- | **Setup** | `fastify.register(vortexPlugin)` | `app.use(createVortexRouter())` | Multiple route files |
264
- | **Architecture** | Plugin-based | Middleware-based | File-based routing |
265
- | **Performance** | High (Fastify native) | Good | Good |
266
- | **Config** | Same API | Same API | Same API |
267
- | **Access Control** | Same API | Same API | Same API |
268
- | **Frontend Integration** | Same React Provider | Same React Provider | Same React Provider |
305
+ | Feature | Fastify SDK | Express SDK | Next.js SDK |
306
+ | ------------------------ | -------------------------------- | ------------------------------- | -------------------- |
307
+ | **Setup** | `fastify.register(vortexPlugin)` | `app.use(createVortexRouter())` | Multiple route files |
308
+ | **Architecture** | Plugin-based | Middleware-based | File-based routing |
309
+ | **Performance** | High (Fastify native) | Good | Good |
310
+ | **Config** | Same API | Same API | Same API |
311
+ | **Access Control** | Same API | Same API | Same API |
312
+ | **Frontend Integration** | Same React Provider | Same React Provider | Same React Provider |
269
313
 
270
314
  ## 📦 Direct SDK Usage
271
315
 
@@ -312,19 +356,23 @@ fastify.get('/api/custom-invitation/:invitationId', async (request, reply) => {
312
356
  ### Common Issues
313
357
 
314
358
  **Configuration errors**
359
+
315
360
  - Ensure you're calling `configureVortex()` or `configureVortexLazy()` before registering the plugin
316
361
  - Check that your `.env` has `VORTEX_API_KEY`
317
362
 
318
363
  **Plugin registration issues**
364
+
319
365
  - Make sure you're using `await fastify.register(vortexPlugin)`
320
366
  - Verify the prefix doesn't conflict with other routes
321
367
 
322
368
  **Authentication Issues**
369
+
323
370
  - Verify your `authenticateUser` function returns the correct format
324
371
  - Check that your authentication middleware is working
325
372
  - Make sure JWT requests include authentication cookies/headers
326
373
 
327
374
  **TypeScript Errors**
375
+
328
376
  - All types are exported from the main package
329
377
  - Resource parameters are fully typed for access control hooks
330
378
 
@@ -348,4 +396,4 @@ This SDK re-exports everything from `@teamvortexsoftware/vortex-node-22-sdk`, so
348
396
 
349
397
  ---
350
398
 
351
- **Need help?** Open an issue or check the Express/Next.js SDK examples for reference patterns.
399
+ **Need help?** Open an issue or check the Express/Next.js SDK examples for reference patterns.
package/dist/config.d.ts CHANGED
@@ -1,17 +1,20 @@
1
1
  import { FastifyRequest, FastifyReply } from 'fastify';
2
2
  export interface AuthenticatedUser {
3
3
  userId: string;
4
- identifiers: {
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;
12
14
  name: string;
13
15
  }[];
14
16
  role?: string;
17
+ attributes?: Record<string, any>;
15
18
  }
16
19
  export interface InvitationResource {
17
20
  invitationId: string;
@@ -1 +1 @@
1
- {"version":3,"file":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OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,kBAgCrF"}
1
+ {"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/handlers/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAKvD,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,kBAgDrF"}
@@ -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, reply) {
44
55
  return __awaiter(this, void 0, void 0, function () {
45
- var config, authenticatedUser, vortex, jwt, error_1, message;
56
+ var config, authenticatedUser, vortex, jwtParams, jwt, error_1, message;
46
57
  return __generator(this, function (_a) {
47
58
  switch (_a.label) {
48
59
  case 0:
@@ -63,12 +74,20 @@ function handleJwtGeneration(request, reply) {
63
74
  return [2 /*return*/, (0, utils_1.createErrorResponse)(reply, 'Unauthorized', 401)];
64
75
  }
65
76
  vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
66
- jwt = vortex.generateJwt({
67
- userId: authenticatedUser.userId,
68
- identifiers: authenticatedUser.identifiers,
69
- groups: authenticatedUser.groups,
70
- role: authenticatedUser.role,
71
- });
77
+ // Validate required fields
78
+ if (!authenticatedUser.userId || !authenticatedUser.userEmail) {
79
+ return [2 /*return*/, (0, utils_1.createErrorResponse)(reply, 'Invalid user format: must provide userId and userEmail', 500)];
80
+ }
81
+ jwtParams = {
82
+ user: __assign({ id: authenticatedUser.userId, email: authenticatedUser.userEmail }, (authenticatedUser.adminScopes && authenticatedUser.adminScopes.length > 0 && {
83
+ adminScopes: authenticatedUser.adminScopes
84
+ })),
85
+ };
86
+ // Add attributes if present
87
+ if (authenticatedUser.attributes) {
88
+ jwtParams.attributes = authenticatedUser.attributes;
89
+ }
90
+ jwt = vortex.generateJwt(jwtParams);
72
91
  return [2 /*return*/, (0, utils_1.createApiResponse)(reply, { jwt: jwt })];
73
92
  case 3:
74
93
  error_1 = _a.sent();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@teamvortexsoftware/vortex-fastify-5-sdk",
3
3
  "description": "Drop-in Fastify module for Vortex API integration",
4
4
  "author": "@teamvortexsoftware",
5
- "version": "0.0.2",
5
+ "version": "0.0.5",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {
@@ -16,19 +16,19 @@
16
16
  "dist/"
17
17
  ],
18
18
  "scripts": {
19
- "build:stg": "pnpm run distclean && pnpm run build && mkdir -p dist.d/stg && mv dist dist.d/stg && echo && echo 'Build in ./dist.d/stg'",
19
+ "build:stg": "pnpm run distclean && turbo run build --filter=@teamvortexsoftware/vortex-fastify-5-sdk && mkdir -p dist.d/stg && mv dist dist.d/stg && echo && echo 'Build in ./dist.d/stg'",
20
20
  "prepublish:stg": "cp ./LICENSE ./README.md ./dist.d/stg/ && NODE_SDK_VERSION=$(jq -r '.version' ../vortex-node-22-sdk/package.json) && jq --arg nodeVer \"^$NODE_SDK_VERSION\" '.name = \"@teamvortexsoftware/vortex-fastify-5-sdk-stg\" | .description = \"Vortex Fastify 5 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",
21
- "publish:stg": "pnpm run prepublish:stg && npm publish --userconfig ../../.npmrc --access restricted ./dist.d/stg",
22
- "build:prod": "pnpm run distclean && pnpm run build && mkdir -p dist.d/prod && mv dist dist.d/prod && echo && echo 'Build in ./dist.d/prod'",
21
+ "publish:stg": "pnpm run prepublish:stg && pnpm publish --access restricted ./dist.d/stg",
22
+ "build:prod": "pnpm run distclean && turbo run build --filter=@teamvortexsoftware/vortex-fastify-5-sdk && mkdir -p dist.d/prod && mv dist dist.d/prod && echo && echo 'Build in ./dist.d/prod'",
23
23
  "prepublish:prod": "cp ./LICENSE ./README.md ./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",
24
- "publish:prod": "pnpm run prepublish:prod && npm publish --userconfig ../../.npmrc --access public ./dist.d/prod",
24
+ "publish:prod": "pnpm run prepublish:prod && pnpm publish --access public ./dist.d/prod",
25
25
  "check-types": "tsc --noEmit",
26
26
  "distclean": "rm -rf ./dist ./dist.d",
27
27
  "clean": "rm -rf ./dist",
28
28
  "dev": "",
29
29
  "test": "jest",
30
30
  "package": "pnpm run build && cd dist/vortex-fastify-5-sdk && npm pack",
31
- "build": "cd ../vortex-node-22-sdk && pnpm run build && cd ../vortex-fastify-5-sdk && tsc -b tsconfig.json"
31
+ "build": "tsc -b tsconfig.json"
32
32
  },
33
33
  "jest": {
34
34
  "rootDir": "__tests__",
@@ -43,17 +43,17 @@
43
43
  "testEnvironment": "node"
44
44
  },
45
45
  "devDependencies": {
46
- "@eslint/js": "^9.24.0",
46
+ "@eslint/js": "catalog:",
47
47
  "@jest/globals": "29.7.0",
48
- "eslint": "^9.24.0",
49
- "jest": "29.7.0",
50
- "typescript-eslint": "^8.30.1",
48
+ "@types/node": "catalog:",
49
+ "eslint": "catalog:",
51
50
  "fastify": "^5.1.0",
52
- "@types/node": "^20.0.0",
53
- "typescript": "^5.0.0"
51
+ "jest": "29.7.0",
52
+ "ts-jest": "catalog:",
53
+ "typescript-eslint": "catalog:"
54
54
  },
55
55
  "dependencies": {
56
- "@teamvortexsoftware/vortex-node-22-sdk": "^0.0.7"
56
+ "@teamvortexsoftware/vortex-node-22-sdk": "^0.1.1"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "fastify": ">=5.0.0"