@xeno-js/core 0.1.12 → 1.0.0
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 +29 -25
- package/dist/index.cjs +97 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -10
- package/dist/index.d.ts +18 -10
- package/dist/index.js +103 -100
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -20,10 +20,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
20
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
21
|
|
|
22
22
|
// src/application/containers/container.utils.ts
|
|
23
|
-
import {
|
|
24
|
-
Guards,
|
|
25
|
-
TOKENS
|
|
26
|
-
} from "@xeno-js/shared";
|
|
23
|
+
import { Guards, TOKENS } from "@xeno-js/shared";
|
|
27
24
|
var ContainerUtils;
|
|
28
25
|
var init_container_utils = __esm({
|
|
29
26
|
"src/application/containers/container.utils.ts"() {
|
|
@@ -59,15 +56,11 @@ var init_container_utils = __esm({
|
|
|
59
56
|
* @throws Error If the service is not found in the container.
|
|
60
57
|
* @throws Error If the service is not a scoped service.
|
|
61
58
|
*/
|
|
62
|
-
async runExecute(
|
|
59
|
+
async runExecute(res, req, container, action) {
|
|
63
60
|
const middleware = container.resolve(TOKENS.MIDDLEWARE);
|
|
64
|
-
return await middleware.execute(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
async () => {
|
|
68
|
-
return await action();
|
|
69
|
-
}
|
|
70
|
-
);
|
|
61
|
+
return await middleware.execute(req, res, async () => {
|
|
62
|
+
return await action();
|
|
63
|
+
});
|
|
71
64
|
}
|
|
72
65
|
});
|
|
73
66
|
}
|
|
@@ -1023,7 +1016,6 @@ var init_gate_keeper = __esm({
|
|
|
1023
1016
|
}
|
|
1024
1017
|
}
|
|
1025
1018
|
return Result14.ok(guest);
|
|
1026
|
-
return Result14.ok(guest);
|
|
1027
1019
|
}
|
|
1028
1020
|
};
|
|
1029
1021
|
}
|
|
@@ -1948,23 +1940,25 @@ var init_csrf = __esm({
|
|
|
1948
1940
|
});
|
|
1949
1941
|
|
|
1950
1942
|
// src/infrastructure/services/extractors/extract-bearer.extractor.ts
|
|
1951
|
-
import { Guards as Guards25
|
|
1943
|
+
import { Guards as Guards25 } from "@xeno-js/shared";
|
|
1952
1944
|
var BearerTokenExtractor;
|
|
1953
1945
|
var init_extract_bearer_extractor = __esm({
|
|
1954
1946
|
"src/infrastructure/services/extractors/extract-bearer.extractor.ts"() {
|
|
1955
1947
|
"use strict";
|
|
1956
1948
|
BearerTokenExtractor = class {
|
|
1949
|
+
constructor(_cookiePrefix) {
|
|
1950
|
+
this._cookiePrefix = _cookiePrefix;
|
|
1951
|
+
}
|
|
1952
|
+
_cookiePrefix;
|
|
1957
1953
|
extract(headers) {
|
|
1958
|
-
const authHeader =
|
|
1959
|
-
if (
|
|
1960
|
-
return void 0;
|
|
1961
|
-
}
|
|
1962
|
-
if (authHeader.toLowerCase().startsWith("bearer ")) {
|
|
1954
|
+
const authHeader = headers.get("Authorization");
|
|
1955
|
+
if (Guards25.isDefined(authHeader) && authHeader.toLowerCase().startsWith("bearer ")) {
|
|
1963
1956
|
return authHeader.substring(7);
|
|
1964
1957
|
}
|
|
1965
|
-
const cookieHeader =
|
|
1958
|
+
const cookieHeader = headers.get("cookie");
|
|
1966
1959
|
if (Guards25.isDefined(cookieHeader)) {
|
|
1967
|
-
const
|
|
1960
|
+
const regex = new RegExp(`${this._cookiePrefix}=([^;]+)`);
|
|
1961
|
+
const match = regex.exec(cookieHeader);
|
|
1968
1962
|
if (!Guards25.isNullOrEmpty(match) && Guards25.isDefined(match[1])) {
|
|
1969
1963
|
return match[1].trim();
|
|
1970
1964
|
}
|
|
@@ -1976,21 +1970,18 @@ var init_extract_bearer_extractor = __esm({
|
|
|
1976
1970
|
});
|
|
1977
1971
|
|
|
1978
1972
|
// src/infrastructure/services/extractors/extract-ssr-bearer.extractor.ts
|
|
1979
|
-
import {
|
|
1980
|
-
Guards as Guards26,
|
|
1981
|
-
StringHelper as StringHelper3
|
|
1982
|
-
} from "@xeno-js/shared";
|
|
1973
|
+
import { Guards as Guards26, StringHelper as StringHelper2 } from "@xeno-js/shared";
|
|
1983
1974
|
var SupabaseSsrTokenExtractor;
|
|
1984
1975
|
var init_extract_ssr_bearer_extractor = __esm({
|
|
1985
1976
|
"src/infrastructure/services/extractors/extract-ssr-bearer.extractor.ts"() {
|
|
1986
1977
|
"use strict";
|
|
1987
1978
|
SupabaseSsrTokenExtractor = class {
|
|
1988
1979
|
extract(headers) {
|
|
1989
|
-
const authHeader =
|
|
1980
|
+
const authHeader = headers.get("authorization");
|
|
1990
1981
|
if (Guards26.isDefined(authHeader) && authHeader.toLowerCase().startsWith("bearer ")) {
|
|
1991
1982
|
return authHeader.substring(7);
|
|
1992
1983
|
}
|
|
1993
|
-
const cookieHeader =
|
|
1984
|
+
const cookieHeader = headers.get("cookie");
|
|
1994
1985
|
if (Guards26.isNullOrEmpty(cookieHeader)) return void 0;
|
|
1995
1986
|
const cookies = cookieHeader.split(";").map((c) => c.trim());
|
|
1996
1987
|
const tokenChunks = {};
|
|
@@ -2013,7 +2004,7 @@ var init_extract_ssr_bearer_extractor = __esm({
|
|
|
2013
2004
|
}
|
|
2014
2005
|
if (Guards26.isNullOrEmpty(fullTokenString)) return void 0;
|
|
2015
2006
|
try {
|
|
2016
|
-
const parsed =
|
|
2007
|
+
const parsed = StringHelper2.safeParse(fullTokenString);
|
|
2017
2008
|
if (Guards26.isDefined(parsed) && Guards26.isObject(parsed) && "access_token" in parsed) {
|
|
2018
2009
|
const accessToken = parsed["access_token"];
|
|
2019
2010
|
if (Guards26.isString(accessToken)) return accessToken;
|
|
@@ -2054,13 +2045,7 @@ var init_http_cookie_extractor = __esm({
|
|
|
2054
2045
|
});
|
|
2055
2046
|
|
|
2056
2047
|
// src/infrastructure/services/extractors/http-header.extractor.ts
|
|
2057
|
-
import {
|
|
2058
|
-
Guards as Guards28,
|
|
2059
|
-
GuidHelper as GuidHelper4,
|
|
2060
|
-
HttpHelper,
|
|
2061
|
-
MathHelper,
|
|
2062
|
-
StringHelper as StringHelper4
|
|
2063
|
-
} from "@xeno-js/shared";
|
|
2048
|
+
import { Guards as Guards28, GuidHelper as GuidHelper4, HttpHelper, MathHelper } from "@xeno-js/shared";
|
|
2064
2049
|
var HttpHeaderExtractor;
|
|
2065
2050
|
var init_http_header_extractor = __esm({
|
|
2066
2051
|
"src/infrastructure/services/extractors/http-header.extractor.ts"() {
|
|
@@ -2086,29 +2071,29 @@ var init_http_header_extractor = __esm({
|
|
|
2086
2071
|
_trustedIp;
|
|
2087
2072
|
_cookieName;
|
|
2088
2073
|
extract(headers) {
|
|
2089
|
-
const correlationId = GuidHelper4.parse(
|
|
2090
|
-
const requestId = GuidHelper4.parse(
|
|
2074
|
+
const correlationId = GuidHelper4.parse(headers.get("x-correlation-id") ?? void 0);
|
|
2075
|
+
const requestId = GuidHelper4.parse(headers.get("x-request-id") ?? void 0);
|
|
2091
2076
|
const token = this._bearerExtractor.extract(headers);
|
|
2092
|
-
const clientIp =
|
|
2093
|
-
const spanId = GuidHelper4.parse(
|
|
2094
|
-
const parentSpanId =
|
|
2095
|
-
const acceptHeader =
|
|
2096
|
-
const contentTypeHeader =
|
|
2097
|
-
const userAgent =
|
|
2098
|
-
const returnAddress =
|
|
2099
|
-
const sequenceId =
|
|
2100
|
-
const position =
|
|
2101
|
-
const size =
|
|
2102
|
-
const expiration =
|
|
2103
|
-
const csrf =
|
|
2104
|
-
const cookieHeader =
|
|
2077
|
+
const clientIp = headers.get(this._trustedIp?.toLowerCase() ?? "x-forwarded-for") ?? headers.get("x-real-ip") ?? void 0;
|
|
2078
|
+
const spanId = GuidHelper4.parse(headers.get("x-span-id") ?? void 0);
|
|
2079
|
+
const parentSpanId = headers.get("x-parent-span-id") ?? void 0;
|
|
2080
|
+
const acceptHeader = headers.get("accept");
|
|
2081
|
+
const contentTypeHeader = headers.get("content-type");
|
|
2082
|
+
const userAgent = headers.get("user-agent") ?? void 0;
|
|
2083
|
+
const returnAddress = headers.get("x-return-address") ?? void 0;
|
|
2084
|
+
const sequenceId = headers.get("x-sequence-id") ?? void 0;
|
|
2085
|
+
const position = headers.get("x-sequence-position");
|
|
2086
|
+
const size = headers.get("x-sequence-size");
|
|
2087
|
+
const expiration = headers.get("x-expiration");
|
|
2088
|
+
const csrf = headers.get("x-csrf-token") ?? void 0;
|
|
2089
|
+
const cookieHeader = headers.get("cookie") ?? void 0;
|
|
2105
2090
|
const csrfCookie = this._cookieExtractor.extract({
|
|
2106
2091
|
header: cookieHeader,
|
|
2107
2092
|
name: this._cookieName
|
|
2108
2093
|
});
|
|
2109
|
-
const origin =
|
|
2094
|
+
const origin = headers.get("origin") ?? void 0;
|
|
2110
2095
|
const cleanOrigin = HttpHelper.sanitizeOriginUrl(origin);
|
|
2111
|
-
const referer =
|
|
2096
|
+
const referer = headers.get("referer") ?? void 0;
|
|
2112
2097
|
const cleanReferer = HttpHelper.sanitizeOriginUrl(referer);
|
|
2113
2098
|
const accept = acceptHeader === "*/*" ? void 0 : acceptHeader;
|
|
2114
2099
|
const formatIndicator = accept ?? contentTypeHeader ?? "application/json";
|
|
@@ -2291,13 +2276,13 @@ var init_allow_method_factory = __esm({
|
|
|
2291
2276
|
// src/infrastructure/factories/axios.factory.ts
|
|
2292
2277
|
import http from "http";
|
|
2293
2278
|
import https from "https";
|
|
2294
|
-
import {
|
|
2279
|
+
import { AxiosHttpClient } from "@xeno-js/shared";
|
|
2295
2280
|
import axios from "axios";
|
|
2296
2281
|
var NodeAxiosFactory;
|
|
2297
2282
|
var init_axios_factory = __esm({
|
|
2298
2283
|
"src/infrastructure/factories/axios.factory.ts"() {
|
|
2299
2284
|
"use strict";
|
|
2300
|
-
NodeAxiosFactory = class
|
|
2285
|
+
NodeAxiosFactory = class {
|
|
2301
2286
|
create(config) {
|
|
2302
2287
|
const isKeepAlive = config.keepAlive ?? true;
|
|
2303
2288
|
const maxSockets = config.maxSockets ?? 100;
|
|
@@ -2842,17 +2827,26 @@ var init_auth_utils = __esm({
|
|
|
2842
2827
|
* @link https://github.com/xeno-js/xeno-js
|
|
2843
2828
|
*/
|
|
2844
2829
|
async addAuthN(container, opts) {
|
|
2845
|
-
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2830
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
2831
|
+
if (Guards46.isDefined(opts.customAuth)) {
|
|
2832
|
+
const authService = opts.customAuth.authExtendedService();
|
|
2833
|
+
container.addScoped(TOKENS4.AUTH_SERVICE, () => {
|
|
2834
|
+
return authService;
|
|
2835
|
+
});
|
|
2836
|
+
container.addSingleton(TOKENS4.BASE_AUTH_SERVICE, () => {
|
|
2837
|
+
return authService;
|
|
2838
|
+
});
|
|
2839
|
+
} else {
|
|
2840
|
+
const { SupabaseServerAuthFactory: SupabaseServerAuthFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
2841
|
+
const factory = new SupabaseServerAuthFactory2();
|
|
2842
|
+
const supabase = factory.create({ config: opts, container });
|
|
2843
|
+
container.addScoped(TOKENS4.AUTH_SERVICE, () => {
|
|
2844
|
+
return supabase;
|
|
2845
|
+
});
|
|
2846
|
+
container.addSingleton(TOKENS4.BASE_AUTH_SERVICE, () => {
|
|
2847
|
+
return supabase;
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2856
2850
|
}
|
|
2857
2851
|
});
|
|
2858
2852
|
}
|
|
@@ -3447,6 +3441,7 @@ var init_base_controller = __esm({
|
|
|
3447
3441
|
/**
|
|
3448
3442
|
* Helper to send a query through the mediator and return the result.
|
|
3449
3443
|
* @param request - The IQuery instance to be sent.
|
|
3444
|
+
* @param signal - The AbortSignal
|
|
3450
3445
|
* @returns A promise resolving to the result of the query.
|
|
3451
3446
|
*
|
|
3452
3447
|
* @author Xeno
|
|
@@ -3454,13 +3449,13 @@ var init_base_controller = __esm({
|
|
|
3454
3449
|
* @since 2025-09-30
|
|
3455
3450
|
* @link https://github.com/xeno-js/xeno-js
|
|
3456
3451
|
*/
|
|
3457
|
-
_query(request) {
|
|
3458
|
-
const signal = new AbortController().signal;
|
|
3452
|
+
_query(request, signal) {
|
|
3459
3453
|
return this._mediator.query(request, signal);
|
|
3460
3454
|
}
|
|
3461
3455
|
/**
|
|
3462
3456
|
* Helper to send a command through the mediator and return the result.
|
|
3463
3457
|
* @param request - The ICommand instance to be sent.
|
|
3458
|
+
* @param signal - The AbortSignal
|
|
3464
3459
|
* @returns A promise resolving to the result of the command.
|
|
3465
3460
|
*
|
|
3466
3461
|
* @author Xeno
|
|
@@ -3468,8 +3463,7 @@ var init_base_controller = __esm({
|
|
|
3468
3463
|
* @since 2025-09-30
|
|
3469
3464
|
* @link https://github.com/xeno-js/xeno-js
|
|
3470
3465
|
*/
|
|
3471
|
-
_send(request) {
|
|
3472
|
-
const signal = new AbortController().signal;
|
|
3466
|
+
_send(request, signal) {
|
|
3473
3467
|
return this._mediator.send(request, signal);
|
|
3474
3468
|
}
|
|
3475
3469
|
getContext() {
|
|
@@ -3506,7 +3500,7 @@ var init_allow_method_middleware = __esm({
|
|
|
3506
3500
|
}
|
|
3507
3501
|
_requestContext;
|
|
3508
3502
|
_allowMethod;
|
|
3509
|
-
async execute(req,
|
|
3503
|
+
async execute(req, _res, next) {
|
|
3510
3504
|
const isAllowed = this._allowMethod.check(req.path, req.method);
|
|
3511
3505
|
if (!isAllowed) {
|
|
3512
3506
|
const { network, tracing } = this._requestContext.getContext() ?? {};
|
|
@@ -3557,7 +3551,7 @@ var init_allow_origin_middleware = __esm({
|
|
|
3557
3551
|
_allowOrigin;
|
|
3558
3552
|
_requestContext;
|
|
3559
3553
|
_logger;
|
|
3560
|
-
async execute(req,
|
|
3554
|
+
async execute(req, _res, next) {
|
|
3561
3555
|
const { network, tracing } = this._requestContext.getContext() ?? {};
|
|
3562
3556
|
const origin = network?.origin;
|
|
3563
3557
|
if (!this._allowOrigin.isAllowed(origin)) {
|
|
@@ -3602,8 +3596,8 @@ var init_auth_middleware = __esm({
|
|
|
3602
3596
|
_tokenExtractor;
|
|
3603
3597
|
_gateKeeper;
|
|
3604
3598
|
_logger;
|
|
3605
|
-
async execute(req,
|
|
3606
|
-
const token = this._tokenExtractor.extract(headers);
|
|
3599
|
+
async execute(req, _res, next) {
|
|
3600
|
+
const token = this._tokenExtractor.extract(req.headers);
|
|
3607
3601
|
const authResult = await this._gateKeeper.authenticate(token);
|
|
3608
3602
|
if (!authResult.isOk()) {
|
|
3609
3603
|
const error = authResult.getErrorOrThrow();
|
|
@@ -3646,12 +3640,12 @@ var init_composite_middleware = __esm({
|
|
|
3646
3640
|
this._middlewares = _middlewares;
|
|
3647
3641
|
}
|
|
3648
3642
|
_middlewares;
|
|
3649
|
-
async execute(req,
|
|
3643
|
+
async execute(req, res, next) {
|
|
3650
3644
|
let currentNext = next;
|
|
3651
3645
|
for (let i = this._middlewares.length - 1; i >= 0; i--) {
|
|
3652
3646
|
const currentBehavior = this._middlewares[i];
|
|
3653
3647
|
const previousNext = currentNext;
|
|
3654
|
-
currentNext = () => currentBehavior.execute(req,
|
|
3648
|
+
currentNext = () => currentBehavior.execute(req, res, previousNext);
|
|
3655
3649
|
}
|
|
3656
3650
|
return currentNext();
|
|
3657
3651
|
}
|
|
@@ -3672,7 +3666,7 @@ var init_cors_middleware = __esm({
|
|
|
3672
3666
|
}
|
|
3673
3667
|
_requestContext;
|
|
3674
3668
|
_withCredentials;
|
|
3675
|
-
async execute(_req,
|
|
3669
|
+
async execute(_req, _res, next) {
|
|
3676
3670
|
const { network } = this._requestContext.getContext() ?? {};
|
|
3677
3671
|
const origin = network?.origin;
|
|
3678
3672
|
const response = await next();
|
|
@@ -3709,7 +3703,7 @@ var init_csrf_middleware = __esm({
|
|
|
3709
3703
|
}
|
|
3710
3704
|
_requestContext;
|
|
3711
3705
|
_csrfTokenService;
|
|
3712
|
-
async execute(req,
|
|
3706
|
+
async execute(req, _res, next) {
|
|
3713
3707
|
const method = req.method.toUpperCase();
|
|
3714
3708
|
const isStateChanging = ["POST", "PUT", "DELETE", "PATCH"].includes(method);
|
|
3715
3709
|
if (isStateChanging) {
|
|
@@ -3801,7 +3795,7 @@ var init_csrf_cookie_middleware = __esm({
|
|
|
3801
3795
|
_requestContext;
|
|
3802
3796
|
_csrfTokenService;
|
|
3803
3797
|
_csrf;
|
|
3804
|
-
async execute(_req,
|
|
3798
|
+
async execute(_req, _res, next) {
|
|
3805
3799
|
const response = await next();
|
|
3806
3800
|
const context = this._requestContext.getContext();
|
|
3807
3801
|
const identity = context?.identity;
|
|
@@ -3841,7 +3835,7 @@ var init_options_middleware = __esm({
|
|
|
3841
3835
|
_alloewMethod;
|
|
3842
3836
|
_allowHeaders;
|
|
3843
3837
|
_withCredentials;
|
|
3844
|
-
async execute(req,
|
|
3838
|
+
async execute(req, _res, next) {
|
|
3845
3839
|
if (req.method.toUpperCase() === "OPTIONS") {
|
|
3846
3840
|
const network = this._requestContext.getNetworkContext();
|
|
3847
3841
|
const origin = network?.origin;
|
|
@@ -3887,7 +3881,7 @@ var init_rate_limiter_middleware = __esm({
|
|
|
3887
3881
|
_keyBuilder;
|
|
3888
3882
|
_logger;
|
|
3889
3883
|
_opts;
|
|
3890
|
-
async execute(req,
|
|
3884
|
+
async execute(req, _res, next) {
|
|
3891
3885
|
const cacheKey = this._keyBuilder.buildRateLimitKey(req.path);
|
|
3892
3886
|
const { network, tracing } = this._ctxAccessor.getContext() ?? {};
|
|
3893
3887
|
if (!Guards40.isDefined(cacheKey))
|
|
@@ -3920,7 +3914,7 @@ var init_rate_limiter_middleware = __esm({
|
|
|
3920
3914
|
error: {
|
|
3921
3915
|
code: ERROR_CODES7.TOO_MANY_REQUESTS,
|
|
3922
3916
|
message: ERROR_CODE_MESSAGES6[ERROR_CODES7.TOO_MANY_REQUESTS],
|
|
3923
|
-
details: `Rate limit exceeded
|
|
3917
|
+
details: `Rate limit exceeded.`,
|
|
3924
3918
|
path: req.path
|
|
3925
3919
|
},
|
|
3926
3920
|
correlationId: tracing?.correlationId ?? GuidHelper10.generate(),
|
|
@@ -4035,14 +4029,14 @@ var init_request_middleware = __esm({
|
|
|
4035
4029
|
_extractor;
|
|
4036
4030
|
_resolver;
|
|
4037
4031
|
_logger;
|
|
4038
|
-
async execute(req,
|
|
4032
|
+
async execute(req, res, next) {
|
|
4039
4033
|
const correlationId = GuidHelper11.generate();
|
|
4040
4034
|
const requestId = GuidHelper11.generate();
|
|
4041
4035
|
const spanId = correlationId;
|
|
4042
4036
|
const formatIndicator = "application/json";
|
|
4043
4037
|
try {
|
|
4044
|
-
const meta = this._extractor.extract(headers);
|
|
4045
|
-
const clientIp = this._resolver.resolve(req
|
|
4038
|
+
const meta = this._extractor.extract(req.headers);
|
|
4039
|
+
const clientIp = this._resolver.resolve(req, meta.clientIp);
|
|
4046
4040
|
const metadata = {
|
|
4047
4041
|
...meta,
|
|
4048
4042
|
clientIp,
|
|
@@ -4055,7 +4049,7 @@ var init_request_middleware = __esm({
|
|
|
4055
4049
|
metadata,
|
|
4056
4050
|
identity: GUEST3,
|
|
4057
4051
|
path: req.path,
|
|
4058
|
-
transport: req
|
|
4052
|
+
transport: { req, res }
|
|
4059
4053
|
});
|
|
4060
4054
|
const result = await this._requestContext.runAsync(tmpContext, async () => {
|
|
4061
4055
|
return next();
|
|
@@ -4186,7 +4180,11 @@ var init_middleware_module = __esm({
|
|
|
4186
4180
|
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
4187
4181
|
const { HttpCookieExtractor: HttpCookieExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4188
4182
|
const { HttpHeaderExtractor: HttpHeaderExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4189
|
-
const tokenExtractor = await this._getTokenExtractor(
|
|
4183
|
+
const tokenExtractor = await this._getTokenExtractor(
|
|
4184
|
+
opts.isSSR,
|
|
4185
|
+
opts.authCookieName,
|
|
4186
|
+
opts.customTokenExtractor
|
|
4187
|
+
);
|
|
4190
4188
|
container.addSingleton(
|
|
4191
4189
|
TOKENS4.SERVICE_EXTRACTOR,
|
|
4192
4190
|
() => new HttpHeaderExtractor2(
|
|
@@ -4305,13 +4303,15 @@ var init_middleware_module = __esm({
|
|
|
4305
4303
|
return new CompositeMiddleware2(middlewares);
|
|
4306
4304
|
});
|
|
4307
4305
|
}
|
|
4308
|
-
async _getTokenExtractor(isSSR) {
|
|
4306
|
+
async _getTokenExtractor(isSSR, cookieName, customTokenExtractor) {
|
|
4307
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
4308
|
+
if (Guards46.isDefined(customTokenExtractor)) return customTokenExtractor();
|
|
4309
4309
|
if (isSSR) {
|
|
4310
4310
|
const { SupabaseSsrTokenExtractor: SupabaseSsrTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4311
4311
|
return new SupabaseSsrTokenExtractor2();
|
|
4312
4312
|
} else {
|
|
4313
4313
|
const { BearerTokenExtractor: BearerTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4314
|
-
return new BearerTokenExtractor2();
|
|
4314
|
+
return new BearerTokenExtractor2(cookieName ?? "sb-access-token");
|
|
4315
4315
|
}
|
|
4316
4316
|
}
|
|
4317
4317
|
async _getAllowMethod(configure, opts) {
|
|
@@ -4695,7 +4695,17 @@ var AppBuilder = class {
|
|
|
4695
4695
|
allowOrigins: [],
|
|
4696
4696
|
allowHeaders: [],
|
|
4697
4697
|
cors: true,
|
|
4698
|
-
withCredentials: true
|
|
4698
|
+
withCredentials: true,
|
|
4699
|
+
authCookieName: "sb-access-token"
|
|
4700
|
+
};
|
|
4701
|
+
_authConfig = {
|
|
4702
|
+
url: "",
|
|
4703
|
+
key: "",
|
|
4704
|
+
opts: void 0,
|
|
4705
|
+
redirectTo: "",
|
|
4706
|
+
storageOpts: { type: "memory", cookieOpts: void 0, storage: void 0 },
|
|
4707
|
+
ssrOpts: void 0,
|
|
4708
|
+
customAuth: void 0
|
|
4699
4709
|
};
|
|
4700
4710
|
_httpConfig = {
|
|
4701
4711
|
dataSourceToken: void 0,
|
|
@@ -4826,21 +4836,13 @@ var AppBuilder = class {
|
|
|
4826
4836
|
addAuth(setupAction) {
|
|
4827
4837
|
if (this._isAuthModuleQueued) return this;
|
|
4828
4838
|
this._isAuthModuleQueued = true;
|
|
4829
|
-
|
|
4830
|
-
url: "",
|
|
4831
|
-
key: "",
|
|
4832
|
-
opts: void 0,
|
|
4833
|
-
redirectTo: "",
|
|
4834
|
-
storageOpts: { type: "memory", cookieOpts: void 0, storage: void 0 },
|
|
4835
|
-
ssrOpts: void 0
|
|
4836
|
-
};
|
|
4837
|
-
setupAction(config, this._configuration);
|
|
4839
|
+
setupAction(this._authConfig, this._configuration);
|
|
4838
4840
|
this._modules.push({
|
|
4839
4841
|
priority: 3,
|
|
4840
4842
|
name: "AuthModule",
|
|
4841
4843
|
action: async () => {
|
|
4842
4844
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
4843
|
-
await AuthUtils2.addAuthN(this._container,
|
|
4845
|
+
await AuthUtils2.addAuthN(this._container, this._authConfig);
|
|
4844
4846
|
}
|
|
4845
4847
|
});
|
|
4846
4848
|
return this;
|
|
@@ -5092,7 +5094,8 @@ var AppBuilder = class {
|
|
|
5092
5094
|
const middlewareModule = new MiddlewareModule2();
|
|
5093
5095
|
await middlewareModule.configure(this._container, {
|
|
5094
5096
|
...this._middlewareConfig,
|
|
5095
|
-
isAuth: this._isAuthModuleQueued
|
|
5097
|
+
isAuth: this._isAuthModuleQueued,
|
|
5098
|
+
customTokenExtractor: this._authConfig.customAuth?.authHeaderExtractor
|
|
5096
5099
|
});
|
|
5097
5100
|
}
|
|
5098
5101
|
});
|