gemi 0.4.16 → 0.4.18
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/app/index.js +19 -1334
- package/dist/auth/adapters/prisma.d.ts +1 -1
- package/dist/auth/adapters/prisma.d.ts.map +1 -1
- package/dist/auth/adapters/types.d.ts +2 -2
- package/dist/auth/adapters/types.d.ts.map +1 -1
- package/dist/chunk-21e105fb2b3d36d7.js +799 -0
- package/dist/chunk-7afdc0ba5afe109a.js +21 -0
- package/dist/chunk-970e033f764e29fc.js +19 -0
- package/dist/chunk-fa40971555060604.js +81 -0
- package/dist/email/index.js +15 -13910
- package/dist/facades/index.js +8 -99
- package/dist/http/index.js +8 -99
- package/dist/kernel/index.js +37 -594
- package/dist/server/index.js +48 -1106
- package/dist/vite/index.js +4 -21
- package/package.json +1 -1
package/dist/kernel/index.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
ApiRouter,
|
|
4
|
+
Controller,
|
|
5
|
+
HttpRequest,
|
|
6
|
+
MiddlewareServiceProvider,
|
|
7
|
+
ViewRouter
|
|
8
|
+
} from "../http/index.js";
|
|
9
|
+
import {
|
|
10
|
+
Auth
|
|
11
|
+
} from "../facades/index.js";
|
|
12
|
+
import {
|
|
13
|
+
KernelContext,
|
|
14
|
+
RequestBreakerError,
|
|
15
|
+
kernelContext
|
|
16
|
+
} from "../chunk-fa40971555060604.js";
|
|
17
|
+
import {
|
|
18
|
+
__commonJS,
|
|
19
|
+
__toESM
|
|
20
|
+
} from "../chunk-970e033f764e29fc.js";
|
|
20
21
|
|
|
21
22
|
// ../../node_modules/deepmerge/dist/cjs.js
|
|
22
23
|
var require_cjs = __commonJS((exports, module) => {
|
|
@@ -4213,565 +4214,6 @@ var require_js = __commonJS((exports, module) => {
|
|
|
4213
4214
|
}
|
|
4214
4215
|
});
|
|
4215
4216
|
|
|
4216
|
-
// http/Controller.ts
|
|
4217
|
-
class Controller {
|
|
4218
|
-
requests = {};
|
|
4219
|
-
static kind = "controller";
|
|
4220
|
-
constructor() {
|
|
4221
|
-
}
|
|
4222
|
-
}
|
|
4223
|
-
|
|
4224
|
-
class ResourceController extends Controller {
|
|
4225
|
-
constructor() {
|
|
4226
|
-
super(...arguments);
|
|
4227
|
-
}
|
|
4228
|
-
}
|
|
4229
|
-
// internal/isConstructor.ts
|
|
4230
|
-
function isConstructor(value) {
|
|
4231
|
-
return typeof value === "function" && value.prototype !== undefined;
|
|
4232
|
-
}
|
|
4233
|
-
|
|
4234
|
-
// http/ApiRouter.ts
|
|
4235
|
-
var isController = function(candidate) {
|
|
4236
|
-
return isConstructor(candidate);
|
|
4237
|
-
};
|
|
4238
|
-
|
|
4239
|
-
class RouteHandler {
|
|
4240
|
-
method;
|
|
4241
|
-
handler;
|
|
4242
|
-
methodName;
|
|
4243
|
-
middlewares = [];
|
|
4244
|
-
constructor(method, handler, methodName) {
|
|
4245
|
-
this.method = method;
|
|
4246
|
-
this.handler = handler;
|
|
4247
|
-
this.methodName = methodName;
|
|
4248
|
-
this.handler = handler;
|
|
4249
|
-
this.methodName = methodName;
|
|
4250
|
-
this.method = method;
|
|
4251
|
-
}
|
|
4252
|
-
run(req) {
|
|
4253
|
-
let httpRequest = req;
|
|
4254
|
-
if (isController(this.handler)) {
|
|
4255
|
-
const controller = new this.handler;
|
|
4256
|
-
const handler = controller[this.methodName].bind(controller);
|
|
4257
|
-
httpRequest = controller.requests[this.methodName] ? new controller.requests[this.methodName](req.rawRequest, req.params) : httpRequest;
|
|
4258
|
-
return handler(httpRequest);
|
|
4259
|
-
} else {
|
|
4260
|
-
return this.handler(req);
|
|
4261
|
-
}
|
|
4262
|
-
}
|
|
4263
|
-
middleware(middlewareList) {
|
|
4264
|
-
this.middlewares = middlewareList;
|
|
4265
|
-
return this;
|
|
4266
|
-
}
|
|
4267
|
-
}
|
|
4268
|
-
|
|
4269
|
-
class ApiRouter {
|
|
4270
|
-
routes = {};
|
|
4271
|
-
middlewares = [];
|
|
4272
|
-
middleware(_req) {
|
|
4273
|
-
}
|
|
4274
|
-
get(handler, methodName) {
|
|
4275
|
-
return new RouteHandler("GET", handler, methodName);
|
|
4276
|
-
}
|
|
4277
|
-
post(handler, methodName) {
|
|
4278
|
-
return new RouteHandler("POST", handler, methodName);
|
|
4279
|
-
}
|
|
4280
|
-
put(handler, methodName) {
|
|
4281
|
-
return new RouteHandler("PUT", handler, methodName);
|
|
4282
|
-
}
|
|
4283
|
-
patch(handler, methodName) {
|
|
4284
|
-
return new RouteHandler("PATCH", handler, methodName);
|
|
4285
|
-
}
|
|
4286
|
-
delete(handler, methodName) {
|
|
4287
|
-
return new RouteHandler("DELETE", handler, methodName);
|
|
4288
|
-
}
|
|
4289
|
-
resource(Controller2) {
|
|
4290
|
-
|
|
4291
|
-
class ResourceRouter extends ApiRouter {
|
|
4292
|
-
constructor() {
|
|
4293
|
-
super(...arguments);
|
|
4294
|
-
}
|
|
4295
|
-
routes = {
|
|
4296
|
-
"/": {
|
|
4297
|
-
list: this.get(Controller2, "list"),
|
|
4298
|
-
create: this.post(Controller2, "create")
|
|
4299
|
-
},
|
|
4300
|
-
"/:id": {
|
|
4301
|
-
show: this.get(Controller2, "show"),
|
|
4302
|
-
update: this.put(Controller2, "update"),
|
|
4303
|
-
delete: this.delete(Controller2, "delete")
|
|
4304
|
-
}
|
|
4305
|
-
};
|
|
4306
|
-
}
|
|
4307
|
-
return ResourceRouter;
|
|
4308
|
-
}
|
|
4309
|
-
}
|
|
4310
|
-
// http/ViewRouter.ts
|
|
4311
|
-
class ViewRouter {
|
|
4312
|
-
routes = {};
|
|
4313
|
-
middlewares = [];
|
|
4314
|
-
middleware(req) {
|
|
4315
|
-
}
|
|
4316
|
-
layout(viewPath, handler, children) {
|
|
4317
|
-
function prepare(middlewares = []) {
|
|
4318
|
-
let _children = children ?? {};
|
|
4319
|
-
if (handler && handler.constructor === Object) {
|
|
4320
|
-
_children = handler;
|
|
4321
|
-
}
|
|
4322
|
-
return {
|
|
4323
|
-
exec: async (req) => {
|
|
4324
|
-
let _handler = () => Promise.resolve({
|
|
4325
|
-
data: { [viewPath]: {} },
|
|
4326
|
-
headers: {},
|
|
4327
|
-
head: {}
|
|
4328
|
-
});
|
|
4329
|
-
if (typeof handler === "function") {
|
|
4330
|
-
_handler = handler;
|
|
4331
|
-
}
|
|
4332
|
-
if (Array.isArray(handler)) {
|
|
4333
|
-
const [controller, methodName] = handler;
|
|
4334
|
-
const instance = new controller(app);
|
|
4335
|
-
_handler = instance[methodName].bind(instance);
|
|
4336
|
-
}
|
|
4337
|
-
const data = await _handler(req);
|
|
4338
|
-
return { [viewPath]: data };
|
|
4339
|
-
},
|
|
4340
|
-
children: _children,
|
|
4341
|
-
viewPath,
|
|
4342
|
-
middlewares,
|
|
4343
|
-
kind: "layout"
|
|
4344
|
-
};
|
|
4345
|
-
}
|
|
4346
|
-
return {
|
|
4347
|
-
prepare,
|
|
4348
|
-
middleware: (middlewares) => ({
|
|
4349
|
-
prepare: () => prepare(middlewares)
|
|
4350
|
-
})
|
|
4351
|
-
};
|
|
4352
|
-
}
|
|
4353
|
-
view(viewPath, handler, children) {
|
|
4354
|
-
function prepare(middlewares = []) {
|
|
4355
|
-
let _children = children ?? {};
|
|
4356
|
-
if (handler && handler.constructor === Object) {
|
|
4357
|
-
_children = handler;
|
|
4358
|
-
}
|
|
4359
|
-
return {
|
|
4360
|
-
exec: async (req) => {
|
|
4361
|
-
let _handler = () => Promise.resolve({
|
|
4362
|
-
data: { [viewPath]: {} },
|
|
4363
|
-
headers: {},
|
|
4364
|
-
head: {}
|
|
4365
|
-
});
|
|
4366
|
-
if (typeof handler === "function") {
|
|
4367
|
-
_handler = handler;
|
|
4368
|
-
}
|
|
4369
|
-
if (Array.isArray(handler)) {
|
|
4370
|
-
const [controller, methodName] = handler;
|
|
4371
|
-
const instance = new controller(app);
|
|
4372
|
-
_handler = instance[methodName].bind(instance);
|
|
4373
|
-
}
|
|
4374
|
-
const data = await _handler(req);
|
|
4375
|
-
return { [viewPath]: data };
|
|
4376
|
-
},
|
|
4377
|
-
children: _children,
|
|
4378
|
-
viewPath,
|
|
4379
|
-
middlewares,
|
|
4380
|
-
kind: "view"
|
|
4381
|
-
};
|
|
4382
|
-
}
|
|
4383
|
-
return {
|
|
4384
|
-
prepare,
|
|
4385
|
-
middleware: (middlewares) => ({
|
|
4386
|
-
prepare: () => prepare(middlewares)
|
|
4387
|
-
})
|
|
4388
|
-
};
|
|
4389
|
-
}
|
|
4390
|
-
}
|
|
4391
|
-
// http/Error.ts
|
|
4392
|
-
var GEMI_REQUEST_BREAKER_ERROR = "GEMI_REQUEST_BREAKER_ERROR";
|
|
4393
|
-
|
|
4394
|
-
class RequestBreakerError extends Error {
|
|
4395
|
-
constructor() {
|
|
4396
|
-
super(...arguments);
|
|
4397
|
-
}
|
|
4398
|
-
kind = GEMI_REQUEST_BREAKER_ERROR;
|
|
4399
|
-
payload = { api: {}, view: {} };
|
|
4400
|
-
}
|
|
4401
|
-
|
|
4402
|
-
// http/Router.ts
|
|
4403
|
-
class AuthenticationError extends RequestBreakerError {
|
|
4404
|
-
constructor() {
|
|
4405
|
-
super("Authentication error");
|
|
4406
|
-
this.name = "AuthenticationError";
|
|
4407
|
-
}
|
|
4408
|
-
payload = {
|
|
4409
|
-
api: {
|
|
4410
|
-
status: 401,
|
|
4411
|
-
data: { error: "Authentication error" }
|
|
4412
|
-
},
|
|
4413
|
-
view: {
|
|
4414
|
-
status: 302,
|
|
4415
|
-
headers: {
|
|
4416
|
-
"Cache-Control": "private, no-cache, no-store, max-age=0, must-revalidate",
|
|
4417
|
-
Location: "/auth/sign-in"
|
|
4418
|
-
}
|
|
4419
|
-
}
|
|
4420
|
-
};
|
|
4421
|
-
}
|
|
4422
|
-
|
|
4423
|
-
class ValidationError extends RequestBreakerError {
|
|
4424
|
-
errors = {};
|
|
4425
|
-
constructor(errors) {
|
|
4426
|
-
super("Validation error");
|
|
4427
|
-
this.name = "ValidationError";
|
|
4428
|
-
this.errors = errors;
|
|
4429
|
-
this.payload = {
|
|
4430
|
-
api: {
|
|
4431
|
-
status: 400,
|
|
4432
|
-
data: {
|
|
4433
|
-
error: {
|
|
4434
|
-
kind: "validation_error",
|
|
4435
|
-
messages: errors
|
|
4436
|
-
}
|
|
4437
|
-
},
|
|
4438
|
-
headers: {
|
|
4439
|
-
"Content-Type": "application/json"
|
|
4440
|
-
}
|
|
4441
|
-
},
|
|
4442
|
-
view: {
|
|
4443
|
-
status: 400
|
|
4444
|
-
}
|
|
4445
|
-
};
|
|
4446
|
-
}
|
|
4447
|
-
}
|
|
4448
|
-
// http/requestContext.ts
|
|
4449
|
-
import {AsyncLocalStorage} from "async_hooks";
|
|
4450
|
-
|
|
4451
|
-
// http/Cookie.ts
|
|
4452
|
-
class Cookie {
|
|
4453
|
-
name;
|
|
4454
|
-
value;
|
|
4455
|
-
options;
|
|
4456
|
-
constructor(name, value, options = {}) {
|
|
4457
|
-
this.name = name;
|
|
4458
|
-
this.value = value;
|
|
4459
|
-
this.options = options;
|
|
4460
|
-
}
|
|
4461
|
-
toString() {
|
|
4462
|
-
return [
|
|
4463
|
-
`${this.name}=${this.value}`,
|
|
4464
|
-
this.options.maxAge ? `Max-Age=${this.options.maxAge}` : "",
|
|
4465
|
-
this.options.httpOnly ? "HttpOnly" : "",
|
|
4466
|
-
this.options.secure ? "Secure" : "",
|
|
4467
|
-
this.options.sameSite ? `SameSite=${this.options.sameSite}` : "SameSite=Strict",
|
|
4468
|
-
this.options.path ? `Path=${this.options.path}` : "Path=/",
|
|
4469
|
-
this.options.domain ? `Domain=${this.options.domain}` : "",
|
|
4470
|
-
this.options.expires ? `Expires=${this.options.expires.toUTCString()}` : "",
|
|
4471
|
-
this.options.partitioned ? "Partitioned" : ""
|
|
4472
|
-
].filter((i) => i !== "").join("; ");
|
|
4473
|
-
}
|
|
4474
|
-
}
|
|
4475
|
-
|
|
4476
|
-
// http/requestContext.ts
|
|
4477
|
-
var requestContext = new AsyncLocalStorage;
|
|
4478
|
-
|
|
4479
|
-
class Store {
|
|
4480
|
-
cookies = new Set;
|
|
4481
|
-
user = null;
|
|
4482
|
-
req = null;
|
|
4483
|
-
constructor() {
|
|
4484
|
-
}
|
|
4485
|
-
setCookie(name, value, options = {}) {
|
|
4486
|
-
this.cookies.add(new Cookie(name, value, options));
|
|
4487
|
-
}
|
|
4488
|
-
setUser(user) {
|
|
4489
|
-
this.user = user;
|
|
4490
|
-
}
|
|
4491
|
-
setRequest(req) {
|
|
4492
|
-
this.req = req;
|
|
4493
|
-
}
|
|
4494
|
-
}
|
|
4495
|
-
|
|
4496
|
-
class RequestContext {
|
|
4497
|
-
static getStore() {
|
|
4498
|
-
return requestContext.getStore();
|
|
4499
|
-
}
|
|
4500
|
-
static setRequest(req) {
|
|
4501
|
-
requestContext.getStore().req = req;
|
|
4502
|
-
}
|
|
4503
|
-
static async run(fn) {
|
|
4504
|
-
return requestContext.run(new Store, fn);
|
|
4505
|
-
}
|
|
4506
|
-
}
|
|
4507
|
-
|
|
4508
|
-
// http/HttpRequest.ts
|
|
4509
|
-
var validate = function(ruleName) {
|
|
4510
|
-
const [rule, param] = ruleName.split(":");
|
|
4511
|
-
switch (rule) {
|
|
4512
|
-
case "required":
|
|
4513
|
-
return (value) => {
|
|
4514
|
-
return value !== null && value !== undefined && value?.length > 0;
|
|
4515
|
-
};
|
|
4516
|
-
case "password":
|
|
4517
|
-
return (value) => {
|
|
4518
|
-
const passwordRegex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/;
|
|
4519
|
-
return passwordRegex.test(value);
|
|
4520
|
-
};
|
|
4521
|
-
case "number":
|
|
4522
|
-
return (value) => {
|
|
4523
|
-
if (typeof value !== "number")
|
|
4524
|
-
return false;
|
|
4525
|
-
return !isNaN(value);
|
|
4526
|
-
};
|
|
4527
|
-
case "min":
|
|
4528
|
-
return (value) => {
|
|
4529
|
-
return value?.length >= parseInt(param);
|
|
4530
|
-
};
|
|
4531
|
-
case "max":
|
|
4532
|
-
return (value) => {
|
|
4533
|
-
return value?.length <= parseInt(param);
|
|
4534
|
-
};
|
|
4535
|
-
case "email":
|
|
4536
|
-
return (value) => {
|
|
4537
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
4538
|
-
return emailRegex.test(value);
|
|
4539
|
-
};
|
|
4540
|
-
default:
|
|
4541
|
-
return () => true;
|
|
4542
|
-
}
|
|
4543
|
-
};
|
|
4544
|
-
|
|
4545
|
-
class Input {
|
|
4546
|
-
data;
|
|
4547
|
-
constructor(data) {
|
|
4548
|
-
this.data = data;
|
|
4549
|
-
}
|
|
4550
|
-
get(key) {
|
|
4551
|
-
return this.data[key];
|
|
4552
|
-
}
|
|
4553
|
-
set(key, value) {
|
|
4554
|
-
this.data[key] = value;
|
|
4555
|
-
}
|
|
4556
|
-
has(key) {
|
|
4557
|
-
return this.data[key] !== undefined;
|
|
4558
|
-
}
|
|
4559
|
-
toJSON() {
|
|
4560
|
-
return this.data;
|
|
4561
|
-
}
|
|
4562
|
-
}
|
|
4563
|
-
|
|
4564
|
-
class HttpRequest {
|
|
4565
|
-
rawRequest;
|
|
4566
|
-
headers;
|
|
4567
|
-
cookies;
|
|
4568
|
-
schema = {};
|
|
4569
|
-
params;
|
|
4570
|
-
ctx = RequestContext.getStore();
|
|
4571
|
-
constructor(req, params) {
|
|
4572
|
-
this.params = params;
|
|
4573
|
-
this.rawRequest = req;
|
|
4574
|
-
this.headers = req.headers;
|
|
4575
|
-
const cookie = this.rawRequest.headers.get("Cookie");
|
|
4576
|
-
const cookies = new Map;
|
|
4577
|
-
if (cookie) {
|
|
4578
|
-
const cookieArray = cookie.split(";");
|
|
4579
|
-
for (const c of cookieArray) {
|
|
4580
|
-
const [key, value] = c.split("=");
|
|
4581
|
-
cookies.set(key.trim(), value.trim());
|
|
4582
|
-
}
|
|
4583
|
-
}
|
|
4584
|
-
this.cookies = cookies;
|
|
4585
|
-
}
|
|
4586
|
-
async parseBody() {
|
|
4587
|
-
const inputMap = new Input({});
|
|
4588
|
-
if (this.rawRequest.headers.get("Content-Type") === "application/json") {
|
|
4589
|
-
const body = await this.rawRequest.json();
|
|
4590
|
-
for (const [key, value] of Object.entries(body)) {
|
|
4591
|
-
inputMap.set(key, value);
|
|
4592
|
-
}
|
|
4593
|
-
}
|
|
4594
|
-
if (this.rawRequest.headers.get("Content-Type") === "application/x-www-form-urlencoded") {
|
|
4595
|
-
const body = await this.rawRequest.formData();
|
|
4596
|
-
for (const [key, value] of body) {
|
|
4597
|
-
inputMap.set(key, value);
|
|
4598
|
-
}
|
|
4599
|
-
}
|
|
4600
|
-
if (this.rawRequest.headers.get("Content-Type").startsWith("multipart/form-data")) {
|
|
4601
|
-
const body = await this.rawRequest.formData();
|
|
4602
|
-
for (const [key, value] of body) {
|
|
4603
|
-
if (inputMap.has(key)) {
|
|
4604
|
-
const currentValue = inputMap.get(key);
|
|
4605
|
-
if (Array.isArray(currentValue)) {
|
|
4606
|
-
currentValue.push(value);
|
|
4607
|
-
inputMap.set(key, currentValue);
|
|
4608
|
-
} else {
|
|
4609
|
-
inputMap.set(key, [currentValue, value]);
|
|
4610
|
-
}
|
|
4611
|
-
} else {
|
|
4612
|
-
inputMap.set(key, value);
|
|
4613
|
-
}
|
|
4614
|
-
}
|
|
4615
|
-
}
|
|
4616
|
-
return inputMap;
|
|
4617
|
-
}
|
|
4618
|
-
validateInput(input) {
|
|
4619
|
-
const errors = {};
|
|
4620
|
-
for (const [key, rules] of Object.entries(this.schema)) {
|
|
4621
|
-
for (const [rule, message] of Object.entries(rules)) {
|
|
4622
|
-
const validator = validate(rule);
|
|
4623
|
-
if (!validator(input.get(key))) {
|
|
4624
|
-
if (!errors[key]) {
|
|
4625
|
-
errors[key] = [];
|
|
4626
|
-
}
|
|
4627
|
-
if (rule === "required") {
|
|
4628
|
-
errors[key] = [String(message)];
|
|
4629
|
-
break;
|
|
4630
|
-
} else {
|
|
4631
|
-
errors[key].push(String(message));
|
|
4632
|
-
}
|
|
4633
|
-
}
|
|
4634
|
-
}
|
|
4635
|
-
}
|
|
4636
|
-
if (Object.keys(errors).length > 0) {
|
|
4637
|
-
throw new ValidationError(errors);
|
|
4638
|
-
} else {
|
|
4639
|
-
return input;
|
|
4640
|
-
}
|
|
4641
|
-
}
|
|
4642
|
-
async input() {
|
|
4643
|
-
return this.validateInput(await this.parseBody());
|
|
4644
|
-
}
|
|
4645
|
-
async safeInput() {
|
|
4646
|
-
const input = await this.parseBody();
|
|
4647
|
-
try {
|
|
4648
|
-
this.validateInput(input);
|
|
4649
|
-
return {
|
|
4650
|
-
isValid: true,
|
|
4651
|
-
errors: {},
|
|
4652
|
-
input
|
|
4653
|
-
};
|
|
4654
|
-
} catch (err) {
|
|
4655
|
-
if (!(err instanceof ValidationError)) {
|
|
4656
|
-
throw err;
|
|
4657
|
-
}
|
|
4658
|
-
return {
|
|
4659
|
-
isValid: false,
|
|
4660
|
-
errors: err.errors,
|
|
4661
|
-
input
|
|
4662
|
-
};
|
|
4663
|
-
}
|
|
4664
|
-
}
|
|
4665
|
-
async terminate(params) {
|
|
4666
|
-
throw "not implemented";
|
|
4667
|
-
}
|
|
4668
|
-
}
|
|
4669
|
-
// http/Middleware.ts
|
|
4670
|
-
class Middleware {
|
|
4671
|
-
async run(_req) {
|
|
4672
|
-
return {};
|
|
4673
|
-
}
|
|
4674
|
-
}
|
|
4675
|
-
// http/getCookies.ts
|
|
4676
|
-
function getCookies(req) {
|
|
4677
|
-
const cookies = req.headers.get("cookie");
|
|
4678
|
-
if (!cookies) {
|
|
4679
|
-
return new Map;
|
|
4680
|
-
}
|
|
4681
|
-
const _cookies = new Map;
|
|
4682
|
-
const cookieStrings = cookies.split(";");
|
|
4683
|
-
for (const cookieString of cookieStrings) {
|
|
4684
|
-
const [name, value] = cookieString.split("=");
|
|
4685
|
-
_cookies.set(name.trim(), value);
|
|
4686
|
-
}
|
|
4687
|
-
return _cookies;
|
|
4688
|
-
}
|
|
4689
|
-
// http/MiddlewareServiceProvider.ts
|
|
4690
|
-
class MiddlewareServiceProvider {
|
|
4691
|
-
aliases = {};
|
|
4692
|
-
}
|
|
4693
|
-
// kernel/context.ts
|
|
4694
|
-
import {AsyncLocalStorage as AsyncLocalStorage2} from "async_hooks";
|
|
4695
|
-
var kernelContext = new AsyncLocalStorage2;
|
|
4696
|
-
|
|
4697
|
-
// kernel/KernelContext.ts
|
|
4698
|
-
class KernelContext {
|
|
4699
|
-
static getStore = () => kernelContext.getStore();
|
|
4700
|
-
}
|
|
4701
|
-
|
|
4702
|
-
// http/AuthenticationMiddlware.ts
|
|
4703
|
-
class AuthenticationMiddleware extends Middleware {
|
|
4704
|
-
constructor() {
|
|
4705
|
-
super(...arguments);
|
|
4706
|
-
}
|
|
4707
|
-
async run(req) {
|
|
4708
|
-
const requestContextStore = RequestContext.getStore();
|
|
4709
|
-
const accessToken = requestContextStore.req.cookies.get("access_token");
|
|
4710
|
-
if (!accessToken) {
|
|
4711
|
-
throw new AuthenticationError;
|
|
4712
|
-
}
|
|
4713
|
-
let user = requestContextStore.user;
|
|
4714
|
-
if (!user) {
|
|
4715
|
-
const session = await KernelContext.getStore().authenticationServiceProvider.adapter.findSession({
|
|
4716
|
-
token: accessToken,
|
|
4717
|
-
userAgent: requestContextStore.req.headers.get("User-Agent")
|
|
4718
|
-
});
|
|
4719
|
-
if (!session) {
|
|
4720
|
-
throw new AuthenticationError;
|
|
4721
|
-
}
|
|
4722
|
-
user = session?.user;
|
|
4723
|
-
requestContextStore.setUser(user);
|
|
4724
|
-
}
|
|
4725
|
-
return {};
|
|
4726
|
-
}
|
|
4727
|
-
}
|
|
4728
|
-
// facades/Auth.ts
|
|
4729
|
-
class Auth {
|
|
4730
|
-
static async user() {
|
|
4731
|
-
const requestContextStore = RequestContext.getStore();
|
|
4732
|
-
const accessToken = requestContextStore.req.cookies.get("access_token");
|
|
4733
|
-
let user = requestContextStore.user;
|
|
4734
|
-
if (!user) {
|
|
4735
|
-
const adapter = KernelContext.getStore().authenticationServiceProvider.adapter;
|
|
4736
|
-
const session = await adapter.findSession({
|
|
4737
|
-
token: accessToken,
|
|
4738
|
-
userAgent: requestContextStore.req.headers.get("User-Agent")
|
|
4739
|
-
});
|
|
4740
|
-
user = session?.user;
|
|
4741
|
-
requestContextStore.setUser(user);
|
|
4742
|
-
}
|
|
4743
|
-
if (user) {
|
|
4744
|
-
return user;
|
|
4745
|
-
}
|
|
4746
|
-
return null;
|
|
4747
|
-
}
|
|
4748
|
-
}
|
|
4749
|
-
// facades/Redirect.ts
|
|
4750
|
-
class RedirectError extends RequestBreakerError {
|
|
4751
|
-
constructor(path) {
|
|
4752
|
-
super("Redirect error");
|
|
4753
|
-
this.name = "RedirectError";
|
|
4754
|
-
this.payload = {
|
|
4755
|
-
api: {
|
|
4756
|
-
status: 302,
|
|
4757
|
-
data: { error: "Redirect error" }
|
|
4758
|
-
},
|
|
4759
|
-
view: {
|
|
4760
|
-
status: 302,
|
|
4761
|
-
headers: {
|
|
4762
|
-
"Cache-Control": "private, no-cache, no-store, max-age=0, must-revalidate",
|
|
4763
|
-
Location: path
|
|
4764
|
-
}
|
|
4765
|
-
}
|
|
4766
|
-
};
|
|
4767
|
-
}
|
|
4768
|
-
}
|
|
4769
|
-
|
|
4770
|
-
class Redirect {
|
|
4771
|
-
static to(path) {
|
|
4772
|
-
throw new RedirectError(path);
|
|
4773
|
-
}
|
|
4774
|
-
}
|
|
4775
4217
|
// ../../node_modules/resend/node_modules/@react-email/render/dist/index.mjs
|
|
4776
4218
|
import * as ReactDomServer from "react-dom/server";
|
|
4777
4219
|
|
|
@@ -9122,14 +8564,14 @@ var selectorsMerge = (acc, src, options) => acc.some((s2) => typeof s2 === "obje
|
|
|
9122
8564
|
|
|
9123
8565
|
// ../../node_modules/resend/node_modules/@react-email/render/dist/index.mjs
|
|
9124
8566
|
var import_js_beautify = __toESM(require_js(), 1);
|
|
9125
|
-
var
|
|
8567
|
+
var __defProp = Object.defineProperty;
|
|
9126
8568
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9127
|
-
var
|
|
8569
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9128
8570
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9129
|
-
var __defNormalProp = (obj, key, value) => (key in obj) ?
|
|
8571
|
+
var __defNormalProp = (obj, key, value) => (key in obj) ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9130
8572
|
var __spreadValues = (a, b) => {
|
|
9131
8573
|
for (var prop in b || (b = {}))
|
|
9132
|
-
if (
|
|
8574
|
+
if (__hasOwnProp.call(b, prop))
|
|
9133
8575
|
__defNormalProp(a, prop, b[prop]);
|
|
9134
8576
|
if (__getOwnPropSymbols)
|
|
9135
8577
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
@@ -9138,11 +8580,11 @@ var __spreadValues = (a, b) => {
|
|
|
9138
8580
|
}
|
|
9139
8581
|
return a;
|
|
9140
8582
|
};
|
|
9141
|
-
var
|
|
9142
|
-
get: (a, b) => (typeof
|
|
8583
|
+
var __require = ((x) => typeof import.meta.require !== "undefined" ? import.meta.require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8584
|
+
get: (a, b) => (typeof import.meta.require !== "undefined" ? import.meta.require : a)[b]
|
|
9143
8585
|
}) : x)(function(x) {
|
|
9144
|
-
if (typeof
|
|
9145
|
-
return
|
|
8586
|
+
if (typeof import.meta.require !== "undefined")
|
|
8587
|
+
return import.meta.require.apply(this, arguments);
|
|
9146
8588
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9147
8589
|
});
|
|
9148
8590
|
var __async = (__this, __arguments, generator) => {
|
|
@@ -9194,7 +8636,7 @@ var readStream = (stream) => __async(undefined, null, function* () {
|
|
|
9194
8636
|
});
|
|
9195
8637
|
yield stream.pipeTo(writableStream);
|
|
9196
8638
|
} else {
|
|
9197
|
-
const { Writable } =
|
|
8639
|
+
const { Writable } = __require("stream");
|
|
9198
8640
|
const writable = new Writable({
|
|
9199
8641
|
write(chunk, _encoding, callback) {
|
|
9200
8642
|
result += decoder.decode(chunk);
|
|
@@ -9245,16 +8687,16 @@ var renderAsync = (component, options) => __async(undefined, null, function* ()
|
|
|
9245
8687
|
});
|
|
9246
8688
|
|
|
9247
8689
|
// ../../node_modules/resend/dist/index.mjs
|
|
9248
|
-
var
|
|
8690
|
+
var __defProp2 = Object.defineProperty;
|
|
9249
8691
|
var __defProps = Object.defineProperties;
|
|
9250
8692
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
9251
8693
|
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
9252
|
-
var
|
|
8694
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
9253
8695
|
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
9254
|
-
var __defNormalProp2 = (obj, key, value) => (key in obj) ?
|
|
8696
|
+
var __defNormalProp2 = (obj, key, value) => (key in obj) ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9255
8697
|
var __spreadValues2 = (a, b) => {
|
|
9256
8698
|
for (var prop in b || (b = {}))
|
|
9257
|
-
if (
|
|
8699
|
+
if (__hasOwnProp2.call(b, prop))
|
|
9258
8700
|
__defNormalProp2(a, prop, b[prop]);
|
|
9259
8701
|
if (__getOwnPropSymbols2)
|
|
9260
8702
|
for (var prop of __getOwnPropSymbols2(b)) {
|
|
@@ -13530,7 +12972,7 @@ class BlankAdapter {
|
|
|
13530
12972
|
}
|
|
13531
12973
|
|
|
13532
12974
|
// auth/AuthenticationServiceProvider.ts
|
|
13533
|
-
class
|
|
12975
|
+
class AuthenticationError extends RequestBreakerError {
|
|
13534
12976
|
error;
|
|
13535
12977
|
constructor(error = "Invalid credentials") {
|
|
13536
12978
|
super("Authentication error");
|
|
@@ -13626,11 +13068,11 @@ class AuthController extends Controller {
|
|
|
13626
13068
|
const { email, password } = input.toJSON();
|
|
13627
13069
|
const user = await this.provider.adapter.findUserByEmailAddress(email);
|
|
13628
13070
|
if (!user) {
|
|
13629
|
-
throw new
|
|
13071
|
+
throw new AuthenticationError;
|
|
13630
13072
|
}
|
|
13631
13073
|
const isPasswordValid = await this.provider.verifyPassword(password, user.password);
|
|
13632
13074
|
if (!isPasswordValid) {
|
|
13633
|
-
throw new
|
|
13075
|
+
throw new AuthenticationError;
|
|
13634
13076
|
}
|
|
13635
13077
|
const userAgent2 = req.headers.get("User-Agent");
|
|
13636
13078
|
const hasher = new Bun.CryptoHasher("sha256");
|
|
@@ -13908,3 +13350,4 @@ export {
|
|
|
13908
13350
|
Kernel,
|
|
13909
13351
|
AuthenticationServiceProvider
|
|
13910
13352
|
};
|
|
13353
|
+
export { EmailServiceProvider, Kernel };
|