@authhero/multi-tenancy 14.20.1 → 14.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/multi-tenancy.mjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Hono as
|
|
5
|
-
import { MANAGEMENT_API_SCOPES as ae, MANAGEMENT_API_AUDIENCE as
|
|
6
|
-
import { OpenAPIHono as
|
|
7
|
-
function
|
|
1
|
+
var ne = Object.defineProperty;
|
|
2
|
+
var re = (e, t, n) => t in e ? ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var E = (e, t, n) => re(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { Hono as se } from "hono";
|
|
5
|
+
import { MANAGEMENT_API_SCOPES as ae, MANAGEMENT_API_AUDIENCE as Y, fetchAll as D, auth0QuerySchema as oe, tenantSchema as O, tenantInsertSchema as G, deepMergePatch as ie, connectionSchema as ce, connectionOptionsSchema as le, init as ue } from "authhero";
|
|
6
|
+
import { OpenAPIHono as de, createRoute as M, z as S } from "@hono/zod-openapi";
|
|
7
|
+
function fe(e) {
|
|
8
8
|
const { controlPlaneTenantId: t, requireOrganizationMatch: n = !0 } = e;
|
|
9
9
|
return {
|
|
10
|
-
async onTenantAccessValidation(r,
|
|
11
|
-
if (
|
|
10
|
+
async onTenantAccessValidation(r, s) {
|
|
11
|
+
if (s === t)
|
|
12
12
|
return !0;
|
|
13
13
|
if (n) {
|
|
14
|
-
const
|
|
15
|
-
return c ? c.toLowerCase() ===
|
|
14
|
+
const o = r.var.org_name, i = r.var.organization_id, c = o || i;
|
|
15
|
+
return c ? c.toLowerCase() === s.toLowerCase() : !1;
|
|
16
16
|
}
|
|
17
17
|
return !0;
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function me(e, t, n, r) {
|
|
22
22
|
if (t === n)
|
|
23
23
|
return !0;
|
|
24
|
-
const
|
|
25
|
-
return
|
|
24
|
+
const s = r || e;
|
|
25
|
+
return s ? s.toLowerCase() === t.toLowerCase() : !1;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function ge(e) {
|
|
28
28
|
return {
|
|
29
29
|
async resolveDataAdapters(t) {
|
|
30
30
|
try {
|
|
@@ -39,23 +39,23 @@ function me(e) {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function we(e) {
|
|
43
43
|
return `urn:authhero:tenant:${e.toLowerCase()}`;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function Z(e) {
|
|
46
46
|
return {
|
|
47
47
|
async beforeCreate(t, n) {
|
|
48
48
|
return !n.audience && n.id ? {
|
|
49
49
|
...n,
|
|
50
|
-
audience:
|
|
50
|
+
audience: we(n.id)
|
|
51
51
|
} : n;
|
|
52
52
|
},
|
|
53
53
|
async afterCreate(t, n) {
|
|
54
|
-
const { accessControl: r, databaseIsolation:
|
|
55
|
-
r && t.ctx && await
|
|
54
|
+
const { accessControl: r, databaseIsolation: s } = e;
|
|
55
|
+
r && t.ctx && await he(t, n, r), s != null && s.onProvision && await s.onProvision(n.id);
|
|
56
56
|
},
|
|
57
57
|
async beforeDelete(t, n) {
|
|
58
|
-
const { accessControl: r, databaseIsolation:
|
|
58
|
+
const { accessControl: r, databaseIsolation: s } = e;
|
|
59
59
|
if (r)
|
|
60
60
|
try {
|
|
61
61
|
const i = (await t.adapters.organizations.list(
|
|
@@ -65,34 +65,34 @@ function Y(e) {
|
|
|
65
65
|
r.controlPlaneTenantId,
|
|
66
66
|
i.id
|
|
67
67
|
);
|
|
68
|
-
} catch (
|
|
68
|
+
} catch (o) {
|
|
69
69
|
console.warn(
|
|
70
70
|
`Failed to remove organization for tenant ${n}:`,
|
|
71
|
-
|
|
71
|
+
o
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
|
-
if (
|
|
74
|
+
if (s != null && s.onDeprovision)
|
|
75
75
|
try {
|
|
76
|
-
await
|
|
77
|
-
} catch (
|
|
76
|
+
await s.onDeprovision(n);
|
|
77
|
+
} catch (o) {
|
|
78
78
|
console.warn(
|
|
79
79
|
`Failed to deprovision database for tenant ${n}:`,
|
|
80
|
-
|
|
80
|
+
o
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
async function
|
|
86
|
+
async function he(e, t, n) {
|
|
87
87
|
const {
|
|
88
88
|
controlPlaneTenantId: r,
|
|
89
|
-
defaultPermissions:
|
|
90
|
-
defaultRoles:
|
|
89
|
+
defaultPermissions: s,
|
|
90
|
+
defaultRoles: o,
|
|
91
91
|
issuer: i,
|
|
92
92
|
adminRoleName: c = "Tenant Admin",
|
|
93
|
-
adminRoleDescription:
|
|
94
|
-
addCreatorToOrganization:
|
|
95
|
-
} = n,
|
|
93
|
+
adminRoleDescription: l = "Full access to all tenant management operations",
|
|
94
|
+
addCreatorToOrganization: a = !0
|
|
95
|
+
} = n, u = await e.adapters.organizations.create(
|
|
96
96
|
r,
|
|
97
97
|
{
|
|
98
98
|
name: t.id,
|
|
@@ -100,14 +100,14 @@ async function we(e, t, n) {
|
|
|
100
100
|
}
|
|
101
101
|
);
|
|
102
102
|
let g;
|
|
103
|
-
if (i && (g = await
|
|
103
|
+
if (i && (g = await ye(
|
|
104
104
|
e,
|
|
105
105
|
r,
|
|
106
106
|
c,
|
|
107
|
-
|
|
108
|
-
)),
|
|
107
|
+
l
|
|
108
|
+
)), a && e.ctx) {
|
|
109
109
|
const d = e.ctx.var.user;
|
|
110
|
-
if (d != null && d.sub && !await
|
|
110
|
+
if (d != null && d.sub && !await pe(
|
|
111
111
|
e,
|
|
112
112
|
r,
|
|
113
113
|
d.sub
|
|
@@ -115,28 +115,28 @@ async function we(e, t, n) {
|
|
|
115
115
|
try {
|
|
116
116
|
await e.adapters.userOrganizations.create(r, {
|
|
117
117
|
user_id: d.sub,
|
|
118
|
-
organization_id:
|
|
118
|
+
organization_id: u.id
|
|
119
119
|
}), g && await e.adapters.userRoles.create(
|
|
120
120
|
r,
|
|
121
121
|
d.sub,
|
|
122
122
|
g,
|
|
123
|
-
|
|
123
|
+
u.id
|
|
124
124
|
// organizationId
|
|
125
125
|
);
|
|
126
|
-
} catch (
|
|
126
|
+
} catch (f) {
|
|
127
127
|
console.warn(
|
|
128
|
-
`Failed to add creator ${d.sub} to organization ${
|
|
129
|
-
|
|
128
|
+
`Failed to add creator ${d.sub} to organization ${u.id}:`,
|
|
129
|
+
f
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
`Would assign roles ${
|
|
135
|
-
),
|
|
136
|
-
`Would grant permissions ${
|
|
133
|
+
o && o.length > 0 && console.log(
|
|
134
|
+
`Would assign roles ${o.join(", ")} to organization ${u.id}`
|
|
135
|
+
), s && s.length > 0 && console.log(
|
|
136
|
+
`Would grant permissions ${s.join(", ")} to organization ${u.id}`
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
|
-
async function
|
|
139
|
+
async function pe(e, t, n) {
|
|
140
140
|
const r = await e.adapters.userRoles.list(
|
|
141
141
|
t,
|
|
142
142
|
n,
|
|
@@ -144,10 +144,10 @@ async function he(e, t, n) {
|
|
|
144
144
|
""
|
|
145
145
|
// Empty string for global roles
|
|
146
146
|
);
|
|
147
|
-
for (const
|
|
147
|
+
for (const s of r)
|
|
148
148
|
if ((await e.adapters.rolePermissions.list(
|
|
149
149
|
t,
|
|
150
|
-
|
|
150
|
+
s.id,
|
|
151
151
|
{ per_page: 1e3 }
|
|
152
152
|
)).some(
|
|
153
153
|
(c) => c.permission_name === "admin:organizations"
|
|
@@ -155,127 +155,127 @@ async function he(e, t, n) {
|
|
|
155
155
|
return !0;
|
|
156
156
|
return !1;
|
|
157
157
|
}
|
|
158
|
-
async function
|
|
159
|
-
const
|
|
160
|
-
if (
|
|
161
|
-
return
|
|
158
|
+
async function ye(e, t, n, r) {
|
|
159
|
+
const o = (await e.adapters.roles.list(t, {})).roles.find((a) => a.name === n);
|
|
160
|
+
if (o)
|
|
161
|
+
return o.id;
|
|
162
162
|
const i = await e.adapters.roles.create(t, {
|
|
163
163
|
name: n,
|
|
164
164
|
description: r
|
|
165
|
-
}), c =
|
|
165
|
+
}), c = Y, l = ae.map((a) => ({
|
|
166
166
|
role_id: i.id,
|
|
167
167
|
resource_server_identifier: c,
|
|
168
|
-
permission_name:
|
|
168
|
+
permission_name: a.value
|
|
169
169
|
}));
|
|
170
170
|
return await e.adapters.rolePermissions.assign(
|
|
171
171
|
t,
|
|
172
172
|
i.id,
|
|
173
|
-
|
|
173
|
+
l
|
|
174
174
|
), i.id;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
const { controlPlaneTenantId: r, getChildTenantIds:
|
|
178
|
-
async function c(
|
|
179
|
-
return (await t(
|
|
176
|
+
function H(e, t, n = () => !0) {
|
|
177
|
+
const { controlPlaneTenantId: r, getChildTenantIds: s, getAdapters: o } = e, i = /* @__PURE__ */ new Map();
|
|
178
|
+
async function c(u, g, d) {
|
|
179
|
+
return (await t(u).list(g, {
|
|
180
180
|
q: `name:${d}`,
|
|
181
181
|
per_page: 1
|
|
182
182
|
}))[0] ?? null;
|
|
183
183
|
}
|
|
184
|
-
async function u
|
|
185
|
-
const g = await
|
|
184
|
+
async function l(u) {
|
|
185
|
+
const g = await s(), d = t(await o(r));
|
|
186
186
|
await Promise.all(
|
|
187
|
-
g.map(async (
|
|
187
|
+
g.map(async (m) => {
|
|
188
188
|
try {
|
|
189
|
-
const
|
|
190
|
-
...d.transform(
|
|
189
|
+
const f = await o(m), w = t(f), y = {
|
|
190
|
+
...d.transform(u),
|
|
191
191
|
is_system: !0
|
|
192
|
-
}, _ = await c(
|
|
193
|
-
if (_ &&
|
|
194
|
-
const
|
|
195
|
-
await w.update(
|
|
192
|
+
}, _ = await c(f, m, u.name), P = _ ? w.getId(_) : void 0;
|
|
193
|
+
if (_ && P) {
|
|
194
|
+
const I = w.preserveOnUpdate ? w.preserveOnUpdate(_, y) : y;
|
|
195
|
+
await w.update(m, P, I);
|
|
196
196
|
} else
|
|
197
|
-
await w.create(
|
|
198
|
-
} catch (
|
|
197
|
+
await w.create(m, y);
|
|
198
|
+
} catch (f) {
|
|
199
199
|
console.error(
|
|
200
|
-
`Failed to sync ${d.listKey} "${
|
|
201
|
-
|
|
200
|
+
`Failed to sync ${d.listKey} "${u.name}" to tenant "${m}":`,
|
|
201
|
+
f
|
|
202
202
|
);
|
|
203
203
|
}
|
|
204
204
|
})
|
|
205
205
|
);
|
|
206
206
|
}
|
|
207
|
-
async function
|
|
208
|
-
const g = await
|
|
207
|
+
async function a(u) {
|
|
208
|
+
const g = await s();
|
|
209
209
|
await Promise.all(
|
|
210
210
|
g.map(async (d) => {
|
|
211
211
|
try {
|
|
212
|
-
const
|
|
213
|
-
w &&
|
|
214
|
-
} catch (
|
|
212
|
+
const m = await o(d), f = t(m), w = await c(m, d, u), T = w ? f.getId(w) : void 0;
|
|
213
|
+
w && T && await f.remove(d, T);
|
|
214
|
+
} catch (m) {
|
|
215
215
|
console.error(
|
|
216
|
-
`Failed to delete entity "${
|
|
217
|
-
|
|
216
|
+
`Failed to delete entity "${u}" from tenant "${d}":`,
|
|
217
|
+
m
|
|
218
218
|
);
|
|
219
219
|
}
|
|
220
220
|
})
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
223
|
return {
|
|
224
|
-
afterCreate: async (
|
|
225
|
-
|
|
224
|
+
afterCreate: async (u, g) => {
|
|
225
|
+
u.tenantId === r && n(g) && await l(g);
|
|
226
226
|
},
|
|
227
|
-
afterUpdate: async (
|
|
228
|
-
|
|
227
|
+
afterUpdate: async (u, g, d) => {
|
|
228
|
+
u.tenantId === r && n(d) && await l(d);
|
|
229
229
|
},
|
|
230
|
-
beforeDelete: async (
|
|
231
|
-
if (
|
|
232
|
-
const
|
|
233
|
-
|
|
230
|
+
beforeDelete: async (u, g) => {
|
|
231
|
+
if (u.tenantId !== r) return;
|
|
232
|
+
const m = await t(u.adapters).get(u.tenantId, g);
|
|
233
|
+
m && n(m) && i.set(g, m);
|
|
234
234
|
},
|
|
235
|
-
afterDelete: async (
|
|
236
|
-
if (
|
|
235
|
+
afterDelete: async (u, g) => {
|
|
236
|
+
if (u.tenantId !== r) return;
|
|
237
237
|
const d = i.get(g);
|
|
238
|
-
d && (i.delete(g), await
|
|
238
|
+
d && (i.delete(g), await a(d.name));
|
|
239
239
|
}
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
|
-
function
|
|
243
|
-
const { controlPlaneTenantId: r, getControlPlaneAdapters:
|
|
242
|
+
function W(e, t, n = () => !0) {
|
|
243
|
+
const { controlPlaneTenantId: r, getControlPlaneAdapters: s, getAdapters: o } = e;
|
|
244
244
|
return {
|
|
245
245
|
async afterCreate(i, c) {
|
|
246
246
|
if (c.id !== r)
|
|
247
247
|
try {
|
|
248
|
-
const
|
|
249
|
-
(
|
|
250
|
-
|
|
248
|
+
const l = await s(), a = await o(c.id), u = t(l), g = t(a), d = await D(
|
|
249
|
+
(m) => u.listPaginated(r, m),
|
|
250
|
+
u.listKey,
|
|
251
251
|
{ cursorField: "id", pageSize: 100 }
|
|
252
252
|
);
|
|
253
253
|
await Promise.all(
|
|
254
|
-
d.filter((
|
|
254
|
+
d.filter((m) => n(m)).map(async (m) => {
|
|
255
255
|
try {
|
|
256
|
-
const
|
|
256
|
+
const f = u.transform(m);
|
|
257
257
|
await g.create(c.id, {
|
|
258
|
-
...
|
|
258
|
+
...f,
|
|
259
259
|
is_system: !0
|
|
260
260
|
});
|
|
261
|
-
} catch (
|
|
261
|
+
} catch (f) {
|
|
262
262
|
console.error(
|
|
263
263
|
`Failed to sync entity to new tenant "${c.id}":`,
|
|
264
|
-
|
|
264
|
+
f
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
267
|
})
|
|
268
268
|
);
|
|
269
|
-
} catch (
|
|
269
|
+
} catch (l) {
|
|
270
270
|
console.error(
|
|
271
271
|
`Failed to sync entities to new tenant "${c.id}":`,
|
|
272
|
-
|
|
272
|
+
l
|
|
273
273
|
);
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
};
|
|
277
277
|
}
|
|
278
|
-
const
|
|
278
|
+
const L = (e) => ({
|
|
279
279
|
list: async (t, n) => (await e.resourceServers.list(t, n)).resource_servers,
|
|
280
280
|
listPaginated: (t, n) => e.resourceServers.list(t, n),
|
|
281
281
|
get: (t, n) => e.resourceServers.get(t, n),
|
|
@@ -293,7 +293,7 @@ const W = (e) => ({
|
|
|
293
293
|
token_lifetime: t.token_lifetime,
|
|
294
294
|
token_lifetime_for_web: t.token_lifetime_for_web
|
|
295
295
|
})
|
|
296
|
-
}),
|
|
296
|
+
}), K = (e) => ({
|
|
297
297
|
list: async (t, n) => (await e.roles.list(t, n)).roles,
|
|
298
298
|
listPaginated: (t, n) => e.roles.list(t, n),
|
|
299
299
|
get: (t, n) => e.roles.get(t, n),
|
|
@@ -308,58 +308,58 @@ const W = (e) => ({
|
|
|
308
308
|
description: t.description
|
|
309
309
|
})
|
|
310
310
|
});
|
|
311
|
-
function
|
|
311
|
+
function Q(e) {
|
|
312
312
|
var t;
|
|
313
313
|
return ((t = e.metadata) == null ? void 0 : t.sync) !== !1;
|
|
314
314
|
}
|
|
315
|
-
function
|
|
316
|
-
const { sync: t = {}, filters: n = {} } = e, r = t.resourceServers ?? !0,
|
|
317
|
-
e,
|
|
318
|
-
W,
|
|
319
|
-
s
|
|
320
|
-
) : void 0, u = a ? G(e, L, i) : void 0, o = r ? H(
|
|
315
|
+
function ve(e) {
|
|
316
|
+
const { sync: t = {}, filters: n = {} } = e, r = t.resourceServers ?? !0, s = t.roles ?? !0, o = (f) => Q(f) ? n.resourceServers ? n.resourceServers(f) : !0 : !1, i = (f) => Q(f) ? n.roles ? n.roles(f) : !0 : !1, c = r ? H(
|
|
321
317
|
e,
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
) : void 0, l =
|
|
318
|
+
L,
|
|
319
|
+
o
|
|
320
|
+
) : void 0, l = s ? H(e, K, i) : void 0, a = r ? W(
|
|
325
321
|
e,
|
|
326
322
|
L,
|
|
323
|
+
o
|
|
324
|
+
) : void 0, u = s ? W(
|
|
325
|
+
e,
|
|
326
|
+
K,
|
|
327
327
|
i
|
|
328
|
-
) : void 0, g =
|
|
329
|
-
async afterCreate(
|
|
330
|
-
var
|
|
328
|
+
) : void 0, g = s ? {
|
|
329
|
+
async afterCreate(f, w) {
|
|
330
|
+
var T;
|
|
331
331
|
if (w.id !== e.controlPlaneTenantId) {
|
|
332
|
-
await ((
|
|
332
|
+
await ((T = u == null ? void 0 : u.afterCreate) == null ? void 0 : T.call(u, f, w));
|
|
333
333
|
try {
|
|
334
|
-
const y = await e.getControlPlaneAdapters(), _ = await e.getAdapters(w.id),
|
|
334
|
+
const y = await e.getControlPlaneAdapters(), _ = await e.getAdapters(w.id), P = await D(
|
|
335
335
|
(h) => y.roles.list(
|
|
336
336
|
e.controlPlaneTenantId,
|
|
337
337
|
h
|
|
338
338
|
),
|
|
339
339
|
"roles",
|
|
340
340
|
{ cursorField: "id", pageSize: 100 }
|
|
341
|
-
),
|
|
342
|
-
for (const h of
|
|
343
|
-
(
|
|
341
|
+
), I = /* @__PURE__ */ new Map();
|
|
342
|
+
for (const h of P.filter(
|
|
343
|
+
(C) => {
|
|
344
344
|
var p;
|
|
345
|
-
return ((p = n.roles) == null ? void 0 : p.call(n,
|
|
345
|
+
return ((p = n.roles) == null ? void 0 : p.call(n, C)) ?? !0;
|
|
346
346
|
}
|
|
347
347
|
)) {
|
|
348
|
-
const
|
|
348
|
+
const C = await d(
|
|
349
349
|
_,
|
|
350
350
|
w.id,
|
|
351
351
|
h.name
|
|
352
352
|
);
|
|
353
|
-
|
|
353
|
+
C && I.set(h.name, C.id);
|
|
354
354
|
}
|
|
355
|
-
for (const h of
|
|
356
|
-
(
|
|
355
|
+
for (const h of P.filter(
|
|
356
|
+
(C) => {
|
|
357
357
|
var p;
|
|
358
|
-
return ((p = n.roles) == null ? void 0 : p.call(n,
|
|
358
|
+
return ((p = n.roles) == null ? void 0 : p.call(n, C)) ?? !0;
|
|
359
359
|
}
|
|
360
360
|
)) {
|
|
361
|
-
const
|
|
362
|
-
if (
|
|
361
|
+
const C = I.get(h.name);
|
|
362
|
+
if (C)
|
|
363
363
|
try {
|
|
364
364
|
const p = await y.rolePermissions.list(
|
|
365
365
|
e.controlPlaneTenantId,
|
|
@@ -368,11 +368,11 @@ function ye(e) {
|
|
|
368
368
|
);
|
|
369
369
|
p.length > 0 && await _.rolePermissions.assign(
|
|
370
370
|
w.id,
|
|
371
|
-
|
|
372
|
-
p.map((
|
|
373
|
-
role_id:
|
|
374
|
-
resource_server_identifier:
|
|
375
|
-
permission_name:
|
|
371
|
+
C,
|
|
372
|
+
p.map((F) => ({
|
|
373
|
+
role_id: C,
|
|
374
|
+
resource_server_identifier: F.resource_server_identifier,
|
|
375
|
+
permission_name: F.permission_name
|
|
376
376
|
}))
|
|
377
377
|
);
|
|
378
378
|
} catch (p) {
|
|
@@ -391,29 +391,29 @@ function ye(e) {
|
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
} : void 0;
|
|
394
|
-
async function d(
|
|
395
|
-
return (await
|
|
396
|
-
q: `name:${
|
|
394
|
+
async function d(f, w, T) {
|
|
395
|
+
return (await f.roles.list(w, {
|
|
396
|
+
q: `name:${T}`,
|
|
397
397
|
per_page: 1
|
|
398
398
|
})).roles[0] ?? null;
|
|
399
399
|
}
|
|
400
400
|
return {
|
|
401
401
|
entityHooks: {
|
|
402
402
|
resourceServers: c,
|
|
403
|
-
roles:
|
|
403
|
+
roles: l
|
|
404
404
|
},
|
|
405
405
|
tenantHooks: {
|
|
406
|
-
async afterCreate(
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
(g == null ? void 0 : g.afterCreate) ?? (
|
|
406
|
+
async afterCreate(f, w) {
|
|
407
|
+
const T = [
|
|
408
|
+
a == null ? void 0 : a.afterCreate,
|
|
409
|
+
(g == null ? void 0 : g.afterCreate) ?? (u == null ? void 0 : u.afterCreate)
|
|
410
410
|
], y = [];
|
|
411
|
-
for (const _ of
|
|
411
|
+
for (const _ of T)
|
|
412
412
|
if (_)
|
|
413
413
|
try {
|
|
414
|
-
await _(
|
|
415
|
-
} catch (
|
|
416
|
-
y.push(
|
|
414
|
+
await _(f, w);
|
|
415
|
+
} catch (P) {
|
|
416
|
+
y.push(P instanceof Error ? P : new Error(String(P)));
|
|
417
417
|
}
|
|
418
418
|
if (y.length === 1) throw y[0];
|
|
419
419
|
if (y.length > 1)
|
|
@@ -425,7 +425,7 @@ function ye(e) {
|
|
|
425
425
|
}
|
|
426
426
|
};
|
|
427
427
|
}
|
|
428
|
-
var
|
|
428
|
+
var b = class extends Error {
|
|
429
429
|
/**
|
|
430
430
|
* Creates an instance of `HTTPException`.
|
|
431
431
|
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
@@ -433,8 +433,8 @@ var A = class extends Error {
|
|
|
433
433
|
*/
|
|
434
434
|
constructor(t = 500, n) {
|
|
435
435
|
super(n == null ? void 0 : n.message, { cause: n == null ? void 0 : n.cause });
|
|
436
|
-
|
|
437
|
-
|
|
436
|
+
E(this, "res");
|
|
437
|
+
E(this, "status");
|
|
438
438
|
this.res = n == null ? void 0 : n.res, this.status = t;
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
@@ -452,14 +452,14 @@ var A = class extends Error {
|
|
|
452
452
|
}
|
|
453
453
|
};
|
|
454
454
|
function N(e, t) {
|
|
455
|
-
const n = new
|
|
455
|
+
const n = new de();
|
|
456
456
|
return n.openapi(
|
|
457
457
|
M({
|
|
458
458
|
tags: ["tenants"],
|
|
459
459
|
method: "get",
|
|
460
460
|
path: "/",
|
|
461
461
|
request: {
|
|
462
|
-
query:
|
|
462
|
+
query: oe
|
|
463
463
|
},
|
|
464
464
|
security: [
|
|
465
465
|
{
|
|
@@ -470,11 +470,11 @@ function N(e, t) {
|
|
|
470
470
|
200: {
|
|
471
471
|
content: {
|
|
472
472
|
"application/json": {
|
|
473
|
-
schema:
|
|
474
|
-
tenants:
|
|
475
|
-
start:
|
|
476
|
-
limit:
|
|
477
|
-
length:
|
|
473
|
+
schema: S.object({
|
|
474
|
+
tenants: S.array(O),
|
|
475
|
+
start: S.number().optional(),
|
|
476
|
+
limit: S.number().optional(),
|
|
477
|
+
length: S.number().optional()
|
|
478
478
|
})
|
|
479
479
|
}
|
|
480
480
|
},
|
|
@@ -483,70 +483,74 @@ function N(e, t) {
|
|
|
483
483
|
}
|
|
484
484
|
}),
|
|
485
485
|
async (r) => {
|
|
486
|
-
var
|
|
487
|
-
const
|
|
488
|
-
if (
|
|
489
|
-
const
|
|
490
|
-
page:
|
|
486
|
+
var w, T, y, _, P, I;
|
|
487
|
+
const s = r.req.valid("query"), { page: o, per_page: i, include_totals: c, q: l } = s, a = r.var.user, u = (a == null ? void 0 : a.permissions) || [];
|
|
488
|
+
if (!!!((a == null ? void 0 : a.org_id) ?? r.var.organization_id) && u.includes("admin:organizations")) {
|
|
489
|
+
const h = await r.env.data.tenants.list({
|
|
490
|
+
page: o,
|
|
491
491
|
per_page: i,
|
|
492
492
|
include_totals: c,
|
|
493
|
-
q:
|
|
493
|
+
q: l
|
|
494
494
|
});
|
|
495
495
|
return c ? r.json({
|
|
496
|
-
tenants:
|
|
497
|
-
start: ((
|
|
498
|
-
limit: ((
|
|
499
|
-
length:
|
|
500
|
-
}) : r.json({ tenants:
|
|
496
|
+
tenants: h.tenants,
|
|
497
|
+
start: ((w = h.totals) == null ? void 0 : w.start) ?? 0,
|
|
498
|
+
limit: ((T = h.totals) == null ? void 0 : T.limit) ?? i,
|
|
499
|
+
length: h.tenants.length
|
|
500
|
+
}) : r.json({ tenants: h.tenants });
|
|
501
501
|
}
|
|
502
|
-
const
|
|
503
|
-
if (
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
502
|
+
const m = ((y = e.accessControl) == null ? void 0 : y.controlPlaneTenantId) ?? ((_ = r.env.data.multiTenancyConfig) == null ? void 0 : _.controlPlaneTenantId);
|
|
503
|
+
if (m && !(a != null && a.sub))
|
|
504
|
+
throw new b(403, {
|
|
505
|
+
message: "Access denied: token has no subject"
|
|
506
|
+
});
|
|
507
|
+
if (m && (a != null && a.sub)) {
|
|
508
|
+
const C = (await D(
|
|
509
|
+
(k) => r.env.data.userOrganizations.listUserOrganizations(
|
|
510
|
+
m,
|
|
511
|
+
a.sub,
|
|
512
|
+
k
|
|
509
513
|
),
|
|
510
514
|
"organizations"
|
|
511
|
-
)).map((
|
|
512
|
-
if (
|
|
515
|
+
)).map((k) => k.name);
|
|
516
|
+
if (C.length === 0)
|
|
513
517
|
return c ? r.json({
|
|
514
518
|
tenants: [],
|
|
515
519
|
start: 0,
|
|
516
520
|
limit: i ?? 50,
|
|
517
521
|
length: 0
|
|
518
522
|
}) : r.json({ tenants: [] });
|
|
519
|
-
const
|
|
520
|
-
if (
|
|
523
|
+
const p = C.length, F = o ?? 0, $ = i ?? 50, R = F * $, A = C.slice(R, R + $);
|
|
524
|
+
if (A.length === 0)
|
|
521
525
|
return c ? r.json({
|
|
522
526
|
tenants: [],
|
|
523
|
-
start:
|
|
524
|
-
limit:
|
|
525
|
-
length:
|
|
527
|
+
start: R,
|
|
528
|
+
limit: $,
|
|
529
|
+
length: p
|
|
526
530
|
}) : r.json({ tenants: [] });
|
|
527
|
-
const
|
|
528
|
-
q:
|
|
529
|
-
per_page:
|
|
531
|
+
const v = A.map((k) => `id:${k}`).join(" OR "), j = l ? `(${v}) AND (${l})` : v, z = await r.env.data.tenants.list({
|
|
532
|
+
q: j,
|
|
533
|
+
per_page: $,
|
|
530
534
|
include_totals: !1
|
|
531
535
|
// We calculate totals from accessibleTenantIds
|
|
532
536
|
});
|
|
533
537
|
return c ? r.json({
|
|
534
|
-
tenants:
|
|
535
|
-
start:
|
|
536
|
-
limit:
|
|
537
|
-
length:
|
|
538
|
-
}) : r.json({ tenants:
|
|
538
|
+
tenants: z.tenants,
|
|
539
|
+
start: R,
|
|
540
|
+
limit: $,
|
|
541
|
+
length: p
|
|
542
|
+
}) : r.json({ tenants: z.tenants });
|
|
539
543
|
}
|
|
540
544
|
const f = await r.env.data.tenants.list({
|
|
541
|
-
page:
|
|
545
|
+
page: o,
|
|
542
546
|
per_page: i,
|
|
543
547
|
include_totals: c,
|
|
544
|
-
q:
|
|
548
|
+
q: l
|
|
545
549
|
});
|
|
546
550
|
return c ? r.json({
|
|
547
551
|
tenants: f.tenants,
|
|
548
|
-
start: ((
|
|
549
|
-
limit: ((
|
|
552
|
+
start: ((P = f.totals) == null ? void 0 : P.start) ?? 0,
|
|
553
|
+
limit: ((I = f.totals) == null ? void 0 : I.limit) ?? i,
|
|
550
554
|
length: f.tenants.length
|
|
551
555
|
}) : r.json({ tenants: f.tenants });
|
|
552
556
|
}
|
|
@@ -559,7 +563,7 @@ function N(e, t) {
|
|
|
559
563
|
body: {
|
|
560
564
|
content: {
|
|
561
565
|
"application/json": {
|
|
562
|
-
schema:
|
|
566
|
+
schema: G
|
|
563
567
|
}
|
|
564
568
|
}
|
|
565
569
|
}
|
|
@@ -573,7 +577,7 @@ function N(e, t) {
|
|
|
573
577
|
201: {
|
|
574
578
|
content: {
|
|
575
579
|
"application/json": {
|
|
576
|
-
schema:
|
|
580
|
+
schema: O
|
|
577
581
|
}
|
|
578
582
|
},
|
|
579
583
|
description: "Tenant created"
|
|
@@ -587,20 +591,20 @@ function N(e, t) {
|
|
|
587
591
|
}
|
|
588
592
|
}),
|
|
589
593
|
async (r) => {
|
|
590
|
-
var
|
|
591
|
-
const
|
|
592
|
-
if (!(
|
|
593
|
-
throw new
|
|
594
|
+
var l, a;
|
|
595
|
+
const s = r.var.user;
|
|
596
|
+
if (!(s != null && s.sub))
|
|
597
|
+
throw new b(401, {
|
|
594
598
|
message: "Authentication required to create tenants"
|
|
595
599
|
});
|
|
596
|
-
let
|
|
600
|
+
let o = r.req.valid("json");
|
|
597
601
|
const i = {
|
|
598
602
|
adapters: r.env.data,
|
|
599
603
|
ctx: r
|
|
600
604
|
};
|
|
601
|
-
(
|
|
602
|
-
const c = await r.env.data.tenants.create(
|
|
603
|
-
return (
|
|
605
|
+
(l = t.tenants) != null && l.beforeCreate && (o = await t.tenants.beforeCreate(i, o));
|
|
606
|
+
const c = await r.env.data.tenants.create(o);
|
|
607
|
+
return (a = t.tenants) != null && a.afterCreate && await t.tenants.afterCreate(i, c), r.json(c, 201);
|
|
604
608
|
}
|
|
605
609
|
), n.openapi(
|
|
606
610
|
M({
|
|
@@ -608,8 +612,8 @@ function N(e, t) {
|
|
|
608
612
|
method: "delete",
|
|
609
613
|
path: "/{id}",
|
|
610
614
|
request: {
|
|
611
|
-
params:
|
|
612
|
-
id:
|
|
615
|
+
params: S.object({
|
|
616
|
+
id: S.string()
|
|
613
617
|
})
|
|
614
618
|
},
|
|
615
619
|
security: [
|
|
@@ -630,39 +634,39 @@ function N(e, t) {
|
|
|
630
634
|
}
|
|
631
635
|
}),
|
|
632
636
|
async (r) => {
|
|
633
|
-
var
|
|
634
|
-
const { id:
|
|
635
|
-
if (
|
|
637
|
+
var l, a, u, g;
|
|
638
|
+
const { id: s } = r.req.valid("param"), o = ((l = e.accessControl) == null ? void 0 : l.controlPlaneTenantId) ?? ((a = r.env.data.multiTenancyConfig) == null ? void 0 : a.controlPlaneTenantId);
|
|
639
|
+
if (o) {
|
|
636
640
|
const d = r.var.user;
|
|
637
641
|
if (!(d != null && d.sub))
|
|
638
|
-
throw new
|
|
642
|
+
throw new b(401, {
|
|
639
643
|
message: "Authentication required"
|
|
640
644
|
});
|
|
641
|
-
if (
|
|
642
|
-
throw new
|
|
645
|
+
if (s === o)
|
|
646
|
+
throw new b(403, {
|
|
643
647
|
message: "Cannot delete the control plane"
|
|
644
648
|
});
|
|
645
649
|
if (!(await D(
|
|
646
650
|
(w) => r.env.data.userOrganizations.listUserOrganizations(
|
|
647
|
-
|
|
651
|
+
o,
|
|
648
652
|
d.sub,
|
|
649
653
|
w
|
|
650
654
|
),
|
|
651
655
|
"organizations"
|
|
652
|
-
)).some((w) => w.name ===
|
|
653
|
-
throw new
|
|
656
|
+
)).some((w) => w.name === s))
|
|
657
|
+
throw new b(403, {
|
|
654
658
|
message: "Access denied to this tenant"
|
|
655
659
|
});
|
|
656
660
|
}
|
|
657
|
-
if (!await r.env.data.tenants.get(
|
|
658
|
-
throw new
|
|
661
|
+
if (!await r.env.data.tenants.get(s))
|
|
662
|
+
throw new b(404, {
|
|
659
663
|
message: "Tenant not found"
|
|
660
664
|
});
|
|
661
665
|
const c = {
|
|
662
666
|
adapters: r.env.data,
|
|
663
667
|
ctx: r
|
|
664
668
|
};
|
|
665
|
-
return (
|
|
669
|
+
return (u = t.tenants) != null && u.beforeDelete && await t.tenants.beforeDelete(c, s), await r.env.data.tenants.remove(s), (g = t.tenants) != null && g.afterDelete && await t.tenants.afterDelete(c, s), r.body(null, 204);
|
|
666
670
|
}
|
|
667
671
|
), n.openapi(
|
|
668
672
|
M({
|
|
@@ -670,8 +674,8 @@ function N(e, t) {
|
|
|
670
674
|
method: "get",
|
|
671
675
|
path: "/settings",
|
|
672
676
|
request: {
|
|
673
|
-
headers:
|
|
674
|
-
"tenant-id":
|
|
677
|
+
headers: S.object({
|
|
678
|
+
"tenant-id": S.string().optional()
|
|
675
679
|
})
|
|
676
680
|
},
|
|
677
681
|
security: [
|
|
@@ -683,7 +687,7 @@ function N(e, t) {
|
|
|
683
687
|
200: {
|
|
684
688
|
content: {
|
|
685
689
|
"application/json": {
|
|
686
|
-
schema:
|
|
690
|
+
schema: O
|
|
687
691
|
}
|
|
688
692
|
},
|
|
689
693
|
description: "Current tenant settings"
|
|
@@ -691,12 +695,12 @@ function N(e, t) {
|
|
|
691
695
|
}
|
|
692
696
|
}),
|
|
693
697
|
async (r) => {
|
|
694
|
-
const
|
|
695
|
-
if (!
|
|
696
|
-
throw new
|
|
698
|
+
const s = await r.env.data.tenants.get(r.var.tenant_id);
|
|
699
|
+
if (!s)
|
|
700
|
+
throw new b(404, {
|
|
697
701
|
message: "Tenant not found"
|
|
698
702
|
});
|
|
699
|
-
return r.json(
|
|
703
|
+
return r.json(s);
|
|
700
704
|
}
|
|
701
705
|
), n.openapi(
|
|
702
706
|
M({
|
|
@@ -704,13 +708,13 @@ function N(e, t) {
|
|
|
704
708
|
method: "patch",
|
|
705
709
|
path: "/settings",
|
|
706
710
|
request: {
|
|
707
|
-
headers:
|
|
708
|
-
"tenant-id":
|
|
711
|
+
headers: S.object({
|
|
712
|
+
"tenant-id": S.string().optional()
|
|
709
713
|
}),
|
|
710
714
|
body: {
|
|
711
715
|
content: {
|
|
712
716
|
"application/json": {
|
|
713
|
-
schema:
|
|
717
|
+
schema: S.object(G.shape).partial()
|
|
714
718
|
}
|
|
715
719
|
}
|
|
716
720
|
}
|
|
@@ -724,7 +728,7 @@ function N(e, t) {
|
|
|
724
728
|
200: {
|
|
725
729
|
content: {
|
|
726
730
|
"application/json": {
|
|
727
|
-
schema:
|
|
731
|
+
schema: O
|
|
728
732
|
}
|
|
729
733
|
},
|
|
730
734
|
description: "Updated tenant settings"
|
|
@@ -732,23 +736,23 @@ function N(e, t) {
|
|
|
732
736
|
}
|
|
733
737
|
}),
|
|
734
738
|
async (r) => {
|
|
735
|
-
const
|
|
739
|
+
const s = r.req.valid("json"), { id: o, ...i } = s, c = await r.env.data.tenants.get(r.var.tenant_id);
|
|
736
740
|
if (!c)
|
|
737
|
-
throw new
|
|
741
|
+
throw new b(404, {
|
|
738
742
|
message: "Tenant not found"
|
|
739
743
|
});
|
|
740
|
-
const
|
|
741
|
-
await r.env.data.tenants.update(r.var.tenant_id,
|
|
742
|
-
const
|
|
743
|
-
if (!
|
|
744
|
-
throw new
|
|
744
|
+
const l = ie(c, i);
|
|
745
|
+
await r.env.data.tenants.update(r.var.tenant_id, l);
|
|
746
|
+
const a = await r.env.data.tenants.get(r.var.tenant_id);
|
|
747
|
+
if (!a)
|
|
748
|
+
throw new b(500, {
|
|
745
749
|
message: "Failed to retrieve updated tenant"
|
|
746
750
|
});
|
|
747
|
-
return r.json(
|
|
751
|
+
return r.json(a);
|
|
748
752
|
}
|
|
749
753
|
), n;
|
|
750
754
|
}
|
|
751
|
-
function
|
|
755
|
+
function _e(e) {
|
|
752
756
|
const t = [
|
|
753
757
|
{
|
|
754
758
|
pattern: /\/api\/v2\/resource-servers\/([^/]+)$/,
|
|
@@ -758,13 +762,13 @@ function ve(e) {
|
|
|
758
762
|
{ pattern: /\/api\/v2\/connections\/([^/]+)$/, type: "connection" }
|
|
759
763
|
];
|
|
760
764
|
for (const { pattern: n, type: r } of t) {
|
|
761
|
-
const
|
|
762
|
-
if (
|
|
763
|
-
return { type: r, id:
|
|
765
|
+
const s = e.match(n);
|
|
766
|
+
if (s && s[1])
|
|
767
|
+
return { type: r, id: s[1] };
|
|
764
768
|
}
|
|
765
769
|
return null;
|
|
766
770
|
}
|
|
767
|
-
async function
|
|
771
|
+
async function Ce(e, t, n) {
|
|
768
772
|
try {
|
|
769
773
|
switch (n.type) {
|
|
770
774
|
case "resource_server": {
|
|
@@ -786,50 +790,50 @@ async function _e(e, t, n) {
|
|
|
786
790
|
return !1;
|
|
787
791
|
}
|
|
788
792
|
}
|
|
789
|
-
function
|
|
793
|
+
function Te(e) {
|
|
790
794
|
return {
|
|
791
795
|
resource_server: "resource server",
|
|
792
796
|
role: "role",
|
|
793
797
|
connection: "connection"
|
|
794
798
|
}[e];
|
|
795
799
|
}
|
|
796
|
-
function
|
|
800
|
+
function be() {
|
|
797
801
|
return async (e, t) => {
|
|
798
802
|
if (!["PATCH", "PUT", "DELETE"].includes(e.req.method))
|
|
799
803
|
return t();
|
|
800
|
-
const n =
|
|
804
|
+
const n = _e(e.req.path);
|
|
801
805
|
if (!n)
|
|
802
806
|
return t();
|
|
803
807
|
const r = e.var.tenant_id || e.req.header("x-tenant-id") || e.req.header("tenant-id");
|
|
804
808
|
if (!r)
|
|
805
809
|
return t();
|
|
806
|
-
if (await
|
|
807
|
-
throw new
|
|
808
|
-
message: `This ${
|
|
810
|
+
if (await Ce(e.env.data, r, n))
|
|
811
|
+
throw new b(403, {
|
|
812
|
+
message: `This ${Te(n.type)} is a system resource and cannot be modified. Make changes in the control plane instead.`
|
|
809
813
|
});
|
|
810
814
|
return t();
|
|
811
815
|
};
|
|
812
816
|
}
|
|
813
|
-
function
|
|
817
|
+
function B(e, t) {
|
|
814
818
|
const n = t.find(
|
|
815
|
-
(
|
|
819
|
+
(s) => s.strategy === e.strategy
|
|
816
820
|
);
|
|
817
821
|
if (!(n != null && n.options))
|
|
818
822
|
return e;
|
|
819
|
-
const r =
|
|
823
|
+
const r = ce.passthrough().parse({
|
|
820
824
|
...n,
|
|
821
825
|
...e
|
|
822
826
|
});
|
|
823
|
-
return r.options =
|
|
827
|
+
return r.options = le.passthrough().parse({
|
|
824
828
|
...n.options || {},
|
|
825
829
|
...e.options
|
|
826
830
|
}), r;
|
|
827
831
|
}
|
|
828
|
-
function
|
|
832
|
+
function q(e, t) {
|
|
829
833
|
const n = [...t || [], ...e || []];
|
|
830
834
|
return [...new Set(n)];
|
|
831
835
|
}
|
|
832
|
-
function
|
|
836
|
+
function Pe(e, t) {
|
|
833
837
|
if (!(t != null && t.length))
|
|
834
838
|
return e || [];
|
|
835
839
|
if (!(e != null && e.length))
|
|
@@ -841,91 +845,91 @@ function be(e, t) {
|
|
|
841
845
|
n.set(r.value, r);
|
|
842
846
|
return Array.from(n.values());
|
|
843
847
|
}
|
|
844
|
-
function
|
|
848
|
+
function V(e, t) {
|
|
845
849
|
return t ? {
|
|
846
850
|
...e,
|
|
847
|
-
scopes:
|
|
851
|
+
scopes: Pe(
|
|
848
852
|
e.scopes,
|
|
849
853
|
t.scopes
|
|
850
854
|
)
|
|
851
855
|
} : e;
|
|
852
856
|
}
|
|
853
|
-
function
|
|
857
|
+
function J(e, t) {
|
|
854
858
|
return t ? {
|
|
855
859
|
...e,
|
|
856
|
-
callbacks:
|
|
857
|
-
web_origins:
|
|
860
|
+
callbacks: q(e.callbacks, t.callbacks),
|
|
861
|
+
web_origins: q(
|
|
858
862
|
e.web_origins,
|
|
859
863
|
t.web_origins
|
|
860
864
|
),
|
|
861
|
-
allowed_logout_urls:
|
|
865
|
+
allowed_logout_urls: q(
|
|
862
866
|
e.allowed_logout_urls,
|
|
863
867
|
t.allowed_logout_urls
|
|
864
868
|
),
|
|
865
|
-
allowed_origins:
|
|
869
|
+
allowed_origins: q(
|
|
866
870
|
e.allowed_origins,
|
|
867
871
|
t.allowed_origins
|
|
868
872
|
)
|
|
869
873
|
} : e;
|
|
870
874
|
}
|
|
871
|
-
function
|
|
875
|
+
function x(e, t) {
|
|
872
876
|
return {
|
|
873
877
|
...e.resourceServers,
|
|
874
878
|
get: async (n, r) => {
|
|
875
|
-
const
|
|
879
|
+
const s = await e.resourceServers.get(
|
|
876
880
|
n,
|
|
877
881
|
r
|
|
878
882
|
);
|
|
879
|
-
if (!
|
|
880
|
-
return
|
|
881
|
-
const
|
|
883
|
+
if (!s || !t || n === t || !s.is_system)
|
|
884
|
+
return s;
|
|
885
|
+
const o = await e.resourceServers.get(
|
|
882
886
|
t,
|
|
883
887
|
r
|
|
884
888
|
);
|
|
885
|
-
return
|
|
886
|
-
|
|
887
|
-
|
|
889
|
+
return V(
|
|
890
|
+
s,
|
|
891
|
+
o
|
|
888
892
|
);
|
|
889
893
|
},
|
|
890
894
|
list: async (n, r) => {
|
|
891
|
-
const
|
|
895
|
+
const s = await e.resourceServers.list(n, r);
|
|
892
896
|
if (!t || n === t)
|
|
893
|
-
return
|
|
894
|
-
const
|
|
895
|
-
(
|
|
896
|
-
).map((
|
|
897
|
+
return s;
|
|
898
|
+
const o = t, i = s.resource_servers.filter(
|
|
899
|
+
(a) => !!(a.is_system && a.id)
|
|
900
|
+
).map((a) => a.id);
|
|
897
901
|
if (i.length === 0)
|
|
898
|
-
return
|
|
902
|
+
return s;
|
|
899
903
|
const c = /* @__PURE__ */ new Map();
|
|
900
904
|
await Promise.all(
|
|
901
|
-
i.map(async (
|
|
902
|
-
const
|
|
903
|
-
|
|
905
|
+
i.map(async (a) => {
|
|
906
|
+
const u = await e.resourceServers.get(o, a);
|
|
907
|
+
u && c.set(a, u);
|
|
904
908
|
})
|
|
905
909
|
);
|
|
906
|
-
const
|
|
907
|
-
(
|
|
908
|
-
|
|
909
|
-
c.get(
|
|
910
|
-
) :
|
|
910
|
+
const l = s.resource_servers.map(
|
|
911
|
+
(a) => a.is_system && a.id ? V(
|
|
912
|
+
a,
|
|
913
|
+
c.get(a.id) ?? null
|
|
914
|
+
) : a
|
|
911
915
|
);
|
|
912
916
|
return {
|
|
913
|
-
...
|
|
914
|
-
resource_servers:
|
|
917
|
+
...s,
|
|
918
|
+
resource_servers: l
|
|
915
919
|
};
|
|
916
920
|
}
|
|
917
921
|
};
|
|
918
922
|
}
|
|
919
|
-
function
|
|
923
|
+
function Ae(e, t) {
|
|
920
924
|
return {
|
|
921
925
|
...e,
|
|
922
|
-
resourceServers:
|
|
926
|
+
resourceServers: x(
|
|
923
927
|
e,
|
|
924
928
|
t.controlPlaneTenantId
|
|
925
929
|
)
|
|
926
930
|
};
|
|
927
931
|
}
|
|
928
|
-
function
|
|
932
|
+
function Se(e, t) {
|
|
929
933
|
const { controlPlaneTenantId: n, controlPlaneClientId: r } = t;
|
|
930
934
|
return {
|
|
931
935
|
...e,
|
|
@@ -936,48 +940,48 @@ function Ae(e, t) {
|
|
|
936
940
|
},
|
|
937
941
|
connections: {
|
|
938
942
|
...e.connections,
|
|
939
|
-
get: async (
|
|
943
|
+
get: async (s, o) => {
|
|
940
944
|
const i = await e.connections.get(
|
|
941
|
-
|
|
942
|
-
|
|
945
|
+
s,
|
|
946
|
+
o
|
|
943
947
|
);
|
|
944
|
-
if (!i || !n ||
|
|
948
|
+
if (!i || !n || s === n)
|
|
945
949
|
return i;
|
|
946
950
|
const c = await e.connections.list(n);
|
|
947
|
-
return
|
|
951
|
+
return B(
|
|
948
952
|
i,
|
|
949
953
|
c.connections || []
|
|
950
954
|
);
|
|
951
955
|
},
|
|
952
|
-
list: async (
|
|
953
|
-
const i = await e.connections.list(
|
|
954
|
-
if (!n ||
|
|
956
|
+
list: async (s, o) => {
|
|
957
|
+
const i = await e.connections.list(s, o);
|
|
958
|
+
if (!n || s === n)
|
|
955
959
|
return i;
|
|
956
|
-
const c = await e.connections.list(n),
|
|
957
|
-
(
|
|
958
|
-
|
|
960
|
+
const c = await e.connections.list(n), l = i.connections.map(
|
|
961
|
+
(a) => B(
|
|
962
|
+
a,
|
|
959
963
|
c.connections || []
|
|
960
964
|
)
|
|
961
965
|
);
|
|
962
966
|
return {
|
|
963
967
|
...i,
|
|
964
|
-
connections:
|
|
968
|
+
connections: l
|
|
965
969
|
};
|
|
966
970
|
}
|
|
967
971
|
},
|
|
968
972
|
clientConnections: {
|
|
969
973
|
...e.clientConnections,
|
|
970
|
-
listByClient: async (
|
|
974
|
+
listByClient: async (s, o) => {
|
|
971
975
|
let i = await e.clientConnections.listByClient(
|
|
972
|
-
|
|
973
|
-
|
|
976
|
+
s,
|
|
977
|
+
o
|
|
974
978
|
);
|
|
975
|
-
if (i.length === 0 && (i = (await e.connections.list(
|
|
979
|
+
if (i.length === 0 && (i = (await e.connections.list(s)).connections || []), !n || s === n)
|
|
976
980
|
return i;
|
|
977
981
|
const c = await e.connections.list(n);
|
|
978
982
|
return i.map(
|
|
979
|
-
(
|
|
980
|
-
|
|
983
|
+
(l) => B(
|
|
984
|
+
l,
|
|
981
985
|
c.connections || []
|
|
982
986
|
)
|
|
983
987
|
);
|
|
@@ -985,248 +989,246 @@ function Ae(e, t) {
|
|
|
985
989
|
},
|
|
986
990
|
clients: {
|
|
987
991
|
...e.clients,
|
|
988
|
-
get: async (
|
|
989
|
-
const i = await e.clients.get(
|
|
992
|
+
get: async (s, o) => {
|
|
993
|
+
const i = await e.clients.get(s, o);
|
|
990
994
|
if (!i)
|
|
991
995
|
return null;
|
|
992
|
-
if (!n || !r ||
|
|
996
|
+
if (!n || !r || s === n && o === r)
|
|
993
997
|
return i;
|
|
994
998
|
const c = await e.clients.get(
|
|
995
999
|
n,
|
|
996
1000
|
r
|
|
997
1001
|
);
|
|
998
|
-
return
|
|
1002
|
+
return J(i, c);
|
|
999
1003
|
},
|
|
1000
|
-
getByClientId: async (
|
|
1001
|
-
const
|
|
1002
|
-
if (!
|
|
1004
|
+
getByClientId: async (s) => {
|
|
1005
|
+
const o = await e.clients.getByClientId(s);
|
|
1006
|
+
if (!o)
|
|
1003
1007
|
return null;
|
|
1004
|
-
if (!n || !r ||
|
|
1005
|
-
return
|
|
1008
|
+
if (!n || !r || o.tenant_id === n && o.client_id === r)
|
|
1009
|
+
return o;
|
|
1006
1010
|
const i = await e.clients.get(
|
|
1007
1011
|
n,
|
|
1008
1012
|
r
|
|
1009
1013
|
);
|
|
1010
1014
|
return {
|
|
1011
|
-
...
|
|
1012
|
-
tenant_id:
|
|
1015
|
+
...J(o, i),
|
|
1016
|
+
tenant_id: o.tenant_id
|
|
1013
1017
|
};
|
|
1014
1018
|
}
|
|
1015
1019
|
},
|
|
1016
1020
|
emailProviders: {
|
|
1017
1021
|
...e.emailProviders,
|
|
1018
|
-
get: async (
|
|
1019
|
-
const
|
|
1020
|
-
return
|
|
1022
|
+
get: async (s) => {
|
|
1023
|
+
const o = await e.emailProviders.get(s);
|
|
1024
|
+
return o || (!n || s === n ? null : e.emailProviders.get(n));
|
|
1021
1025
|
}
|
|
1022
1026
|
},
|
|
1023
|
-
resourceServers:
|
|
1027
|
+
resourceServers: x(
|
|
1024
1028
|
e,
|
|
1025
1029
|
n
|
|
1026
1030
|
),
|
|
1027
|
-
hooks:
|
|
1031
|
+
hooks: Ie(e, n)
|
|
1028
1032
|
// Note: Additional adapters can be extended here for runtime fallback:
|
|
1029
1033
|
// - promptSettings: Fall back to control plane prompts
|
|
1030
1034
|
// - branding: Fall back to control plane branding/themes
|
|
1031
1035
|
};
|
|
1032
1036
|
}
|
|
1033
|
-
function
|
|
1037
|
+
function X(e) {
|
|
1034
1038
|
if (!e || typeof e != "object") return !1;
|
|
1035
1039
|
const t = e.metadata;
|
|
1036
1040
|
return !t || typeof t != "object" ? !1 : t.inheritable === !0;
|
|
1037
1041
|
}
|
|
1038
|
-
function
|
|
1042
|
+
function Ie(e, t) {
|
|
1039
1043
|
return {
|
|
1040
1044
|
...e.hooks,
|
|
1041
1045
|
list: async (n, r) => {
|
|
1042
|
-
const
|
|
1046
|
+
const s = await e.hooks.list(n, r);
|
|
1043
1047
|
if (!t || n === t)
|
|
1044
|
-
return
|
|
1048
|
+
return s;
|
|
1045
1049
|
const i = ((await e.hooks.list(
|
|
1046
1050
|
t,
|
|
1047
1051
|
r
|
|
1048
1052
|
)).hooks || []).filter(
|
|
1049
|
-
|
|
1053
|
+
X
|
|
1050
1054
|
);
|
|
1051
1055
|
if (i.length === 0)
|
|
1052
|
-
return
|
|
1053
|
-
const c = new Set(
|
|
1054
|
-
(a.hooks || []).map((o) => o.hook_id)
|
|
1055
|
-
), u = i.filter((o) => !c.has(o.hook_id));
|
|
1056
|
+
return s;
|
|
1057
|
+
const c = new Set((s.hooks || []).map((a) => a.hook_id)), l = i.filter((a) => !c.has(a.hook_id));
|
|
1056
1058
|
return {
|
|
1057
|
-
...
|
|
1058
|
-
hooks: [...
|
|
1059
|
-
length: typeof
|
|
1059
|
+
...s,
|
|
1060
|
+
hooks: [...s.hooks || [], ...l],
|
|
1061
|
+
length: typeof s.length == "number" ? s.length + l.length : s.length
|
|
1060
1062
|
};
|
|
1061
1063
|
},
|
|
1062
1064
|
get: async (n, r) => {
|
|
1063
|
-
const
|
|
1064
|
-
if (
|
|
1065
|
-
return
|
|
1066
|
-
const
|
|
1065
|
+
const s = await e.hooks.get(n, r);
|
|
1066
|
+
if (s || !t || n === t)
|
|
1067
|
+
return s;
|
|
1068
|
+
const o = await e.hooks.get(
|
|
1067
1069
|
t,
|
|
1068
1070
|
r
|
|
1069
1071
|
);
|
|
1070
|
-
return
|
|
1072
|
+
return o && X(o) ? o : null;
|
|
1071
1073
|
}
|
|
1072
1074
|
};
|
|
1073
1075
|
}
|
|
1074
|
-
function
|
|
1075
|
-
return
|
|
1076
|
+
function ee(e, t) {
|
|
1077
|
+
return Se(e, t);
|
|
1076
1078
|
}
|
|
1077
|
-
function
|
|
1079
|
+
function Re(e) {
|
|
1078
1080
|
return async (t, n) => {
|
|
1079
1081
|
const r = t.var.user;
|
|
1080
1082
|
return (r == null ? void 0 : r.tenant_id) === e && r.org_name && t.set("tenant_id", r.org_name), n();
|
|
1081
1083
|
};
|
|
1082
1084
|
}
|
|
1083
|
-
function
|
|
1085
|
+
function ze(e) {
|
|
1084
1086
|
return async (t, n) => {
|
|
1085
1087
|
if (!e.accessControl)
|
|
1086
1088
|
return n();
|
|
1087
|
-
const { controlPlaneTenantId: r } = e.accessControl,
|
|
1089
|
+
const { controlPlaneTenantId: r } = e.accessControl, s = t.var.org_name, o = t.var.organization_id, i = s || o;
|
|
1088
1090
|
let c = t.var.tenant_id;
|
|
1089
|
-
const
|
|
1090
|
-
if (!c && i &&
|
|
1091
|
-
throw new
|
|
1091
|
+
const l = t.var.user, u = (l != null && l.aud ? Array.isArray(l.aud) ? l.aud : [l.aud] : []).includes(Y);
|
|
1092
|
+
if (!c && i && u && (t.set("tenant_id", i), c = i), !c)
|
|
1093
|
+
throw new b(400, {
|
|
1092
1094
|
message: "Tenant ID not found in request"
|
|
1093
1095
|
});
|
|
1094
|
-
if (!
|
|
1095
|
-
|
|
1096
|
+
if (!me(
|
|
1097
|
+
o,
|
|
1096
1098
|
c,
|
|
1097
1099
|
r,
|
|
1098
|
-
|
|
1100
|
+
s
|
|
1099
1101
|
))
|
|
1100
|
-
throw new
|
|
1102
|
+
throw new b(403, {
|
|
1101
1103
|
message: `Access denied to tenant ${c}`
|
|
1102
1104
|
});
|
|
1103
1105
|
return n();
|
|
1104
1106
|
};
|
|
1105
1107
|
}
|
|
1106
|
-
function
|
|
1108
|
+
function $e(e) {
|
|
1107
1109
|
return async (t, n) => {
|
|
1108
1110
|
if (!e.subdomainRouting)
|
|
1109
1111
|
return n();
|
|
1110
1112
|
const {
|
|
1111
1113
|
baseDomain: r,
|
|
1112
|
-
reservedSubdomains:
|
|
1113
|
-
resolveSubdomain:
|
|
1114
|
+
reservedSubdomains: s = [],
|
|
1115
|
+
resolveSubdomain: o
|
|
1114
1116
|
} = e.subdomainRouting, i = t.req.header("x-forwarded-host") || t.req.header("host") || "";
|
|
1115
1117
|
let c = null;
|
|
1116
1118
|
if (i.endsWith(r)) {
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1119
|
+
const a = i.slice(0, -(r.length + 1));
|
|
1120
|
+
a && !a.includes(".") && (c = a);
|
|
1119
1121
|
}
|
|
1120
|
-
if (c &&
|
|
1122
|
+
if (c && s.includes(c) && (c = null), !c)
|
|
1121
1123
|
return e.accessControl && t.set("tenant_id", e.accessControl.controlPlaneTenantId), n();
|
|
1122
|
-
let
|
|
1123
|
-
if (
|
|
1124
|
-
|
|
1124
|
+
let l = null;
|
|
1125
|
+
if (o)
|
|
1126
|
+
l = await o(c);
|
|
1125
1127
|
else if (e.subdomainRouting.useOrganizations !== !1 && e.accessControl)
|
|
1126
1128
|
try {
|
|
1127
|
-
const
|
|
1129
|
+
const a = await t.env.data.organizations.get(
|
|
1128
1130
|
e.accessControl.controlPlaneTenantId,
|
|
1129
1131
|
c
|
|
1130
1132
|
);
|
|
1131
|
-
|
|
1133
|
+
a && (l = a.id);
|
|
1132
1134
|
} catch {
|
|
1133
1135
|
}
|
|
1134
|
-
if (!
|
|
1135
|
-
throw new
|
|
1136
|
+
if (!l)
|
|
1137
|
+
throw new b(404, {
|
|
1136
1138
|
message: `Tenant not found for subdomain: ${c}`
|
|
1137
1139
|
});
|
|
1138
|
-
return t.set("tenant_id",
|
|
1140
|
+
return t.set("tenant_id", l), n();
|
|
1139
1141
|
};
|
|
1140
1142
|
}
|
|
1141
|
-
function
|
|
1143
|
+
function je(e) {
|
|
1142
1144
|
return async (t, n) => {
|
|
1143
1145
|
if (!e.databaseIsolation)
|
|
1144
1146
|
return n();
|
|
1145
1147
|
const r = t.var.tenant_id;
|
|
1146
1148
|
if (!r)
|
|
1147
|
-
throw new
|
|
1149
|
+
throw new b(400, {
|
|
1148
1150
|
message: "Tenant ID not found in request"
|
|
1149
1151
|
});
|
|
1150
1152
|
try {
|
|
1151
|
-
const
|
|
1152
|
-
t.env.data =
|
|
1153
|
-
} catch (
|
|
1153
|
+
const s = await e.databaseIsolation.getAdapters(r);
|
|
1154
|
+
t.env.data = s;
|
|
1155
|
+
} catch (s) {
|
|
1154
1156
|
throw console.error(
|
|
1155
1157
|
`Failed to resolve database for tenant ${r}:`,
|
|
1156
|
-
|
|
1157
|
-
), new
|
|
1158
|
+
s
|
|
1159
|
+
), new b(500, {
|
|
1158
1160
|
message: "Failed to resolve tenant database"
|
|
1159
1161
|
});
|
|
1160
1162
|
}
|
|
1161
1163
|
return n();
|
|
1162
1164
|
};
|
|
1163
1165
|
}
|
|
1164
|
-
function
|
|
1165
|
-
const t =
|
|
1166
|
-
return async (
|
|
1167
|
-
}), await n(
|
|
1168
|
-
}), await r(
|
|
1169
|
-
}),
|
|
1166
|
+
function te(e) {
|
|
1167
|
+
const t = $e(e), n = ze(e), r = je(e);
|
|
1168
|
+
return async (s, o) => (await t(s, async () => {
|
|
1169
|
+
}), await n(s, async () => {
|
|
1170
|
+
}), await r(s, async () => {
|
|
1171
|
+
}), o());
|
|
1170
1172
|
}
|
|
1171
|
-
function
|
|
1173
|
+
function qe(e) {
|
|
1172
1174
|
const {
|
|
1173
1175
|
dataAdapter: t,
|
|
1174
1176
|
controlPlane: n,
|
|
1175
1177
|
controlPlane: {
|
|
1176
1178
|
tenantId: r = "control_plane",
|
|
1177
|
-
clientId:
|
|
1179
|
+
clientId: s
|
|
1178
1180
|
} = {},
|
|
1179
|
-
sync:
|
|
1181
|
+
sync: o = { resourceServers: !0, roles: !0 },
|
|
1180
1182
|
defaultPermissions: i = ["tenant:admin"],
|
|
1181
1183
|
requireOrganizationMatch: c = !1,
|
|
1182
|
-
managementApiExtensions:
|
|
1183
|
-
entityHooks:
|
|
1184
|
-
getChildTenantIds:
|
|
1184
|
+
managementApiExtensions: l = [],
|
|
1185
|
+
entityHooks: a,
|
|
1186
|
+
getChildTenantIds: u,
|
|
1185
1187
|
getAdapters: g,
|
|
1186
1188
|
...d
|
|
1187
1189
|
} = e;
|
|
1188
|
-
let
|
|
1189
|
-
n && (
|
|
1190
|
+
let m = t, f = t;
|
|
1191
|
+
n && (m = ee(t, {
|
|
1190
1192
|
controlPlaneTenantId: r,
|
|
1191
|
-
controlPlaneClientId:
|
|
1192
|
-
}),
|
|
1193
|
-
...
|
|
1193
|
+
controlPlaneClientId: s
|
|
1194
|
+
}), f = {
|
|
1195
|
+
...Ae(t, {
|
|
1194
1196
|
controlPlaneTenantId: r
|
|
1195
1197
|
}),
|
|
1196
1198
|
multiTenancyConfig: {
|
|
1197
1199
|
controlPlaneTenantId: r,
|
|
1198
|
-
controlPlaneClientId:
|
|
1200
|
+
controlPlaneClientId: s
|
|
1199
1201
|
}
|
|
1200
1202
|
});
|
|
1201
|
-
const w =
|
|
1202
|
-
resourceServers:
|
|
1203
|
-
roles:
|
|
1204
|
-
} : { resourceServers: !1, roles: !1 },
|
|
1203
|
+
const w = o !== !1, T = w ? {
|
|
1204
|
+
resourceServers: o.resourceServers ?? !0,
|
|
1205
|
+
roles: o.roles ?? !0
|
|
1206
|
+
} : { resourceServers: !1, roles: !1 }, P = {
|
|
1205
1207
|
controlPlaneTenantId: r,
|
|
1206
|
-
getChildTenantIds:
|
|
1207
|
-
(v) =>
|
|
1208
|
+
getChildTenantIds: u ?? (async () => (await D(
|
|
1209
|
+
(v) => m.tenants.list(v),
|
|
1208
1210
|
"tenants",
|
|
1209
1211
|
{ cursorField: "id", pageSize: 100 }
|
|
1210
1212
|
)).filter((v) => v.id !== r).map((v) => v.id)),
|
|
1211
|
-
getAdapters: g ?? (async () =>
|
|
1212
|
-
getControlPlaneAdapters: async () =>
|
|
1213
|
-
sync:
|
|
1214
|
-
}, { entityHooks:
|
|
1213
|
+
getAdapters: g ?? (async () => m),
|
|
1214
|
+
getControlPlaneAdapters: async () => m,
|
|
1215
|
+
sync: T
|
|
1216
|
+
}, { entityHooks: I, tenantHooks: h } = ve(P), C = {
|
|
1215
1217
|
resourceServers: [
|
|
1216
|
-
|
|
1217
|
-
...(
|
|
1218
|
+
I.resourceServers,
|
|
1219
|
+
...(a == null ? void 0 : a.resourceServers) ?? []
|
|
1218
1220
|
],
|
|
1219
|
-
roles: [
|
|
1220
|
-
connections: (
|
|
1221
|
-
tenants: (
|
|
1222
|
-
rolePermissions: (
|
|
1223
|
-
}, p =
|
|
1221
|
+
roles: [I.roles, ...(a == null ? void 0 : a.roles) ?? []],
|
|
1222
|
+
connections: (a == null ? void 0 : a.connections) ?? [],
|
|
1223
|
+
tenants: (a == null ? void 0 : a.tenants) ?? [],
|
|
1224
|
+
rolePermissions: (a == null ? void 0 : a.rolePermissions) ?? []
|
|
1225
|
+
}, p = Z({
|
|
1224
1226
|
accessControl: {
|
|
1225
1227
|
controlPlaneTenantId: r,
|
|
1226
1228
|
requireOrganizationMatch: c,
|
|
1227
1229
|
defaultPermissions: i
|
|
1228
1230
|
}
|
|
1229
|
-
}),
|
|
1231
|
+
}), $ = N(
|
|
1230
1232
|
{
|
|
1231
1233
|
accessControl: {
|
|
1232
1234
|
controlPlaneTenantId: r,
|
|
@@ -1235,39 +1237,39 @@ function ke(e) {
|
|
|
1235
1237
|
}
|
|
1236
1238
|
},
|
|
1237
1239
|
{ tenants: {
|
|
1238
|
-
async beforeCreate(
|
|
1239
|
-
return p.beforeCreate && (v = await p.beforeCreate(
|
|
1240
|
+
async beforeCreate(A, v) {
|
|
1241
|
+
return p.beforeCreate && (v = await p.beforeCreate(A, v)), h.beforeCreate && (v = await h.beforeCreate(A, v)), v;
|
|
1240
1242
|
},
|
|
1241
|
-
async afterCreate(
|
|
1242
|
-
var
|
|
1243
|
-
await ((
|
|
1243
|
+
async afterCreate(A, v) {
|
|
1244
|
+
var j, z;
|
|
1245
|
+
await ((j = p.afterCreate) == null ? void 0 : j.call(p, A, v)), await ((z = h.afterCreate) == null ? void 0 : z.call(h, A, v));
|
|
1244
1246
|
},
|
|
1245
|
-
async beforeDelete(
|
|
1246
|
-
var
|
|
1247
|
-
await ((
|
|
1247
|
+
async beforeDelete(A, v) {
|
|
1248
|
+
var j, z;
|
|
1249
|
+
await ((j = p.beforeDelete) == null ? void 0 : j.call(p, A, v)), await ((z = h.beforeDelete) == null ? void 0 : z.call(h, A, v));
|
|
1248
1250
|
}
|
|
1249
1251
|
} }
|
|
1250
|
-
), { app:
|
|
1251
|
-
dataAdapter:
|
|
1252
|
-
managementDataAdapter:
|
|
1252
|
+
), { app: R } = ue({
|
|
1253
|
+
dataAdapter: m,
|
|
1254
|
+
managementDataAdapter: f,
|
|
1253
1255
|
...d,
|
|
1254
|
-
entityHooks:
|
|
1256
|
+
entityHooks: C,
|
|
1255
1257
|
managementApiExtensions: [
|
|
1256
|
-
...
|
|
1257
|
-
{ path: "/tenants", router:
|
|
1258
|
+
...l,
|
|
1259
|
+
{ path: "/tenants", router: $ }
|
|
1258
1260
|
]
|
|
1259
1261
|
});
|
|
1260
|
-
return
|
|
1262
|
+
return R.use(
|
|
1261
1263
|
"/api/v2/*",
|
|
1262
|
-
|
|
1263
|
-
), w &&
|
|
1264
|
+
Re(r)
|
|
1265
|
+
), w && R.use("/api/v2/*", be()), { app: R, controlPlaneTenantId: r };
|
|
1264
1266
|
}
|
|
1265
|
-
function
|
|
1266
|
-
const t =
|
|
1267
|
+
function Ee(e) {
|
|
1268
|
+
const t = U(e);
|
|
1267
1269
|
return {
|
|
1268
1270
|
name: "multi-tenancy",
|
|
1269
1271
|
// Apply multi-tenancy middleware for subdomain routing, database resolution, etc.
|
|
1270
|
-
middleware:
|
|
1272
|
+
middleware: te(e),
|
|
1271
1273
|
// Provide lifecycle hooks
|
|
1272
1274
|
hooks: t,
|
|
1273
1275
|
// Mount tenant management routes
|
|
@@ -1287,23 +1289,23 @@ function Oe(e) {
|
|
|
1287
1289
|
}
|
|
1288
1290
|
};
|
|
1289
1291
|
}
|
|
1290
|
-
function
|
|
1291
|
-
const t = e.accessControl ?
|
|
1292
|
+
function U(e) {
|
|
1293
|
+
const t = e.accessControl ? fe(e.accessControl) : {}, n = e.databaseIsolation ? ge(e.databaseIsolation) : {}, r = Z(e);
|
|
1292
1294
|
return {
|
|
1293
1295
|
...t,
|
|
1294
1296
|
...n,
|
|
1295
1297
|
tenants: r
|
|
1296
1298
|
};
|
|
1297
1299
|
}
|
|
1298
|
-
function
|
|
1299
|
-
const t = new
|
|
1300
|
+
function Fe(e) {
|
|
1301
|
+
const t = new se(), n = U(e);
|
|
1300
1302
|
return t.route("/tenants", N(e, n)), t;
|
|
1301
1303
|
}
|
|
1302
|
-
function
|
|
1304
|
+
function Be(e) {
|
|
1303
1305
|
return {
|
|
1304
|
-
hooks:
|
|
1305
|
-
middleware:
|
|
1306
|
-
app:
|
|
1306
|
+
hooks: U(e),
|
|
1307
|
+
middleware: te(e),
|
|
1308
|
+
app: Fe(e),
|
|
1307
1309
|
config: e,
|
|
1308
1310
|
/**
|
|
1309
1311
|
* Wraps data adapters with runtime fallback from the control plane.
|
|
@@ -1315,7 +1317,7 @@ function Ee(e) {
|
|
|
1315
1317
|
*/
|
|
1316
1318
|
wrapAdapters: (t, n) => {
|
|
1317
1319
|
var r;
|
|
1318
|
-
return
|
|
1320
|
+
return ee(t, {
|
|
1319
1321
|
controlPlaneTenantId: (r = e.accessControl) == null ? void 0 : r.controlPlaneTenantId,
|
|
1320
1322
|
controlPlaneClientId: n == null ? void 0 : n.controlPlaneClientId
|
|
1321
1323
|
});
|
|
@@ -1323,24 +1325,24 @@ function Ee(e) {
|
|
|
1323
1325
|
};
|
|
1324
1326
|
}
|
|
1325
1327
|
export {
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1328
|
+
fe as createAccessControlHooks,
|
|
1329
|
+
ze as createAccessControlMiddleware,
|
|
1330
|
+
Re as createControlPlaneTenantMiddleware,
|
|
1331
|
+
ge as createDatabaseHooks,
|
|
1332
|
+
je as createDatabaseMiddleware,
|
|
1333
|
+
Fe as createMultiTenancy,
|
|
1334
|
+
U as createMultiTenancyHooks,
|
|
1335
|
+
te as createMultiTenancyMiddleware,
|
|
1336
|
+
Ee as createMultiTenancyPlugin,
|
|
1337
|
+
be as createProtectSyncedMiddleware,
|
|
1338
|
+
Z as createProvisioningHooks,
|
|
1339
|
+
Se as createRuntimeFallbackAdapter,
|
|
1340
|
+
$e as createSubdomainMiddleware,
|
|
1341
|
+
ve as createSyncHooks,
|
|
1340
1342
|
N as createTenantsOpenAPIRouter,
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1343
|
+
qe as initMultiTenant,
|
|
1344
|
+
Be as setupMultiTenancy,
|
|
1345
|
+
me as validateTenantAccess,
|
|
1346
|
+
ee as withRuntimeFallback,
|
|
1347
|
+
Ae as withSystemResourceServerInheritance
|
|
1346
1348
|
};
|