authula 0.5.3 → 0.6.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/README.md +79 -739
- package/dist/custom-fetch-ZBY99AZW.js +114 -0
- package/dist/custom-fetch-ZBY99AZW.js.map +1 -0
- package/dist/index-DHUQcsNV.d.ts +2011 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -17
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.d.ts +2935 -738
- package/dist/plugins/index.js +4091 -522
- package/dist/plugins/index.js.map +1 -1
- package/dist/rolldown-runtime-w6R9maHv.js +18 -0
- package/package.json +26 -23
- package/dist/fetch-BnZpQ0Yq.js +0 -128
- package/dist/fetch-BnZpQ0Yq.js.map +0 -1
- package/dist/fetch-CEj1gBkL.cjs +0 -163
- package/dist/fetch-CEj1gBkL.cjs.map +0 -1
- package/dist/index.cjs +0 -60
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -2
- package/dist/plugins/index.cjs +0 -696
- package/dist/plugins/index.cjs.map +0 -1
- package/dist/plugins/index.d.cts +0 -825
- package/dist/sdk-7eSlhCrf.d.cts +0 -167
- package/dist/sdk-7eSlhCrf.d.ts +0 -167
package/dist/plugins/index.cjs
DELETED
|
@@ -1,696 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_fetch = require('../fetch-CEj1gBkL.cjs');
|
|
3
|
-
let zod = require("zod");
|
|
4
|
-
let cookie = require("cookie");
|
|
5
|
-
|
|
6
|
-
//#region src/plugins/access-control/plugin.ts
|
|
7
|
-
var AccessControlPlugin = class {
|
|
8
|
-
id = "accessControl";
|
|
9
|
-
constructor() {}
|
|
10
|
-
init(client) {
|
|
11
|
-
return {
|
|
12
|
-
createRole: async (data) => {
|
|
13
|
-
return require_fetch.wrappedFetch(client, `/access-control/roles`, {
|
|
14
|
-
method: "POST",
|
|
15
|
-
body: data
|
|
16
|
-
});
|
|
17
|
-
},
|
|
18
|
-
getAllRoles: async () => {
|
|
19
|
-
return require_fetch.wrappedFetch(client, `/access-control/roles`, { method: "GET" });
|
|
20
|
-
},
|
|
21
|
-
getRoleByName: async (roleName) => {
|
|
22
|
-
return require_fetch.wrappedFetch(client, `/access-control/roles/by-name/${roleName}`, { method: "GET" });
|
|
23
|
-
},
|
|
24
|
-
getRoleById: async (roleId) => {
|
|
25
|
-
return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}`, { method: "GET" });
|
|
26
|
-
},
|
|
27
|
-
updateRole: async (roleId, data) => {
|
|
28
|
-
return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}`, {
|
|
29
|
-
method: "PATCH",
|
|
30
|
-
body: data
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
deleteRole: async (roleId) => {
|
|
34
|
-
return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}`, { method: "DELETE" });
|
|
35
|
-
},
|
|
36
|
-
createPermission: async (data) => {
|
|
37
|
-
return require_fetch.wrappedFetch(client, `/access-control/permissions`, {
|
|
38
|
-
method: "POST",
|
|
39
|
-
body: data
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
getAllPermissions: async () => {
|
|
43
|
-
return require_fetch.wrappedFetch(client, `/access-control/permissions`, { method: "GET" });
|
|
44
|
-
},
|
|
45
|
-
getPermissionById: async (permissionId) => {
|
|
46
|
-
return require_fetch.wrappedFetch(client, `/access-control/permissions/${permissionId}`, { method: "GET" });
|
|
47
|
-
},
|
|
48
|
-
updatePermission: async (permissionId, data) => {
|
|
49
|
-
return require_fetch.wrappedFetch(client, `/access-control/permissions/${permissionId}`, {
|
|
50
|
-
method: "PATCH",
|
|
51
|
-
body: data
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
deletePermission: async (permissionId) => {
|
|
55
|
-
return require_fetch.wrappedFetch(client, `/access-control/permissions/${permissionId}`, { method: "DELETE" });
|
|
56
|
-
},
|
|
57
|
-
addRolePermission: async (roleId, data) => {
|
|
58
|
-
return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, {
|
|
59
|
-
method: "POST",
|
|
60
|
-
body: data
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
getRolePermissions: async (roleId) => {
|
|
64
|
-
return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, { method: "GET" });
|
|
65
|
-
},
|
|
66
|
-
replaceRolePermissions: async (roleId, data) => {
|
|
67
|
-
return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, {
|
|
68
|
-
method: "PUT",
|
|
69
|
-
body: data
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
removeRolePermission: async (roleId, permissionId) => {
|
|
73
|
-
return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}/permissions/${permissionId}`, { method: "DELETE" });
|
|
74
|
-
},
|
|
75
|
-
getUserRoles: async (userId) => {
|
|
76
|
-
return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/roles`, { method: "GET" });
|
|
77
|
-
},
|
|
78
|
-
assignUserRole: async (userId, data) => {
|
|
79
|
-
return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/roles`, {
|
|
80
|
-
method: "POST",
|
|
81
|
-
body: data
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
replaceUserRoles: async (userId, data) => {
|
|
85
|
-
return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/roles`, {
|
|
86
|
-
method: "PUT",
|
|
87
|
-
body: data
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
removeUserRole: async (userId, roleId) => {
|
|
91
|
-
return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/roles/${roleId}`, { method: "DELETE" });
|
|
92
|
-
},
|
|
93
|
-
getUserPermissions: async (userId) => {
|
|
94
|
-
return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/permissions`, { method: "GET" });
|
|
95
|
-
},
|
|
96
|
-
checkUserPermissions: async (userId, data) => {
|
|
97
|
-
return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/permissions/check`, {
|
|
98
|
-
method: "POST",
|
|
99
|
-
body: data
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/plugins/access-control/types.ts
|
|
108
|
-
const roleSchema = zod.z.object({
|
|
109
|
-
id: zod.z.string().nonempty(),
|
|
110
|
-
name: zod.z.string().nonempty(),
|
|
111
|
-
description: zod.z.string().nullish(),
|
|
112
|
-
weight: zod.z.number(),
|
|
113
|
-
isSystem: zod.z.boolean(),
|
|
114
|
-
createdAt: zod.z.iso.datetime(),
|
|
115
|
-
updatedAt: zod.z.iso.datetime()
|
|
116
|
-
});
|
|
117
|
-
const permissionSchema = zod.z.object({
|
|
118
|
-
id: zod.z.string().nonempty(),
|
|
119
|
-
key: zod.z.string().nonempty(),
|
|
120
|
-
description: zod.z.string().nullish(),
|
|
121
|
-
isSystem: zod.z.boolean(),
|
|
122
|
-
createdAt: zod.z.iso.datetime(),
|
|
123
|
-
updatedAt: zod.z.iso.datetime()
|
|
124
|
-
});
|
|
125
|
-
const permissionGrantSourceSchema = zod.z.object({
|
|
126
|
-
roleId: zod.z.string().nonempty(),
|
|
127
|
-
roleName: zod.z.string().nonempty(),
|
|
128
|
-
grantedByUserId: zod.z.string().nullish(),
|
|
129
|
-
grantedAt: zod.z.iso.datetime().nullish()
|
|
130
|
-
});
|
|
131
|
-
const userPermissionInfoSchema = zod.z.object({
|
|
132
|
-
permissionId: zod.z.string().nonempty(),
|
|
133
|
-
permissionKey: zod.z.string().nonempty(),
|
|
134
|
-
permissionDescription: zod.z.string().nullish(),
|
|
135
|
-
grantedByUserId: zod.z.string().nullish(),
|
|
136
|
-
grantedAt: zod.z.iso.datetime().nullish(),
|
|
137
|
-
sources: zod.z.array(permissionGrantSourceSchema).optional()
|
|
138
|
-
});
|
|
139
|
-
const userRoleInfoSchema = zod.z.object({
|
|
140
|
-
roleId: zod.z.string().nonempty(),
|
|
141
|
-
roleName: zod.z.string().nonempty(),
|
|
142
|
-
roleDescription: zod.z.string().nullish(),
|
|
143
|
-
assignedByUserId: zod.z.string().nullish(),
|
|
144
|
-
assignedAt: zod.z.iso.datetime().nullish(),
|
|
145
|
-
expiresAt: zod.z.iso.datetime().nullish()
|
|
146
|
-
});
|
|
147
|
-
const roleDetailsSchema = zod.z.object({
|
|
148
|
-
role: roleSchema,
|
|
149
|
-
permissions: zod.z.array(userPermissionInfoSchema)
|
|
150
|
-
});
|
|
151
|
-
const getUserPermissionsResponseSchema = zod.z.object({ permissions: zod.z.array(userPermissionInfoSchema) });
|
|
152
|
-
const checkUserPermissionsResponseSchema = zod.z.object({ hasPermissions: zod.z.boolean() });
|
|
153
|
-
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/plugins/admin/plugin.ts
|
|
156
|
-
var AdminPlugin = class {
|
|
157
|
-
id = "admin";
|
|
158
|
-
constructor() {}
|
|
159
|
-
init(client) {
|
|
160
|
-
return {
|
|
161
|
-
createUser: async (data) => {
|
|
162
|
-
return require_fetch.wrappedFetch(client, "/admin/users", {
|
|
163
|
-
method: "POST",
|
|
164
|
-
body: data
|
|
165
|
-
});
|
|
166
|
-
},
|
|
167
|
-
getAllUsers: async (limit) => {
|
|
168
|
-
const urlSearchParams = new URLSearchParams();
|
|
169
|
-
if (limit) urlSearchParams.append("limit", limit.toString());
|
|
170
|
-
return require_fetch.wrappedFetch(client, `/admin/users${urlSearchParams.toString() ? `?${urlSearchParams.toString()}` : ""}`, { method: "GET" });
|
|
171
|
-
},
|
|
172
|
-
getUserById: async (userId) => {
|
|
173
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}`, { method: "GET" });
|
|
174
|
-
},
|
|
175
|
-
updateUser: async (userId, data) => {
|
|
176
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}`, {
|
|
177
|
-
method: "PATCH",
|
|
178
|
-
body: data
|
|
179
|
-
});
|
|
180
|
-
},
|
|
181
|
-
deleteUser: async (userId) => {
|
|
182
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}`, { method: "DELETE" });
|
|
183
|
-
},
|
|
184
|
-
createAccount: async (userId, data) => {
|
|
185
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}/accounts`, {
|
|
186
|
-
method: "POST",
|
|
187
|
-
body: data
|
|
188
|
-
});
|
|
189
|
-
},
|
|
190
|
-
getUserAccounts: async (userId) => {
|
|
191
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}/accounts`, { method: "GET" });
|
|
192
|
-
},
|
|
193
|
-
getAccountById: async (id) => {
|
|
194
|
-
return require_fetch.wrappedFetch(client, `/admin/accounts/${id}`, { method: "GET" });
|
|
195
|
-
},
|
|
196
|
-
updateAccount: async (id, data) => {
|
|
197
|
-
return require_fetch.wrappedFetch(client, `/admin/accounts/${id}`, {
|
|
198
|
-
method: "PATCH",
|
|
199
|
-
body: data
|
|
200
|
-
});
|
|
201
|
-
},
|
|
202
|
-
deleteAccount: async (id) => {
|
|
203
|
-
return require_fetch.wrappedFetch(client, `/admin/accounts/${id}`, { method: "DELETE" });
|
|
204
|
-
},
|
|
205
|
-
getUserState: async (userId) => {
|
|
206
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}/state`, { method: "GET" });
|
|
207
|
-
},
|
|
208
|
-
createUserState: async (userId, data) => {
|
|
209
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}/state`, {
|
|
210
|
-
method: "POST",
|
|
211
|
-
body: data
|
|
212
|
-
});
|
|
213
|
-
},
|
|
214
|
-
updateUserState: async (userId, data) => {
|
|
215
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}/state`, {
|
|
216
|
-
method: "PATCH",
|
|
217
|
-
body: data
|
|
218
|
-
});
|
|
219
|
-
},
|
|
220
|
-
deleteUserState: async (userId) => {
|
|
221
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}/state`, { method: "DELETE" });
|
|
222
|
-
},
|
|
223
|
-
getBannedUserStates: async () => {
|
|
224
|
-
return require_fetch.wrappedFetch(client, `/admin/users/states/banned`, { method: "GET" });
|
|
225
|
-
},
|
|
226
|
-
banUser: async (userId, data) => {
|
|
227
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}/ban`, {
|
|
228
|
-
method: "POST",
|
|
229
|
-
body: data
|
|
230
|
-
});
|
|
231
|
-
},
|
|
232
|
-
unbanUser: async (userId) => {
|
|
233
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}/unban`, { method: "POST" });
|
|
234
|
-
},
|
|
235
|
-
getUserAdminSessions: async (userId) => {
|
|
236
|
-
return require_fetch.wrappedFetch(client, `/admin/users/${userId}/sessions`, { method: "GET" });
|
|
237
|
-
},
|
|
238
|
-
getSessionState: async (sessionId) => {
|
|
239
|
-
return require_fetch.wrappedFetch(client, `/admin/sessions/${sessionId}/state`, { method: "GET" });
|
|
240
|
-
},
|
|
241
|
-
createSessionState: async (sessionId, data) => {
|
|
242
|
-
return require_fetch.wrappedFetch(client, `/admin/sessions/${sessionId}/state`, {
|
|
243
|
-
method: "POST",
|
|
244
|
-
body: data
|
|
245
|
-
});
|
|
246
|
-
},
|
|
247
|
-
updateSessionState: async (sessionId, data) => {
|
|
248
|
-
return require_fetch.wrappedFetch(client, `/admin/sessions/${sessionId}/state`, {
|
|
249
|
-
method: "PATCH",
|
|
250
|
-
body: data
|
|
251
|
-
});
|
|
252
|
-
},
|
|
253
|
-
deleteSessionState: async (sessionId) => {
|
|
254
|
-
return require_fetch.wrappedFetch(client, `/admin/sessions/${sessionId}/state`, { method: "DELETE" });
|
|
255
|
-
},
|
|
256
|
-
getRevokedSessionStates: async () => {
|
|
257
|
-
return require_fetch.wrappedFetch(client, `/admin/sessions/states/revoked`, { method: "GET" });
|
|
258
|
-
},
|
|
259
|
-
revokeSession: async (sessionId, data) => {
|
|
260
|
-
return require_fetch.wrappedFetch(client, `/admin/sessions/${sessionId}/revoke`, {
|
|
261
|
-
method: "POST",
|
|
262
|
-
body: data
|
|
263
|
-
});
|
|
264
|
-
},
|
|
265
|
-
getAllImpersonations: async () => {
|
|
266
|
-
return require_fetch.wrappedFetch(client, "/admin/impersonations", { method: "GET" });
|
|
267
|
-
},
|
|
268
|
-
getImpersonationById: async (impersonationId) => {
|
|
269
|
-
return require_fetch.wrappedFetch(client, `/admin/impersonations/${impersonationId}`, { method: "GET" });
|
|
270
|
-
},
|
|
271
|
-
startImpersonation: async (data) => {
|
|
272
|
-
return require_fetch.wrappedFetch(client, "/admin/impersonations", {
|
|
273
|
-
method: "POST",
|
|
274
|
-
body: data
|
|
275
|
-
});
|
|
276
|
-
},
|
|
277
|
-
stopImpersonation: async (impersonationId) => {
|
|
278
|
-
return require_fetch.wrappedFetch(client, `/admin/impersonations/${impersonationId}/stop`, { method: "POST" });
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region src/plugins/admin/types.ts
|
|
286
|
-
const adminUserStateSchema = zod.z.object({
|
|
287
|
-
userId: zod.z.string().nonempty(),
|
|
288
|
-
isBanned: zod.z.boolean(),
|
|
289
|
-
bannedAt: zod.z.iso.datetime().nullable(),
|
|
290
|
-
bannedUntil: zod.z.iso.datetime().nullable(),
|
|
291
|
-
bannedReason: zod.z.string().nullable(),
|
|
292
|
-
bannedByUserId: zod.z.string().nullable(),
|
|
293
|
-
createdAt: zod.z.iso.datetime(),
|
|
294
|
-
updatedAt: zod.z.iso.datetime()
|
|
295
|
-
});
|
|
296
|
-
const adminSessionStateSchema = zod.z.object({
|
|
297
|
-
sessionId: zod.z.string().nonempty(),
|
|
298
|
-
revokedAt: zod.z.iso.datetime().nullable(),
|
|
299
|
-
revokedReason: zod.z.string().nullable(),
|
|
300
|
-
revokedByUserId: zod.z.string().nullable(),
|
|
301
|
-
impersonatorUserId: zod.z.string().nullable(),
|
|
302
|
-
impersonationReason: zod.z.string().nullable(),
|
|
303
|
-
impersonationExpiresAt: zod.z.iso.datetime().nullable(),
|
|
304
|
-
createdAt: zod.z.iso.datetime(),
|
|
305
|
-
updatedAt: zod.z.iso.datetime()
|
|
306
|
-
});
|
|
307
|
-
const adminUserSessionSchema = zod.z.object({
|
|
308
|
-
session: require_fetch.sessionSchema,
|
|
309
|
-
state: adminSessionStateSchema.nullable()
|
|
310
|
-
});
|
|
311
|
-
const impersonationSchema = zod.z.object({
|
|
312
|
-
id: zod.z.string().nonempty(),
|
|
313
|
-
actorUserId: zod.z.string().nonempty(),
|
|
314
|
-
targetUserId: zod.z.string().nonempty(),
|
|
315
|
-
actorSessionId: zod.z.string().nullable(),
|
|
316
|
-
impersonationSessionId: zod.z.string().nullable(),
|
|
317
|
-
reason: zod.z.string().nonempty(),
|
|
318
|
-
startedAt: zod.z.iso.datetime(),
|
|
319
|
-
expiresAt: zod.z.iso.datetime(),
|
|
320
|
-
endedAt: zod.z.iso.datetime().nullable(),
|
|
321
|
-
endedByUserId: zod.z.string().nullable(),
|
|
322
|
-
createdAt: zod.z.iso.datetime(),
|
|
323
|
-
updatedAt: zod.z.iso.datetime()
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
//#endregion
|
|
327
|
-
//#region src/plugins/bearer/plugin.ts
|
|
328
|
-
var BearerPlugin = class {
|
|
329
|
-
options;
|
|
330
|
-
id = "bearer";
|
|
331
|
-
refreshPromise = null;
|
|
332
|
-
constructor(options) {
|
|
333
|
-
this.options = options;
|
|
334
|
-
}
|
|
335
|
-
init(client) {
|
|
336
|
-
client.registerBeforeFetch(async (ctx) => {
|
|
337
|
-
if (typeof document === "undefined") return;
|
|
338
|
-
const headerName = this.options?.headerName ?? "Authorization";
|
|
339
|
-
const token = localStorage.getItem("accessToken");
|
|
340
|
-
if (token) ctx.init.headers = {
|
|
341
|
-
...ctx.init.headers,
|
|
342
|
-
[headerName]: `Bearer ${token}`
|
|
343
|
-
};
|
|
344
|
-
});
|
|
345
|
-
client.registerAfterFetch(async (ctx, res) => {
|
|
346
|
-
if (typeof document === "undefined") return;
|
|
347
|
-
if (res.status !== 401) return;
|
|
348
|
-
if (ctx.meta.retry) return;
|
|
349
|
-
const refreshToken = localStorage.getItem("refreshToken");
|
|
350
|
-
if (!refreshToken) return;
|
|
351
|
-
if (!client.jwt) {
|
|
352
|
-
console.warn("JWT Plugin is required for Bearer token refresh.");
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
if (!this.refreshPromise) this.refreshPromise = (async () => {
|
|
356
|
-
try {
|
|
357
|
-
const response = await client.jwt.refreshToken({ refreshToken });
|
|
358
|
-
if (!response) return null;
|
|
359
|
-
localStorage.setItem("accessToken", response.accessToken);
|
|
360
|
-
localStorage.setItem("refreshToken", response.refreshToken);
|
|
361
|
-
return response;
|
|
362
|
-
} finally {
|
|
363
|
-
this.refreshPromise = null;
|
|
364
|
-
}
|
|
365
|
-
})();
|
|
366
|
-
const refreshed = await this.refreshPromise;
|
|
367
|
-
if (!refreshed) return;
|
|
368
|
-
const headerName = this.options?.headerName ?? "Authorization";
|
|
369
|
-
ctx.init.headers = {
|
|
370
|
-
...ctx.init.headers,
|
|
371
|
-
[headerName]: `Bearer ${refreshed.accessToken}`
|
|
372
|
-
};
|
|
373
|
-
return "retry";
|
|
374
|
-
});
|
|
375
|
-
return {};
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
//#endregion
|
|
380
|
-
//#region src/plugins/csrf/plugin.ts
|
|
381
|
-
var CSRFPlugin = class {
|
|
382
|
-
options;
|
|
383
|
-
id = "csrf";
|
|
384
|
-
constructor(options) {
|
|
385
|
-
this.options = options;
|
|
386
|
-
}
|
|
387
|
-
init(client) {
|
|
388
|
-
client.registerBeforeFetch(async (ctx) => {
|
|
389
|
-
if (typeof document !== "undefined") {
|
|
390
|
-
if ([
|
|
391
|
-
"OPTIONS",
|
|
392
|
-
"HEAD",
|
|
393
|
-
"GET"
|
|
394
|
-
].includes(ctx.init.method || "GET")) return;
|
|
395
|
-
const value = (0, cookie.parseCookie)(document.cookie)[this.options.cookieName];
|
|
396
|
-
if (!value) return;
|
|
397
|
-
ctx.init.headers = new Headers(ctx.init.headers);
|
|
398
|
-
ctx.init.headers.set(this.options.headerName, value);
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
if (this.cookies) {
|
|
402
|
-
if ([
|
|
403
|
-
"OPTIONS",
|
|
404
|
-
"HEAD",
|
|
405
|
-
"GET"
|
|
406
|
-
].includes(ctx.init.method || "GET")) return;
|
|
407
|
-
const cookie$1 = (await this.cookies()).get(this.options.cookieName);
|
|
408
|
-
if (!cookie$1) return;
|
|
409
|
-
ctx.init.headers = new Headers(ctx.init.headers);
|
|
410
|
-
ctx.init.headers.set(this.options.headerName, cookie$1.value);
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
return {};
|
|
414
|
-
}
|
|
415
|
-
cookies;
|
|
416
|
-
attachCookies(fn) {
|
|
417
|
-
this.cookies = fn;
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
//#endregion
|
|
422
|
-
//#region src/plugins/email-password/plugin.ts
|
|
423
|
-
var EmailPasswordPlugin = class {
|
|
424
|
-
id = "emailPassword";
|
|
425
|
-
init(client) {
|
|
426
|
-
return {
|
|
427
|
-
signUp: async (data) => {
|
|
428
|
-
return require_fetch.wrappedFetch(client, "/email-password/sign-up", {
|
|
429
|
-
method: "POST",
|
|
430
|
-
body: data
|
|
431
|
-
});
|
|
432
|
-
},
|
|
433
|
-
signIn: async (data) => {
|
|
434
|
-
return require_fetch.wrappedFetch(client, "/email-password/sign-in", {
|
|
435
|
-
method: "POST",
|
|
436
|
-
body: data
|
|
437
|
-
});
|
|
438
|
-
},
|
|
439
|
-
sendEmailVerification: async (data) => {
|
|
440
|
-
return require_fetch.wrappedFetch(client, `/email-password/send-email-verification`, {
|
|
441
|
-
method: "POST",
|
|
442
|
-
body: data
|
|
443
|
-
});
|
|
444
|
-
},
|
|
445
|
-
requestPasswordReset: async (data) => {
|
|
446
|
-
return require_fetch.wrappedFetch(client, `/email-password/request-password-reset`, {
|
|
447
|
-
method: "POST",
|
|
448
|
-
body: data
|
|
449
|
-
});
|
|
450
|
-
},
|
|
451
|
-
changePassword: async (data) => {
|
|
452
|
-
return require_fetch.wrappedFetch(client, `/email-password/change-password`, {
|
|
453
|
-
method: "POST",
|
|
454
|
-
body: data
|
|
455
|
-
});
|
|
456
|
-
},
|
|
457
|
-
requestEmailChange: async (data) => {
|
|
458
|
-
return require_fetch.wrappedFetch(client, `/email-password/request-email-change`, {
|
|
459
|
-
method: "POST",
|
|
460
|
-
body: data
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
//#endregion
|
|
468
|
-
//#region src/plugins/jwt/plugin.ts
|
|
469
|
-
var JWTPlugin = class {
|
|
470
|
-
id = "jwt";
|
|
471
|
-
constructor() {}
|
|
472
|
-
init(client) {
|
|
473
|
-
return {
|
|
474
|
-
refreshToken: async (data) => {
|
|
475
|
-
return require_fetch.wrappedFetch(client, "/token/refresh", {
|
|
476
|
-
method: "POST",
|
|
477
|
-
body: data
|
|
478
|
-
});
|
|
479
|
-
},
|
|
480
|
-
getJWKSKeys: async () => {
|
|
481
|
-
return require_fetch.wrappedFetch(client, "/.well-known/jwks.json", { method: "GET" });
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
//#endregion
|
|
488
|
-
//#region src/plugins/magic-link/plugin.ts
|
|
489
|
-
var MagicLinkPlugin = class {
|
|
490
|
-
id = "magicLink";
|
|
491
|
-
constructor() {}
|
|
492
|
-
init(client) {
|
|
493
|
-
return {
|
|
494
|
-
signIn: async (data) => {
|
|
495
|
-
return require_fetch.wrappedFetch(client, "/magic-link/sign-in", {
|
|
496
|
-
method: "POST",
|
|
497
|
-
body: data
|
|
498
|
-
});
|
|
499
|
-
},
|
|
500
|
-
verify: async (data) => {
|
|
501
|
-
const searchParams = new URLSearchParams();
|
|
502
|
-
searchParams.append("token", data.token);
|
|
503
|
-
if (data.callbackUrl) searchParams.append("callback_url", data.callbackUrl);
|
|
504
|
-
return require_fetch.wrappedFetch(client, `/magic-link/verify?${searchParams.toString()}`, { method: "GET" });
|
|
505
|
-
},
|
|
506
|
-
exchange: async (data) => {
|
|
507
|
-
return require_fetch.wrappedFetch(client, "/magic-link/exchange", {
|
|
508
|
-
method: "POST",
|
|
509
|
-
body: data
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
|
|
516
|
-
//#endregion
|
|
517
|
-
//#region src/plugins/oauth2/plugin.ts
|
|
518
|
-
var OAuth2Plugin = class {
|
|
519
|
-
id = "oauth2";
|
|
520
|
-
init(client) {
|
|
521
|
-
return { signIn: async (data) => {
|
|
522
|
-
return require_fetch.wrappedFetch(client, `/oauth2/authorize/${data.provider}?redirect_to=${data.redirectTo}`, { method: "GET" });
|
|
523
|
-
} };
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
//#endregion
|
|
528
|
-
//#region src/plugins/organizations/plugin.ts
|
|
529
|
-
var OrganizationsPlugin = class {
|
|
530
|
-
id = "organizations";
|
|
531
|
-
init(client) {
|
|
532
|
-
return {
|
|
533
|
-
createOrganization: async (data) => {
|
|
534
|
-
return require_fetch.wrappedFetch(client, "/organizations", {
|
|
535
|
-
method: "POST",
|
|
536
|
-
body: data
|
|
537
|
-
});
|
|
538
|
-
},
|
|
539
|
-
getAllOrganizations: async () => {
|
|
540
|
-
return require_fetch.wrappedFetch(client, "/organizations", { method: "GET" });
|
|
541
|
-
},
|
|
542
|
-
getOrganizationById: async (organizationId) => {
|
|
543
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}`, { method: "GET" });
|
|
544
|
-
},
|
|
545
|
-
updateOrganization: async (organizationId, data) => {
|
|
546
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}`, {
|
|
547
|
-
method: "PATCH",
|
|
548
|
-
body: data
|
|
549
|
-
});
|
|
550
|
-
},
|
|
551
|
-
deleteOrganization: async (organizationId) => {
|
|
552
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}`, { method: "DELETE" });
|
|
553
|
-
},
|
|
554
|
-
createOrganizationInvitation: async (organizationId, data) => {
|
|
555
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/invitations`, {
|
|
556
|
-
method: "POST",
|
|
557
|
-
body: data
|
|
558
|
-
});
|
|
559
|
-
},
|
|
560
|
-
getAllOrganizationInvitations: async (organizationId) => {
|
|
561
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/invitations`, { method: "GET" });
|
|
562
|
-
},
|
|
563
|
-
getOrganizationInvitation: async (organizationId, invitationId) => {
|
|
564
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/invitations/${invitationId}`, { method: "GET" });
|
|
565
|
-
},
|
|
566
|
-
revokeOrganizationInvitation: async (organizationId, invitationId) => {
|
|
567
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/invitations/${invitationId}`, { method: "PATCH" });
|
|
568
|
-
},
|
|
569
|
-
acceptOrganizationInvitation: async (organizationId, invitationId, data) => {
|
|
570
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/invitations/${invitationId}/accept`, {
|
|
571
|
-
method: "POST",
|
|
572
|
-
body: data
|
|
573
|
-
});
|
|
574
|
-
},
|
|
575
|
-
rejectOrganizationInvitation: async (organizationId, invitationId) => {
|
|
576
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/invitations/${invitationId}/reject`, { method: "POST" });
|
|
577
|
-
},
|
|
578
|
-
addOrganizationMember: async (organizationId, data) => {
|
|
579
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/members`, {
|
|
580
|
-
method: "POST",
|
|
581
|
-
body: data
|
|
582
|
-
});
|
|
583
|
-
},
|
|
584
|
-
getAllOrganizationMembers: async (organizationId) => {
|
|
585
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/members`, { method: "GET" });
|
|
586
|
-
},
|
|
587
|
-
getOrganizationMember: async (organizationId, memberId) => {
|
|
588
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/members/${memberId}`, { method: "GET" });
|
|
589
|
-
},
|
|
590
|
-
updateOrganizationMember: async (organizationId, memberId, data) => {
|
|
591
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/members/${memberId}`, {
|
|
592
|
-
method: "PATCH",
|
|
593
|
-
body: data
|
|
594
|
-
});
|
|
595
|
-
},
|
|
596
|
-
deleteOrganizationMember: async (organizationId, memberId) => {
|
|
597
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/members/${memberId}`, { method: "DELETE" });
|
|
598
|
-
},
|
|
599
|
-
createOrganizationTeam: async (organizationId, data) => {
|
|
600
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/teams`, {
|
|
601
|
-
method: "POST",
|
|
602
|
-
body: data
|
|
603
|
-
});
|
|
604
|
-
},
|
|
605
|
-
getAllOrganizationTeams: async (organizationId) => {
|
|
606
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/teams`, { method: "GET" });
|
|
607
|
-
},
|
|
608
|
-
getOrganizationTeam: async (organizationId, teamId) => {
|
|
609
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}`, { method: "GET" });
|
|
610
|
-
},
|
|
611
|
-
updateOrganizationTeam: async (organizationId, teamId, data) => {
|
|
612
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}`, {
|
|
613
|
-
method: "PATCH",
|
|
614
|
-
body: data
|
|
615
|
-
});
|
|
616
|
-
},
|
|
617
|
-
deleteOrganizationTeam: async (organizationId, teamId) => {
|
|
618
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}`, { method: "DELETE" });
|
|
619
|
-
},
|
|
620
|
-
addOrganizationTeamMember: async (organizationId, teamId, data) => {
|
|
621
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}/members`, {
|
|
622
|
-
method: "POST",
|
|
623
|
-
body: data
|
|
624
|
-
});
|
|
625
|
-
},
|
|
626
|
-
getAllOrganizationTeamMembers: async (organizationId, teamId) => {
|
|
627
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}/members`, { method: "GET" });
|
|
628
|
-
},
|
|
629
|
-
getOrganizationTeamMember: async (organizationId, teamId, memberId) => {
|
|
630
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}/members/${memberId}`, { method: "GET" });
|
|
631
|
-
},
|
|
632
|
-
deleteOrganizationTeamMember: async (organizationId, teamId, memberId) => {
|
|
633
|
-
return require_fetch.wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}/members/${memberId}`, { method: "DELETE" });
|
|
634
|
-
}
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
//#endregion
|
|
640
|
-
//#region src/plugins/totp/plugin.ts
|
|
641
|
-
var TOTPPlugin = class {
|
|
642
|
-
id = "totp";
|
|
643
|
-
init(client) {
|
|
644
|
-
return {
|
|
645
|
-
enable: async () => {
|
|
646
|
-
return require_fetch.wrappedFetch(client, "/totp/enable", { method: "POST" });
|
|
647
|
-
},
|
|
648
|
-
disable: async () => {
|
|
649
|
-
return require_fetch.wrappedFetch(client, "/totp/disable", { method: "POST" });
|
|
650
|
-
},
|
|
651
|
-
getUri: async () => {
|
|
652
|
-
return require_fetch.wrappedFetch(client, "/totp/get-uri", { method: "GET" });
|
|
653
|
-
},
|
|
654
|
-
verify: async (data) => {
|
|
655
|
-
return require_fetch.wrappedFetch(client, "/totp/verify", {
|
|
656
|
-
method: "POST",
|
|
657
|
-
body: data
|
|
658
|
-
});
|
|
659
|
-
},
|
|
660
|
-
verifyBackupCode: async (data) => {
|
|
661
|
-
return require_fetch.wrappedFetch(client, "/totp/verify-backup-code", {
|
|
662
|
-
method: "POST",
|
|
663
|
-
body: data
|
|
664
|
-
});
|
|
665
|
-
},
|
|
666
|
-
generateBackupCodes: async () => {
|
|
667
|
-
return require_fetch.wrappedFetch(client, "/totp/generate-backup-codes", { method: "POST" });
|
|
668
|
-
}
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
//#endregion
|
|
674
|
-
exports.AccessControlPlugin = AccessControlPlugin;
|
|
675
|
-
exports.AdminPlugin = AdminPlugin;
|
|
676
|
-
exports.BearerPlugin = BearerPlugin;
|
|
677
|
-
exports.CSRFPlugin = CSRFPlugin;
|
|
678
|
-
exports.EmailPasswordPlugin = EmailPasswordPlugin;
|
|
679
|
-
exports.JWTPlugin = JWTPlugin;
|
|
680
|
-
exports.MagicLinkPlugin = MagicLinkPlugin;
|
|
681
|
-
exports.OAuth2Plugin = OAuth2Plugin;
|
|
682
|
-
exports.OrganizationsPlugin = OrganizationsPlugin;
|
|
683
|
-
exports.TOTPPlugin = TOTPPlugin;
|
|
684
|
-
exports.adminSessionStateSchema = adminSessionStateSchema;
|
|
685
|
-
exports.adminUserSessionSchema = adminUserSessionSchema;
|
|
686
|
-
exports.adminUserStateSchema = adminUserStateSchema;
|
|
687
|
-
exports.checkUserPermissionsResponseSchema = checkUserPermissionsResponseSchema;
|
|
688
|
-
exports.getUserPermissionsResponseSchema = getUserPermissionsResponseSchema;
|
|
689
|
-
exports.impersonationSchema = impersonationSchema;
|
|
690
|
-
exports.permissionGrantSourceSchema = permissionGrantSourceSchema;
|
|
691
|
-
exports.permissionSchema = permissionSchema;
|
|
692
|
-
exports.roleDetailsSchema = roleDetailsSchema;
|
|
693
|
-
exports.roleSchema = roleSchema;
|
|
694
|
-
exports.userPermissionInfoSchema = userPermissionInfoSchema;
|
|
695
|
-
exports.userRoleInfoSchema = userRoleInfoSchema;
|
|
696
|
-
//# sourceMappingURL=index.cjs.map
|