@teamvortexsoftware/vortex-nextjs-15-sdk 0.0.1
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/LICENSE +201 -0
- package/README.md +454 -0
- package/dist/config.d.ts +33 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +107 -0
- package/dist/examples.d.ts +41 -0
- package/dist/examples.d.ts.map +1 -0
- package/dist/examples.js +50 -0
- package/dist/handlers/invitations.d.ts +9 -0
- package/dist/handlers/invitations.d.ts.map +1 -0
- package/dist/handlers/invitations.js +400 -0
- package/dist/handlers/jwt.d.ts +3 -0
- package/dist/handlers/jwt.d.ts.map +1 -0
- package/dist/handlers/jwt.js +79 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/routes.d.ts +42 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +129 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +88 -0
- package/package.json +63 -0
package/dist/config.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
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);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.configureVortex = configureVortex;
|
|
51
|
+
exports.getVortexConfig = getVortexConfig;
|
|
52
|
+
exports.authenticateRequest = authenticateRequest;
|
|
53
|
+
// Store configuration template (immutable after first set)
|
|
54
|
+
var configTemplate = null;
|
|
55
|
+
var isConfigLocked = false;
|
|
56
|
+
function configureVortex(config) {
|
|
57
|
+
if (isConfigLocked && configTemplate) {
|
|
58
|
+
throw new Error('Vortex configuration is already locked. Configuration can only be set once for security reasons.');
|
|
59
|
+
}
|
|
60
|
+
// Validate required config
|
|
61
|
+
if (!config.apiKey && !process.env.VORTEX_API_KEY) {
|
|
62
|
+
throw new Error('API key is required in config or VORTEX_API_KEY environment variable');
|
|
63
|
+
}
|
|
64
|
+
configTemplate = __assign({}, config);
|
|
65
|
+
isConfigLocked = true;
|
|
66
|
+
}
|
|
67
|
+
function getVortexConfig(request) {
|
|
68
|
+
// Create a fresh config for each request
|
|
69
|
+
var baseConfig = {
|
|
70
|
+
apiKey: (configTemplate === null || configTemplate === void 0 ? void 0 : configTemplate.apiKey) || process.env.VORTEX_API_KEY,
|
|
71
|
+
apiBaseUrl: (configTemplate === null || configTemplate === void 0 ? void 0 : configTemplate.apiBaseUrl) || process.env.VORTEX_API_BASE_URL,
|
|
72
|
+
};
|
|
73
|
+
if (!baseConfig.apiKey) {
|
|
74
|
+
throw new Error('Vortex not configured. Call configureVortex() or set VORTEX_API_KEY environment variable');
|
|
75
|
+
}
|
|
76
|
+
// Copy hooks from template if they exist
|
|
77
|
+
if (configTemplate) {
|
|
78
|
+
return __assign(__assign({}, baseConfig), { authenticateUser: configTemplate.authenticateUser, canAccessInvitationsByTarget: configTemplate.canAccessInvitationsByTarget, canAccessInvitation: configTemplate.canAccessInvitation, canDeleteInvitation: configTemplate.canDeleteInvitation, canAcceptInvitations: configTemplate.canAcceptInvitations, canAccessInvitationsByGroup: configTemplate.canAccessInvitationsByGroup, canDeleteInvitationsByGroup: configTemplate.canDeleteInvitationsByGroup, canReinvite: configTemplate.canReinvite });
|
|
79
|
+
}
|
|
80
|
+
return baseConfig;
|
|
81
|
+
}
|
|
82
|
+
// Helper function to authenticate user for any request
|
|
83
|
+
function authenticateRequest(request) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var config, error_1;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
config = getVortexConfig(request);
|
|
90
|
+
if (!config.authenticateUser) {
|
|
91
|
+
return [2 /*return*/, null];
|
|
92
|
+
}
|
|
93
|
+
_a.label = 1;
|
|
94
|
+
case 1:
|
|
95
|
+
_a.trys.push([1, 3, , 4]);
|
|
96
|
+
return [4 /*yield*/, config.authenticateUser(request)];
|
|
97
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
98
|
+
case 3:
|
|
99
|
+
error_1 = _a.sent();
|
|
100
|
+
// Log error but don't expose details
|
|
101
|
+
console.error('Authentication error:', error_1);
|
|
102
|
+
return [2 /*return*/, null];
|
|
103
|
+
case 4: return [2 /*return*/];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example Next.js API route setups for Vortex integration
|
|
3
|
+
*
|
|
4
|
+
* To use these examples in your Next.js app, create the corresponding
|
|
5
|
+
* files in your app/api directory with the following structure:
|
|
6
|
+
*/
|
|
7
|
+
export declare const jwtRouteExample = "\nimport { createVortexJwtRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const POST = createVortexJwtRoute();\n";
|
|
8
|
+
export declare const invitationsRouteExample = "\nimport { createVortexInvitationsRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const { GET } = createVortexInvitationsRoute();\n";
|
|
9
|
+
export declare const invitationByIdRouteExample = "\nimport { createVortexInvitationRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const { GET, DELETE } = createVortexInvitationRoute();\n";
|
|
10
|
+
export declare const acceptInvitationsRouteExample = "\nimport { createVortexInvitationsAcceptRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const { POST } = createVortexInvitationsAcceptRoute();\n";
|
|
11
|
+
export declare const invitationsByGroupRouteExample = "\nimport { createVortexInvitationsByGroupRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const { GET, DELETE } = createVortexInvitationsByGroupRoute();\n";
|
|
12
|
+
export declare const reinviteRouteExample = "\nimport { createVortexReinviteRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const { POST } = createVortexReinviteRoute();\n";
|
|
13
|
+
export declare const configurationExample = "\n// In your app initialization (e.g., in a layout.tsx or _app.tsx equivalent):\nimport { configureVortex, type AuthenticatedUser } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\nimport { NextRequest } from 'next/server';\n\n// Example with custom authentication logic\nconfigureVortex({\n apiKey: process.env.VORTEX_API_KEY!,\n apiBaseUrl: process.env.VORTEX_API_BASE_URL, // optional\n authenticateUser: async (request: NextRequest): Promise<AuthenticatedUser | null> => {\n // Your authentication logic here - extract user from session, JWT, etc.\n const sessionToken = request.headers.get('authorization')?.replace('Bearer ', '');\n\n if (!sessionToken) {\n return null;\n }\n\n // Example: decode your session token and get user info\n const user = await validateSessionAndGetUser(sessionToken);\n\n if (!user) {\n return null;\n }\n\n return {\n userId: user.id,\n identifiers: [{ type: 'email', value: user.email }],\n groups: user.organizations.map(org => ({\n type: 'organization',\n id: org.id,\n name: org.name\n })),\n role: user.role\n };\n }\n});\n\n// Minimal setup with environment variables only (JWT endpoint will require authenticateUser hook):\nconfigureVortex({\n apiKey: process.env.VORTEX_API_KEY!,\n});\n";
|
|
14
|
+
/**
|
|
15
|
+
* Complete API Routes Summary:
|
|
16
|
+
*
|
|
17
|
+
* POST /api/vortex/jwt
|
|
18
|
+
* - Generate JWT token for authentication
|
|
19
|
+
*
|
|
20
|
+
* GET /api/vortex/invitations?targetType={email|username|phoneNumber}&targetValue={value}
|
|
21
|
+
* - Get invitations by target
|
|
22
|
+
*
|
|
23
|
+
* GET /api/vortex/invitations/[invitationId]
|
|
24
|
+
* - Get specific invitation
|
|
25
|
+
*
|
|
26
|
+
* DELETE /api/vortex/invitations/[invitationId]
|
|
27
|
+
* - Revoke/delete invitation
|
|
28
|
+
*
|
|
29
|
+
* POST /api/vortex/invitations/accept
|
|
30
|
+
* - Accept invitations
|
|
31
|
+
*
|
|
32
|
+
* GET /api/vortex/invitations/by-group/[groupType]/[groupId]
|
|
33
|
+
* - Get invitations by group
|
|
34
|
+
*
|
|
35
|
+
* DELETE /api/vortex/invitations/by-group/[groupType]/[groupId]
|
|
36
|
+
* - Delete invitations by group
|
|
37
|
+
*
|
|
38
|
+
* POST /api/vortex/invitations/[invitationId]/reinvite
|
|
39
|
+
* - Resend invitation
|
|
40
|
+
*/
|
|
41
|
+
//# sourceMappingURL=examples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examples.d.ts","sourceRoot":"","sources":["../src/examples.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,eAAe,wIAI3B,CAAC;AAGF,eAAO,MAAM,uBAAuB,2JAInC,CAAC;AAGF,eAAO,MAAM,0BAA0B,iKAItC,CAAC;AAGF,eAAO,MAAM,6BAA6B,wKAIzC,CAAC;AAGF,eAAO,MAAM,8BAA8B,iLAI1C,CAAC;AAGF,eAAO,MAAM,oBAAoB,sJAIhC,CAAC;AAGF,eAAO,MAAM,oBAAoB,+yCAyChC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
|
package/dist/examples.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Example Next.js API route setups for Vortex integration
|
|
4
|
+
*
|
|
5
|
+
* To use these examples in your Next.js app, create the corresponding
|
|
6
|
+
* files in your app/api directory with the following structure:
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.configurationExample = exports.reinviteRouteExample = exports.invitationsByGroupRouteExample = exports.acceptInvitationsRouteExample = exports.invitationByIdRouteExample = exports.invitationsRouteExample = exports.jwtRouteExample = void 0;
|
|
10
|
+
// app/api/vortex/jwt/route.ts
|
|
11
|
+
exports.jwtRouteExample = "\nimport { createVortexJwtRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const POST = createVortexJwtRoute();\n";
|
|
12
|
+
// app/api/vortex/invitations/route.ts
|
|
13
|
+
exports.invitationsRouteExample = "\nimport { createVortexInvitationsRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const { GET } = createVortexInvitationsRoute();\n";
|
|
14
|
+
// app/api/vortex/invitations/[invitationId]/route.ts
|
|
15
|
+
exports.invitationByIdRouteExample = "\nimport { createVortexInvitationRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const { GET, DELETE } = createVortexInvitationRoute();\n";
|
|
16
|
+
// app/api/vortex/invitations/accept/route.ts
|
|
17
|
+
exports.acceptInvitationsRouteExample = "\nimport { createVortexInvitationsAcceptRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const { POST } = createVortexInvitationsAcceptRoute();\n";
|
|
18
|
+
// app/api/vortex/invitations/by-group/[groupType]/[groupId]/route.ts
|
|
19
|
+
exports.invitationsByGroupRouteExample = "\nimport { createVortexInvitationsByGroupRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const { GET, DELETE } = createVortexInvitationsByGroupRoute();\n";
|
|
20
|
+
// app/api/vortex/invitations/[invitationId]/reinvite/route.ts
|
|
21
|
+
exports.reinviteRouteExample = "\nimport { createVortexReinviteRoute } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\n\nexport const { POST } = createVortexReinviteRoute();\n";
|
|
22
|
+
// Configuration example
|
|
23
|
+
exports.configurationExample = "\n// In your app initialization (e.g., in a layout.tsx or _app.tsx equivalent):\nimport { configureVortex, type AuthenticatedUser } from '@teamvortexsoftware/vortex-nextjs-15-sdk';\nimport { NextRequest } from 'next/server';\n\n// Example with custom authentication logic\nconfigureVortex({\n apiKey: process.env.VORTEX_API_KEY!,\n apiBaseUrl: process.env.VORTEX_API_BASE_URL, // optional\n authenticateUser: async (request: NextRequest): Promise<AuthenticatedUser | null> => {\n // Your authentication logic here - extract user from session, JWT, etc.\n const sessionToken = request.headers.get('authorization')?.replace('Bearer ', '');\n\n if (!sessionToken) {\n return null;\n }\n\n // Example: decode your session token and get user info\n const user = await validateSessionAndGetUser(sessionToken);\n\n if (!user) {\n return null;\n }\n\n return {\n userId: user.id,\n identifiers: [{ type: 'email', value: user.email }],\n groups: user.organizations.map(org => ({\n type: 'organization',\n id: org.id,\n name: org.name\n })),\n role: user.role\n };\n }\n});\n\n// Minimal setup with environment variables only (JWT endpoint will require authenticateUser hook):\nconfigureVortex({\n apiKey: process.env.VORTEX_API_KEY!,\n});\n";
|
|
24
|
+
/**
|
|
25
|
+
* Complete API Routes Summary:
|
|
26
|
+
*
|
|
27
|
+
* POST /api/vortex/jwt
|
|
28
|
+
* - Generate JWT token for authentication
|
|
29
|
+
*
|
|
30
|
+
* GET /api/vortex/invitations?targetType={email|username|phoneNumber}&targetValue={value}
|
|
31
|
+
* - Get invitations by target
|
|
32
|
+
*
|
|
33
|
+
* GET /api/vortex/invitations/[invitationId]
|
|
34
|
+
* - Get specific invitation
|
|
35
|
+
*
|
|
36
|
+
* DELETE /api/vortex/invitations/[invitationId]
|
|
37
|
+
* - Revoke/delete invitation
|
|
38
|
+
*
|
|
39
|
+
* POST /api/vortex/invitations/accept
|
|
40
|
+
* - Accept invitations
|
|
41
|
+
*
|
|
42
|
+
* GET /api/vortex/invitations/by-group/[groupType]/[groupId]
|
|
43
|
+
* - Get invitations by group
|
|
44
|
+
*
|
|
45
|
+
* DELETE /api/vortex/invitations/by-group/[groupType]/[groupId]
|
|
46
|
+
* - Delete invitations by group
|
|
47
|
+
*
|
|
48
|
+
* POST /api/vortex/invitations/[invitationId]/reinvite
|
|
49
|
+
* - Resend invitation
|
|
50
|
+
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NextRequest } from 'next/server';
|
|
2
|
+
export declare function handleGetInvitationsByTarget(request: NextRequest): Promise<import("next/server").NextResponse<unknown>>;
|
|
3
|
+
export declare function handleGetInvitation(request: NextRequest, invitationId: string): Promise<import("next/server").NextResponse<unknown>>;
|
|
4
|
+
export declare function handleRevokeInvitation(request: NextRequest, invitationId: string): Promise<import("next/server").NextResponse<unknown>>;
|
|
5
|
+
export declare function handleAcceptInvitations(request: NextRequest): Promise<import("next/server").NextResponse<unknown>>;
|
|
6
|
+
export declare function handleGetInvitationsByGroup(request: NextRequest, groupType: string, groupId: string): Promise<import("next/server").NextResponse<unknown>>;
|
|
7
|
+
export declare function handleDeleteInvitationsByGroup(request: NextRequest, groupType: string, groupId: string): Promise<import("next/server").NextResponse<unknown>>;
|
|
8
|
+
export declare function handleReinvite(request: NextRequest, invitationId: string): Promise<import("next/server").NextResponse<unknown>>;
|
|
9
|
+
//# sourceMappingURL=invitations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitations.d.ts","sourceRoot":"","sources":["../../src/handlers/invitations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1C,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,WAAW,wDAuCtE;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wDAgCnF;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wDA8BtF;AAED,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,WAAW,wDAmDjE;AAED,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wDAmCzG;AAED,wBAAsB,8BAA8B,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wDAmC5G;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wDA8B9E"}
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
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);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.handleGetInvitationsByTarget = handleGetInvitationsByTarget;
|
|
40
|
+
exports.handleGetInvitation = handleGetInvitation;
|
|
41
|
+
exports.handleRevokeInvitation = handleRevokeInvitation;
|
|
42
|
+
exports.handleAcceptInvitations = handleAcceptInvitations;
|
|
43
|
+
exports.handleGetInvitationsByGroup = handleGetInvitationsByGroup;
|
|
44
|
+
exports.handleDeleteInvitationsByGroup = handleDeleteInvitationsByGroup;
|
|
45
|
+
exports.handleReinvite = handleReinvite;
|
|
46
|
+
var vortex_node_22_sdk_1 = require("@teamvortexsoftware/vortex-node-22-sdk");
|
|
47
|
+
var config_1 = require("../config");
|
|
48
|
+
var utils_1 = require("../utils");
|
|
49
|
+
function handleGetInvitationsByTarget(request) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
+
var config, user, hasAccess, targetType, targetValue, vortex, invitations, error_1;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
_a.trys.push([0, 6, , 7]);
|
|
56
|
+
if (request.method !== 'GET') {
|
|
57
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Method not allowed', 405)];
|
|
58
|
+
}
|
|
59
|
+
config = (0, config_1.getVortexConfig)(request);
|
|
60
|
+
return [4 /*yield*/, (0, config_1.authenticateRequest)(request)];
|
|
61
|
+
case 1:
|
|
62
|
+
user = _a.sent();
|
|
63
|
+
if (!config.canAccessInvitationsByTarget) return [3 /*break*/, 3];
|
|
64
|
+
return [4 /*yield*/, config.canAccessInvitationsByTarget(request, user)];
|
|
65
|
+
case 2:
|
|
66
|
+
hasAccess = _a.sent();
|
|
67
|
+
if (!hasAccess) {
|
|
68
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied', 403)];
|
|
69
|
+
}
|
|
70
|
+
return [3 /*break*/, 4];
|
|
71
|
+
case 3:
|
|
72
|
+
if (!user) {
|
|
73
|
+
// If no access control hook is configured, require authentication
|
|
74
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied. Configure access control hooks for invitation endpoints.', 403)];
|
|
75
|
+
}
|
|
76
|
+
_a.label = 4;
|
|
77
|
+
case 4:
|
|
78
|
+
targetType = (0, utils_1.sanitizeInput)((0, utils_1.getQueryParam)(request, 'targetType'));
|
|
79
|
+
targetValue = (0, utils_1.sanitizeInput)((0, utils_1.getQueryParam)(request, 'targetValue'));
|
|
80
|
+
if (!targetType || !targetValue) {
|
|
81
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('targetType and targetValue query parameters are required', 400)];
|
|
82
|
+
}
|
|
83
|
+
if (!['email', 'username', 'phoneNumber'].includes(targetType)) {
|
|
84
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('targetType must be email, username, or phoneNumber', 400)];
|
|
85
|
+
}
|
|
86
|
+
vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
|
|
87
|
+
return [4 /*yield*/, vortex.getInvitationsByTarget(targetType, targetValue)];
|
|
88
|
+
case 5:
|
|
89
|
+
invitations = _a.sent();
|
|
90
|
+
return [2 /*return*/, (0, utils_1.createApiResponse)({ invitations: invitations })];
|
|
91
|
+
case 6:
|
|
92
|
+
error_1 = _a.sent();
|
|
93
|
+
console.error('Error in handleGetInvitationsByTarget:', error_1);
|
|
94
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('An error occurred while processing your request', 500)];
|
|
95
|
+
case 7: return [2 /*return*/];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function handleGetInvitation(request, invitationId) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
var sanitizedId, config, user, hasAccess, vortex, invitation, error_2;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
_a.trys.push([0, 6, , 7]);
|
|
107
|
+
if (request.method !== 'GET') {
|
|
108
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Method not allowed', 405)];
|
|
109
|
+
}
|
|
110
|
+
sanitizedId = (0, utils_1.sanitizeInput)(invitationId);
|
|
111
|
+
if (!sanitizedId) {
|
|
112
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Invalid invitation ID', 400)];
|
|
113
|
+
}
|
|
114
|
+
config = (0, config_1.getVortexConfig)(request);
|
|
115
|
+
return [4 /*yield*/, (0, config_1.authenticateRequest)(request)];
|
|
116
|
+
case 1:
|
|
117
|
+
user = _a.sent();
|
|
118
|
+
if (!config.canAccessInvitation) return [3 /*break*/, 3];
|
|
119
|
+
return [4 /*yield*/, config.canAccessInvitation(request, user, { invitationId: sanitizedId })];
|
|
120
|
+
case 2:
|
|
121
|
+
hasAccess = _a.sent();
|
|
122
|
+
if (!hasAccess) {
|
|
123
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied', 403)];
|
|
124
|
+
}
|
|
125
|
+
return [3 /*break*/, 4];
|
|
126
|
+
case 3:
|
|
127
|
+
if (!user) {
|
|
128
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied. Configure access control hooks for invitation endpoints.', 403)];
|
|
129
|
+
}
|
|
130
|
+
_a.label = 4;
|
|
131
|
+
case 4:
|
|
132
|
+
vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
|
|
133
|
+
return [4 /*yield*/, vortex.getInvitation(sanitizedId)];
|
|
134
|
+
case 5:
|
|
135
|
+
invitation = _a.sent();
|
|
136
|
+
return [2 /*return*/, (0, utils_1.createApiResponse)(invitation)];
|
|
137
|
+
case 6:
|
|
138
|
+
error_2 = _a.sent();
|
|
139
|
+
console.error('Error in handleGetInvitation:', error_2);
|
|
140
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('An error occurred while processing your request', 500)];
|
|
141
|
+
case 7: return [2 /*return*/];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function handleRevokeInvitation(request, invitationId) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
+
var sanitizedId, config, user, hasAccess, vortex, error_3;
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
switch (_a.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
_a.trys.push([0, 6, , 7]);
|
|
153
|
+
if (request.method !== 'DELETE') {
|
|
154
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Method not allowed', 405)];
|
|
155
|
+
}
|
|
156
|
+
sanitizedId = (0, utils_1.sanitizeInput)(invitationId);
|
|
157
|
+
if (!sanitizedId) {
|
|
158
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Invalid invitation ID', 400)];
|
|
159
|
+
}
|
|
160
|
+
config = (0, config_1.getVortexConfig)(request);
|
|
161
|
+
return [4 /*yield*/, (0, config_1.authenticateRequest)(request)];
|
|
162
|
+
case 1:
|
|
163
|
+
user = _a.sent();
|
|
164
|
+
if (!config.canDeleteInvitation) return [3 /*break*/, 3];
|
|
165
|
+
return [4 /*yield*/, config.canDeleteInvitation(request, user, { invitationId: sanitizedId })];
|
|
166
|
+
case 2:
|
|
167
|
+
hasAccess = _a.sent();
|
|
168
|
+
if (!hasAccess) {
|
|
169
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied', 403)];
|
|
170
|
+
}
|
|
171
|
+
return [3 /*break*/, 4];
|
|
172
|
+
case 3:
|
|
173
|
+
if (!user) {
|
|
174
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied. Configure access control hooks for invitation endpoints.', 403)];
|
|
175
|
+
}
|
|
176
|
+
_a.label = 4;
|
|
177
|
+
case 4:
|
|
178
|
+
vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
|
|
179
|
+
return [4 /*yield*/, vortex.revokeInvitation(sanitizedId)];
|
|
180
|
+
case 5:
|
|
181
|
+
_a.sent();
|
|
182
|
+
return [2 /*return*/, (0, utils_1.createApiResponse)({ success: true })];
|
|
183
|
+
case 6:
|
|
184
|
+
error_3 = _a.sent();
|
|
185
|
+
console.error('Error in handleRevokeInvitation:', error_3);
|
|
186
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('An error occurred while processing your request', 500)];
|
|
187
|
+
case 7: return [2 /*return*/];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function handleAcceptInvitations(request) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
+
var body, invitationIds, target, sanitizedIds, config, user, hasAccess, vortex, result, error_4;
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
switch (_a.label) {
|
|
197
|
+
case 0:
|
|
198
|
+
_a.trys.push([0, 7, , 8]);
|
|
199
|
+
if (request.method !== 'POST') {
|
|
200
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Method not allowed', 405)];
|
|
201
|
+
}
|
|
202
|
+
return [4 /*yield*/, (0, utils_1.parseRequestBody)(request)];
|
|
203
|
+
case 1:
|
|
204
|
+
body = _a.sent();
|
|
205
|
+
(0, utils_1.validateRequiredFields)(body, ['invitationIds', 'target']);
|
|
206
|
+
invitationIds = body.invitationIds, target = body.target;
|
|
207
|
+
if (!Array.isArray(invitationIds) || invitationIds.length === 0) {
|
|
208
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('invitationIds must be a non-empty array', 400)];
|
|
209
|
+
}
|
|
210
|
+
sanitizedIds = invitationIds.map(function (id) { return (0, utils_1.sanitizeInput)(id); }).filter(function (id) { return Boolean(id); });
|
|
211
|
+
if (sanitizedIds.length !== invitationIds.length) {
|
|
212
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Invalid invitation IDs provided', 400)];
|
|
213
|
+
}
|
|
214
|
+
if (!target.type || !target.value) {
|
|
215
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('target must have type and value properties', 400)];
|
|
216
|
+
}
|
|
217
|
+
if (!['email', 'username', 'phoneNumber'].includes(target.type)) {
|
|
218
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('target.type must be email, username, or phoneNumber', 400)];
|
|
219
|
+
}
|
|
220
|
+
config = (0, config_1.getVortexConfig)(request);
|
|
221
|
+
return [4 /*yield*/, (0, config_1.authenticateRequest)(request)];
|
|
222
|
+
case 2:
|
|
223
|
+
user = _a.sent();
|
|
224
|
+
if (!config.canAcceptInvitations) return [3 /*break*/, 4];
|
|
225
|
+
return [4 /*yield*/, config.canAcceptInvitations(request, user, { invitationIds: sanitizedIds, target: target })];
|
|
226
|
+
case 3:
|
|
227
|
+
hasAccess = _a.sent();
|
|
228
|
+
if (!hasAccess) {
|
|
229
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied', 403)];
|
|
230
|
+
}
|
|
231
|
+
return [3 /*break*/, 5];
|
|
232
|
+
case 4:
|
|
233
|
+
if (!user) {
|
|
234
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied. Configure access control hooks for invitation endpoints.', 403)];
|
|
235
|
+
}
|
|
236
|
+
_a.label = 5;
|
|
237
|
+
case 5:
|
|
238
|
+
vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
|
|
239
|
+
return [4 /*yield*/, vortex.acceptInvitations(sanitizedIds, {
|
|
240
|
+
type: target.type,
|
|
241
|
+
value: (0, utils_1.sanitizeInput)(target.value) || target.value
|
|
242
|
+
})];
|
|
243
|
+
case 6:
|
|
244
|
+
result = _a.sent();
|
|
245
|
+
return [2 /*return*/, (0, utils_1.createApiResponse)(result)];
|
|
246
|
+
case 7:
|
|
247
|
+
error_4 = _a.sent();
|
|
248
|
+
console.error('Error in handleAcceptInvitations:', error_4);
|
|
249
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('An error occurred while processing your request', 500)];
|
|
250
|
+
case 8: return [2 /*return*/];
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
function handleGetInvitationsByGroup(request, groupType, groupId) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
257
|
+
var sanitizedGroupType, sanitizedGroupId, config, user, hasAccess, vortex, invitations, error_5;
|
|
258
|
+
return __generator(this, function (_a) {
|
|
259
|
+
switch (_a.label) {
|
|
260
|
+
case 0:
|
|
261
|
+
_a.trys.push([0, 6, , 7]);
|
|
262
|
+
if (request.method !== 'GET') {
|
|
263
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Method not allowed', 405)];
|
|
264
|
+
}
|
|
265
|
+
sanitizedGroupType = (0, utils_1.sanitizeInput)(groupType);
|
|
266
|
+
sanitizedGroupId = (0, utils_1.sanitizeInput)(groupId);
|
|
267
|
+
if (!sanitizedGroupType || !sanitizedGroupId) {
|
|
268
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Invalid group parameters', 400)];
|
|
269
|
+
}
|
|
270
|
+
config = (0, config_1.getVortexConfig)(request);
|
|
271
|
+
return [4 /*yield*/, (0, config_1.authenticateRequest)(request)];
|
|
272
|
+
case 1:
|
|
273
|
+
user = _a.sent();
|
|
274
|
+
if (!config.canAccessInvitationsByGroup) return [3 /*break*/, 3];
|
|
275
|
+
return [4 /*yield*/, config.canAccessInvitationsByGroup(request, user, {
|
|
276
|
+
groupType: sanitizedGroupType,
|
|
277
|
+
groupId: sanitizedGroupId
|
|
278
|
+
})];
|
|
279
|
+
case 2:
|
|
280
|
+
hasAccess = _a.sent();
|
|
281
|
+
if (!hasAccess) {
|
|
282
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied', 403)];
|
|
283
|
+
}
|
|
284
|
+
return [3 /*break*/, 4];
|
|
285
|
+
case 3:
|
|
286
|
+
if (!user) {
|
|
287
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied. Configure access control hooks for invitation endpoints.', 403)];
|
|
288
|
+
}
|
|
289
|
+
_a.label = 4;
|
|
290
|
+
case 4:
|
|
291
|
+
vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
|
|
292
|
+
return [4 /*yield*/, vortex.getInvitationsByGroup(sanitizedGroupType, sanitizedGroupId)];
|
|
293
|
+
case 5:
|
|
294
|
+
invitations = _a.sent();
|
|
295
|
+
return [2 /*return*/, (0, utils_1.createApiResponse)({ invitations: invitations })];
|
|
296
|
+
case 6:
|
|
297
|
+
error_5 = _a.sent();
|
|
298
|
+
console.error('Error in handleGetInvitationsByGroup:', error_5);
|
|
299
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('An error occurred while processing your request', 500)];
|
|
300
|
+
case 7: return [2 /*return*/];
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
function handleDeleteInvitationsByGroup(request, groupType, groupId) {
|
|
306
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
307
|
+
var sanitizedGroupType, sanitizedGroupId, config, user, hasAccess, vortex, error_6;
|
|
308
|
+
return __generator(this, function (_a) {
|
|
309
|
+
switch (_a.label) {
|
|
310
|
+
case 0:
|
|
311
|
+
_a.trys.push([0, 6, , 7]);
|
|
312
|
+
if (request.method !== 'DELETE') {
|
|
313
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Method not allowed', 405)];
|
|
314
|
+
}
|
|
315
|
+
sanitizedGroupType = (0, utils_1.sanitizeInput)(groupType);
|
|
316
|
+
sanitizedGroupId = (0, utils_1.sanitizeInput)(groupId);
|
|
317
|
+
if (!sanitizedGroupType || !sanitizedGroupId) {
|
|
318
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Invalid group parameters', 400)];
|
|
319
|
+
}
|
|
320
|
+
config = (0, config_1.getVortexConfig)(request);
|
|
321
|
+
return [4 /*yield*/, (0, config_1.authenticateRequest)(request)];
|
|
322
|
+
case 1:
|
|
323
|
+
user = _a.sent();
|
|
324
|
+
if (!config.canDeleteInvitationsByGroup) return [3 /*break*/, 3];
|
|
325
|
+
return [4 /*yield*/, config.canDeleteInvitationsByGroup(request, user, {
|
|
326
|
+
groupType: sanitizedGroupType,
|
|
327
|
+
groupId: sanitizedGroupId
|
|
328
|
+
})];
|
|
329
|
+
case 2:
|
|
330
|
+
hasAccess = _a.sent();
|
|
331
|
+
if (!hasAccess) {
|
|
332
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied', 403)];
|
|
333
|
+
}
|
|
334
|
+
return [3 /*break*/, 4];
|
|
335
|
+
case 3:
|
|
336
|
+
if (!user) {
|
|
337
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied. Configure access control hooks for invitation endpoints.', 403)];
|
|
338
|
+
}
|
|
339
|
+
_a.label = 4;
|
|
340
|
+
case 4:
|
|
341
|
+
vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
|
|
342
|
+
return [4 /*yield*/, vortex.deleteInvitationsByGroup(sanitizedGroupType, sanitizedGroupId)];
|
|
343
|
+
case 5:
|
|
344
|
+
_a.sent();
|
|
345
|
+
return [2 /*return*/, (0, utils_1.createApiResponse)({ success: true })];
|
|
346
|
+
case 6:
|
|
347
|
+
error_6 = _a.sent();
|
|
348
|
+
console.error('Error in handleDeleteInvitationsByGroup:', error_6);
|
|
349
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('An error occurred while processing your request', 500)];
|
|
350
|
+
case 7: return [2 /*return*/];
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function handleReinvite(request, invitationId) {
|
|
356
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
357
|
+
var sanitizedId, config, user, hasAccess, vortex, invitation, error_7;
|
|
358
|
+
return __generator(this, function (_a) {
|
|
359
|
+
switch (_a.label) {
|
|
360
|
+
case 0:
|
|
361
|
+
_a.trys.push([0, 6, , 7]);
|
|
362
|
+
if (request.method !== 'POST') {
|
|
363
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Method not allowed', 405)];
|
|
364
|
+
}
|
|
365
|
+
sanitizedId = (0, utils_1.sanitizeInput)(invitationId);
|
|
366
|
+
if (!sanitizedId) {
|
|
367
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Invalid invitation ID', 400)];
|
|
368
|
+
}
|
|
369
|
+
config = (0, config_1.getVortexConfig)(request);
|
|
370
|
+
return [4 /*yield*/, (0, config_1.authenticateRequest)(request)];
|
|
371
|
+
case 1:
|
|
372
|
+
user = _a.sent();
|
|
373
|
+
if (!config.canReinvite) return [3 /*break*/, 3];
|
|
374
|
+
return [4 /*yield*/, config.canReinvite(request, user, { invitationId: sanitizedId })];
|
|
375
|
+
case 2:
|
|
376
|
+
hasAccess = _a.sent();
|
|
377
|
+
if (!hasAccess) {
|
|
378
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied', 403)];
|
|
379
|
+
}
|
|
380
|
+
return [3 /*break*/, 4];
|
|
381
|
+
case 3:
|
|
382
|
+
if (!user) {
|
|
383
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('Access denied. Configure access control hooks for invitation endpoints.', 403)];
|
|
384
|
+
}
|
|
385
|
+
_a.label = 4;
|
|
386
|
+
case 4:
|
|
387
|
+
vortex = new vortex_node_22_sdk_1.Vortex(config.apiKey);
|
|
388
|
+
return [4 /*yield*/, vortex.reinvite(sanitizedId)];
|
|
389
|
+
case 5:
|
|
390
|
+
invitation = _a.sent();
|
|
391
|
+
return [2 /*return*/, (0, utils_1.createApiResponse)(invitation)];
|
|
392
|
+
case 6:
|
|
393
|
+
error_7 = _a.sent();
|
|
394
|
+
console.error('Error in handleReinvite:', error_7);
|
|
395
|
+
return [2 /*return*/, (0, utils_1.createErrorResponse)('An error occurred while processing your request', 500)];
|
|
396
|
+
case 7: return [2 /*return*/];
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
}
|
|
@@ -0,0 +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,wDAgC7D"}
|