@arkstack/http 0.17.16 → 0.17.17

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.
@@ -1,7 +1,6 @@
1
1
  import { ClearHttpContext, Request, Response } from "clear-router";
2
2
  import { MiddlewareClass, MiddlewareInstance, RequestData } from "clear-router/types/basic";
3
3
  import { User } from "@app/models/User";
4
-
5
4
  //#region src/Response.d.ts
6
5
  declare const setResponseResolver: (resolver?: () => Response$1<any> | undefined) => void;
7
6
  /**
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /// <reference path="./app.d.ts" />
2
- import { $ as registerResponseFlashSweep, A as DatabaseSessionDriver, B as encodeSignedValue, C as RedirectHelper, Ct as setResponseResolver, D as ResponseSource, E as RequestSource, F as decryptSessionValue, G as setCookie, H as getCookie, I as encryptSessionValue, J as createSessionDriver, K as signValue, L as decodeJson, M as BaseSessionDriver, N as decodeSessionPayload, O as SessionHelper, P as encodeSessionPayload, Q as getSession, R as decodeSignedValue, S as OldHelper, St as Response, T as RequestOptions, U as parseCookies, V as generateSessionId, W as serializeCookie, X as attachViewState, Y as getSessionDriver, Z as ensureSession, _ as ClassMiddleware, _t as SessionInitialState, a as redirect, at as ErrorBag, b as HeaderSource, bt as cookie_options, c as isHeaders, ct as HttpContextLike, d as normalizeHeaderValue, dt as SessionDriver, et as arkstackHttpPlugin, f as normalizeHeaders, ft as SessionDriverResult, g as setRequestResolver, gt as SessionErrorValue, h as Request, ht as SessionErrorSource, i as old, it as setSessionResolver, j as CookieSessionDriver, k as FileSessionDriver, l as isRecord, lt as PersistentSessionConfig, m as unwrapRequestSource, mt as SessionErrorRecord, n as web, nt as Session, o as redirectBackTarget, ot as BaseSessionDriverOptions, p as resolveMiddleware, pt as SessionDriverType, q as configureSession, r as webMiddlewareKey, rt as clearFallbackSession, s as resolveRedirectTarget, st as DatabaseSessionDriverOptions, t as isWebRequest, tt as kanunSessionPlugin, u as makeHeaders, ut as SessionConfig, v as FunctionMiddleware, vt as SessionMessageProvider, w as RequestHelper, x as HeaderValue, xt as FlashBag, y as HeaderMap, yt as SessionPayload, z as encodeJson } from "./index-Dw5AaS_c.js";
2
+ import { $ as registerResponseFlashSweep, A as DatabaseSessionDriver, B as encodeSignedValue, C as RedirectHelper, Ct as setResponseResolver, D as ResponseSource, E as RequestSource, F as decryptSessionValue, G as setCookie, H as getCookie, I as encryptSessionValue, J as createSessionDriver, K as signValue, L as decodeJson, M as BaseSessionDriver, N as decodeSessionPayload, O as SessionHelper, P as encodeSessionPayload, Q as getSession, R as decodeSignedValue, S as OldHelper, St as Response, T as RequestOptions, U as parseCookies, V as generateSessionId, W as serializeCookie, X as attachViewState, Y as getSessionDriver, Z as ensureSession, _ as ClassMiddleware, _t as SessionInitialState, a as redirect, at as ErrorBag, b as HeaderSource, bt as cookie_options, c as isHeaders, ct as HttpContextLike, d as normalizeHeaderValue, dt as SessionDriver, et as arkstackHttpPlugin, f as normalizeHeaders, ft as SessionDriverResult, g as setRequestResolver, gt as SessionErrorValue, h as Request, ht as SessionErrorSource, i as old, it as setSessionResolver, j as CookieSessionDriver, k as FileSessionDriver, l as isRecord, lt as PersistentSessionConfig, m as unwrapRequestSource, mt as SessionErrorRecord, n as web, nt as Session, o as redirectBackTarget, ot as BaseSessionDriverOptions, p as resolveMiddleware, pt as SessionDriverType, q as configureSession, r as webMiddlewareKey, rt as clearFallbackSession, s as resolveRedirectTarget, st as DatabaseSessionDriverOptions, t as isWebRequest, tt as kanunSessionPlugin, u as makeHeaders, ut as SessionConfig, v as FunctionMiddleware, vt as SessionMessageProvider, w as RequestHelper, x as HeaderValue, xt as FlashBag, y as HeaderMap, yt as SessionPayload, z as encodeJson } from "./index-CtDcgfhW.js";
3
3
  export { BaseSessionDriver, BaseSessionDriverOptions, ClassMiddleware, CookieSessionDriver, DatabaseSessionDriver, DatabaseSessionDriverOptions, ErrorBag, FileSessionDriver, FlashBag, FunctionMiddleware, HeaderMap, HeaderSource, HeaderValue, HttpContextLike, OldHelper, PersistentSessionConfig, RedirectHelper, Request, RequestHelper, RequestOptions, RequestSource, Response, ResponseSource, Session, SessionConfig, SessionDriver, SessionDriverResult, SessionDriverType, SessionErrorRecord, SessionErrorSource, SessionErrorValue, SessionHelper, SessionInitialState, SessionMessageProvider, SessionPayload, arkstackHttpPlugin, attachViewState, clearFallbackSession, configureSession, cookie_options, createSessionDriver, decodeJson, decodeSessionPayload, decodeSignedValue, decryptSessionValue, encodeJson, encodeSessionPayload, encodeSignedValue, encryptSessionValue, ensureSession, generateSessionId, getCookie, getSession, getSessionDriver, isHeaders, isRecord, isWebRequest, kanunSessionPlugin, makeHeaders, normalizeHeaderValue, normalizeHeaders, old, parseCookies, redirect, redirectBackTarget, registerResponseFlashSweep, resolveMiddleware, resolveRedirectTarget, serializeCookie, setCookie, setRequestResolver, setResponseResolver, setSessionResolver, signValue, unwrapRequestSource, web, webMiddlewareKey };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as registerResponseFlashSweep, B as setRequestResolver, C as parseCookies, D as attachViewState, E as signValue, F as ErrorBag, G as normalizeHeaders, H as isRecord, I as FlashBag, K as resolveMiddleware, L as Response, M as Session, N as clearFallbackSession, O as ensureSession, P as setSessionResolver, R as setResponseResolver, S as getCookie, T as setCookie, U as makeHeaders, V as isHeaders, W as normalizeHeaderValue, _ as decodeJson, a as kanunSessionPlugin, b as encodeSignedValue, c as getSessionDriver, d as CookieSessionDriver, f as BaseSessionDriver, g as encodeSessionPayload, h as decodeSessionPayload, i as arkstackHttpPlugin, j as old, k as getSession, l as FileSessionDriver, m as encryptSessionValue, n as redirectBackTarget, o as configureSession, p as decryptSessionValue, q as unwrapRequestSource, r as resolveRedirectTarget, s as createSessionDriver, t as redirect, u as DatabaseSessionDriver, v as decodeSignedValue, w as serializeCookie, x as generateSessionId, y as encodeJson, z as Request } from "./redirect-BzYZk5xe.js";
1
+ import { A as registerResponseFlashSweep, B as setRequestResolver, C as parseCookies, D as attachViewState, E as signValue, F as ErrorBag, G as normalizeHeaders, H as isRecord, I as FlashBag, K as resolveMiddleware, L as Response, M as Session, N as clearFallbackSession, O as ensureSession, P as setSessionResolver, R as setResponseResolver, S as getCookie, T as setCookie, U as makeHeaders, V as isHeaders, W as normalizeHeaderValue, _ as decodeJson, a as kanunSessionPlugin, b as encodeSignedValue, c as getSessionDriver, d as CookieSessionDriver, f as BaseSessionDriver, g as encodeSessionPayload, h as decodeSessionPayload, i as arkstackHttpPlugin, j as old, k as getSession, l as FileSessionDriver, m as encryptSessionValue, n as redirectBackTarget, o as configureSession, p as decryptSessionValue, q as unwrapRequestSource, r as resolveRedirectTarget, s as createSessionDriver, t as redirect, u as DatabaseSessionDriver, v as decodeSignedValue, w as serializeCookie, x as generateSessionId, y as encodeJson, z as Request } from "./redirect-g4KUj_g-.js";
2
2
  //#region src/middlewares/web.ts
3
3
  const webMiddlewareKey = Symbol.for("arkstack:http:web");
4
4
  const markWebRequest = (target) => {
@@ -366,7 +366,8 @@ const asMessageRecord = (value) => {
366
366
  };
367
367
  const callRecordMethod = (source, method) => {
368
368
  if (typeof source[method] !== "function") return;
369
- return asMessageRecord(source[method]());
369
+ const value = source[method]();
370
+ return asMessageRecord(value);
370
371
  };
371
372
  const resolveMessageRecord = (source) => {
372
373
  if (!isRecord(source)) return;
@@ -925,7 +926,8 @@ const parseCookies = (header) => {
925
926
  const getCookie = (context, name) => {
926
927
  const ctx = isRecord(context.ctx) ? context.ctx : context;
927
928
  const headers = (context.request || ctx.clearRequest || ctx.req || ctx.request)?.headers || ctx.headers || ctx.req?.headers || ctx.request?.headers;
928
- return parseCookies(typeof headers?.get === "function" ? headers.get("cookie") : headers?.cookie)[name];
929
+ const cookie = typeof headers?.get === "function" ? headers.get("cookie") : headers?.cookie;
930
+ return parseCookies(cookie)[name];
929
931
  };
930
932
  const serializeCookie = (name, value, options = {}) => {
931
933
  const parts = [`${name}=${encodeURIComponent(value)}`];
@@ -947,12 +949,14 @@ const withoutCookie = (current, cookieName) => {
947
949
  const upsertHeaderValue = (target, headerName, cookieName, value) => {
948
950
  if (!target) return false;
949
951
  if (typeof target.setHeader === "function") {
950
- const next = [...withoutCookie(typeof target.getHeader === "function" ? target.getHeader(headerName) : void 0, cookieName), value];
952
+ const current = typeof target.getHeader === "function" ? target.getHeader(headerName) : void 0;
953
+ const next = [...withoutCookie(current, cookieName), value];
951
954
  target.setHeader(headerName, next);
952
955
  return true;
953
956
  }
954
957
  if (target.headers && typeof target.headers.set === "function") {
955
- const next = [...withoutCookie(target.headers.get(headerName), cookieName), value];
958
+ const current = target.headers.get(headerName);
959
+ const next = [...withoutCookie(current, cookieName), value];
956
960
  target.headers.set(headerName, next.join(", "));
957
961
  return true;
958
962
  }
@@ -971,7 +975,8 @@ const setCookie = (context, name, value, options = {}) => {
971
975
  const cookie = serializeCookie(name, value, options);
972
976
  const response = context.response || ctx.clearResponse;
973
977
  if (response?.headers && typeof response.headers.set === "function") {
974
- const next = [...withoutCookie(response.headers.get("set-cookie"), name), cookie];
978
+ const current = response.headers.get("set-cookie");
979
+ const next = [...withoutCookie(current, name), cookie];
975
980
  response.headers.set("set-cookie", next.join(", "));
976
981
  }
977
982
  upsertHeaderValue(response?.source, "Set-Cookie", name, cookie) || upsertHeaderValue(ctx.res, "Set-Cookie", name, cookie) || upsertHeaderValue(ctx.response, "Set-Cookie", name, cookie) || upsertHeaderValue(ctx.response?.source, "Set-Cookie", name, cookie) || upsertHeaderValue(ctx.event?.res, "Set-Cookie", name, cookie);
@@ -1295,7 +1300,7 @@ const readAppSessionConfig = () => {
1295
1300
  driver: config("session.driver", "cookie"),
1296
1301
  cookie: config("session.cookie", "arkstack_session"),
1297
1302
  secret: config("session.secret"),
1298
- ttl: config("session.ttl", 3600 * 24 * 7),
1303
+ ttl: config("session.ttl", 604800),
1299
1304
  cookie_options: {
1300
1305
  path: config("session.path", "/"),
1301
1306
  httpOnly: config("session.http_only", true),
package/dist/setup.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { C as RedirectHelper, O as SessionHelper, S as OldHelper, St as Response, w as RequestHelper } from "./index-Dw5AaS_c.js";
1
+ import { C as RedirectHelper, O as SessionHelper, S as OldHelper, St as Response, w as RequestHelper } from "./index-CtDcgfhW.js";
2
+ import "dotenv/config";
3
+ import "clear-router/decorators/setup";
2
4
  import { User } from "@app/models/User";
3
-
4
5
  //#region src/setup.d.ts
5
6
  declare global {
6
7
  var session: SessionHelper;
package/dist/setup.js CHANGED
@@ -1,4 +1,4 @@
1
- import { L as Response$1, a as kanunSessionPlugin, i as arkstackHttpPlugin, j as old, t as redirect, z as Request$1 } from "./redirect-BzYZk5xe.js";
1
+ import { L as Response$1, a as kanunSessionPlugin, i as arkstackHttpPlugin, j as old, t as redirect, z as Request$1 } from "./redirect-g4KUj_g-.js";
2
2
  import { CoreRouter } from "clear-router";
3
3
  import { Validator } from "kanun";
4
4
  import { dirname, join } from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/http",
3
- "version": "0.17.16",
3
+ "version": "0.17.17",
4
4
  "type": "module",
5
5
  "description": "HTTP module for Arkstack, providing framework-agnostic request and response primitives.",
6
6
  "homepage": "https://arkstack.toneflix.net/guide/http",
@@ -29,13 +29,13 @@
29
29
  "./package.json": "./package.json"
30
30
  },
31
31
  "dependencies": {
32
- "clear-router": "^2.9.2",
32
+ "clear-router": "^2.9.3",
33
33
  "dotenv": "^17.4.2",
34
- "@arkstack/contract": "^0.17.16",
35
- "@arkstack/common": "^0.17.16"
34
+ "@arkstack/contract": "^0.17.17",
35
+ "@arkstack/common": "^0.17.17"
36
36
  },
37
37
  "peerDependencies": {
38
- "arkormx": "^2.12.0",
38
+ "arkormx": "^2.12.8",
39
39
  "kanun": "^1.2.0"
40
40
  },
41
41
  "peerDependenciesMeta": {