@arkstack/http 0.12.9 → 0.12.11
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,7 @@
|
|
|
1
1
|
import * as _$clear_router0 from "clear-router";
|
|
2
|
-
import { Request, Response } from "clear-router";
|
|
2
|
+
import { ClearHttpContext, Request, Response } from "clear-router";
|
|
3
3
|
import * as _$kanun from "kanun";
|
|
4
|
-
import { RequestData } from "clear-router/types/basic";
|
|
4
|
+
import { MiddlewareClass, MiddlewareInstance, RequestData } from "clear-router/types/basic";
|
|
5
5
|
|
|
6
6
|
//#region src/Response.d.ts
|
|
7
7
|
/**
|
|
@@ -302,7 +302,7 @@ declare class Session {
|
|
|
302
302
|
}
|
|
303
303
|
//#endregion
|
|
304
304
|
//#region src/session/plugins.d.ts
|
|
305
|
-
declare const arkstackHttpPlugin: _$clear_router0.ClearRouterPlugin<any,
|
|
305
|
+
declare const arkstackHttpPlugin: _$clear_router0.ClearRouterPlugin<any, ClearHttpContext>;
|
|
306
306
|
declare const kanunSessionPlugin: _$kanun.ValidatorPlugin;
|
|
307
307
|
//#endregion
|
|
308
308
|
//#region src/session/helpers.d.ts
|
|
@@ -396,6 +396,10 @@ declare class FileSessionDriver extends BaseSessionDriver {
|
|
|
396
396
|
type HeaderValue = string | string[] | number | boolean | null | undefined;
|
|
397
397
|
type HeaderMap = Record<string, string>;
|
|
398
398
|
type HeaderSource = Headers | Record<string, HeaderValue>;
|
|
399
|
+
type FunctionMiddleware = (...args: any[]) => any;
|
|
400
|
+
type ClassMiddleware = new (...args: any[]) => {
|
|
401
|
+
handle: FunctionMiddleware;
|
|
402
|
+
};
|
|
399
403
|
type RequestSource<TUser = unknown> = {
|
|
400
404
|
headers?: HeaderSource;
|
|
401
405
|
method?: string;
|
|
@@ -471,6 +475,13 @@ declare const normalizeHeaders: (headers?: HeaderSource) => HeaderMap;
|
|
|
471
475
|
declare const normalizeHeaderValue: (value: HeaderValue) => string | undefined;
|
|
472
476
|
declare const isHeaders: (value: unknown) => value is Headers;
|
|
473
477
|
declare const isRecord: (value: unknown) => value is Record<PropertyKey, any>;
|
|
478
|
+
/**
|
|
479
|
+
* Resolve Middleware
|
|
480
|
+
*
|
|
481
|
+
* @param middleware
|
|
482
|
+
* @returns
|
|
483
|
+
*/
|
|
484
|
+
declare const resolveMiddleware: <T extends FunctionMiddleware | MiddlewareClass | MiddlewareInstance>(middleware: T) => T extends MiddlewareClass<FunctionMiddleware> ? InstanceType<T>["handle"] : T extends MiddlewareInstance ? T["handle"] : T;
|
|
474
485
|
//#endregion
|
|
475
486
|
//#region src/redirect.d.ts
|
|
476
487
|
declare const redirectBackTarget: (fallback?: string) => string;
|
|
@@ -485,4 +496,4 @@ declare const webMiddlewareKey: unique symbol;
|
|
|
485
496
|
declare const web: (...args: any[]) => Promise<any>;
|
|
486
497
|
declare const isWebRequest: (target: unknown) => boolean;
|
|
487
498
|
//#endregion
|
|
488
|
-
export {
|
|
499
|
+
export { arkstackHttpPlugin as $, CookieSessionDriver as A, generateSessionId as B, RequestHelper as C, SessionHelper as D, ResponseSource as E, encryptSessionValue as F, signValue as G, parseCookies as H, decodeJson as I, getSessionDriver as J, configureSession as K, decodeSignedValue as L, decodeSessionPayload as M, encodeSessionPayload as N, FileSessionDriver as O, decryptSessionValue as P, registerResponseFlashSweep as Q, encodeJson as R, RedirectHelper as S, RequestSource as T, serializeCookie as U, getCookie as V, setCookie as W, ensureSession as X, attachViewState as Y, getSession as Z, FunctionMiddleware as _, cookie_options as _t, redirect as a, HttpContextLike as at, HeaderValue as b, isHeaders as c, SessionDriver as ct, normalizeHeaderValue as d, SessionErrorRecord as dt, kanunSessionPlugin as et, normalizeHeaders as f, SessionErrorSource as ft, ClassMiddleware as g, SessionPayload as gt, Request$1 as h, SessionMessageProvider as ht, old as i, DatabaseSessionDriverOptions as it, BaseSessionDriver as j, DatabaseSessionDriver as k, isRecord as l, SessionDriverResult as lt, unwrapRequestSource as m, SessionInitialState as mt, web as n, ErrorBag as nt, redirectBackTarget as o, PersistentSessionConfig as ot, resolveMiddleware as p, SessionErrorValue as pt, createSessionDriver as q, webMiddlewareKey as r, BaseSessionDriverOptions as rt, resolveRedirectTarget as s, SessionConfig as st, isWebRequest as t, Session as tt, makeHeaders as u, SessionDriverType as ut, HeaderMap as v, FlashBag as vt, RequestOptions as w, OldHelper as x, HeaderSource as y, Response$1 as yt, encodeSignedValue as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference path="./app.d.ts" />
|
|
2
|
-
import { $ as
|
|
3
|
-
export { BaseSessionDriver, BaseSessionDriverOptions, CookieSessionDriver, DatabaseSessionDriver, DatabaseSessionDriverOptions, ErrorBag, FileSessionDriver, FlashBag, 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, 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, resolveRedirectTarget, serializeCookie, setCookie, signValue, unwrapRequestSource, web, webMiddlewareKey };
|
|
2
|
+
import { $ as arkstackHttpPlugin, A as CookieSessionDriver, B as generateSessionId, C as RequestHelper, D as SessionHelper, E as ResponseSource, F as encryptSessionValue, G as signValue, H as parseCookies, I as decodeJson, J as getSessionDriver, K as configureSession, L as decodeSignedValue, M as decodeSessionPayload, N as encodeSessionPayload, O as FileSessionDriver, P as decryptSessionValue, Q as registerResponseFlashSweep, R as encodeJson, S as RedirectHelper, T as RequestSource, U as serializeCookie, V as getCookie, W as setCookie, X as ensureSession, Y as attachViewState, Z as getSession, _ as FunctionMiddleware, _t as cookie_options, a as redirect, at as HttpContextLike, b as HeaderValue, c as isHeaders, ct as SessionDriver, d as normalizeHeaderValue, dt as SessionErrorRecord, et as kanunSessionPlugin, f as normalizeHeaders, ft as SessionErrorSource, g as ClassMiddleware, gt as SessionPayload, h as Request, ht as SessionMessageProvider, i as old, it as DatabaseSessionDriverOptions, j as BaseSessionDriver, k as DatabaseSessionDriver, l as isRecord, lt as SessionDriverResult, m as unwrapRequestSource, mt as SessionInitialState, n as web, nt as ErrorBag, o as redirectBackTarget, ot as PersistentSessionConfig, p as resolveMiddleware, pt as SessionErrorValue, q as createSessionDriver, r as webMiddlewareKey, rt as BaseSessionDriverOptions, s as resolveRedirectTarget, st as SessionConfig, t as isWebRequest, tt as Session, u as makeHeaders, ut as SessionDriverType, v as HeaderMap, vt as FlashBag, w as RequestOptions, x as OldHelper, y as HeaderSource, yt as Response, z as encodeSignedValue } from "./index-CwN_oKs8.js";
|
|
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, 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, signValue, unwrapRequestSource, web, webMiddlewareKey };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as registerResponseFlashSweep, B as normalizeHeaderValue, C as parseCookies, D as attachViewState, E as signValue, F as Response, H as
|
|
1
|
+
import { A as registerResponseFlashSweep, B as normalizeHeaderValue, C as parseCookies, D as attachViewState, E as signValue, F as Response, H as resolveMiddleware, I as Request, L as isHeaders, M as Session, N as ErrorBag, O as ensureSession, P as FlashBag, R as isRecord, S as getCookie, T as setCookie, U as unwrapRequestSource, V as normalizeHeaders, _ 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, 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 makeHeaders } from "./redirect-Bwrh6IHq.js";
|
|
2
2
|
//#region src/middlewares/web.ts
|
|
3
3
|
const webMiddlewareKey = Symbol.for("arkstack:http:web");
|
|
4
4
|
const markWebRequest = (target) => {
|
|
@@ -45,4 +45,4 @@ const isWebRequest = (target) => {
|
|
|
45
45
|
return target[webMiddlewareKey] === true || target.arkstackWeb === true || isWebRequest(target.context) || isWebRequest(target.req);
|
|
46
46
|
};
|
|
47
47
|
//#endregion
|
|
48
|
-
export { BaseSessionDriver, CookieSessionDriver, DatabaseSessionDriver, ErrorBag, FileSessionDriver, FlashBag, Request, Response, Session, arkstackHttpPlugin, attachViewState, configureSession, 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, resolveRedirectTarget, serializeCookie, setCookie, signValue, unwrapRequestSource, web, webMiddlewareKey };
|
|
48
|
+
export { BaseSessionDriver, CookieSessionDriver, DatabaseSessionDriver, ErrorBag, FileSessionDriver, FlashBag, Request, Response, Session, arkstackHttpPlugin, attachViewState, configureSession, 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, signValue, unwrapRequestSource, web, webMiddlewareKey };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isClass } from "@arkstack/common";
|
|
1
2
|
import { Request, Response } from "clear-router";
|
|
2
3
|
import { definePlugin } from "clear-router/core";
|
|
3
4
|
import { definePlugin as definePlugin$1 } from "kanun";
|
|
@@ -40,6 +41,19 @@ const isHeaders = (value) => typeof Headers !== "undefined" && value instanceof
|
|
|
40
41
|
const isRecord = (value) => {
|
|
41
42
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
42
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Resolve Middleware
|
|
46
|
+
*
|
|
47
|
+
* @param middleware
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
const resolveMiddleware = (middleware) => {
|
|
51
|
+
if (!middleware || typeof middleware === "function" && !isClass(middleware)) return middleware;
|
|
52
|
+
if (middleware && typeof middleware === "object" && !isClass(middleware) && "handle" in middleware) return middleware.handle.bind(middleware);
|
|
53
|
+
const instance = isClass(middleware) ? new middleware() : middleware;
|
|
54
|
+
if (instance && typeof instance.handle === "function") return instance.handle.bind(instance);
|
|
55
|
+
return middleware;
|
|
56
|
+
};
|
|
43
57
|
//#endregion
|
|
44
58
|
//#region src/Request.ts
|
|
45
59
|
/**
|
|
@@ -1241,4 +1255,4 @@ const redirect = (to = "back", status = defaultRedirectStatus) => {
|
|
|
1241
1255
|
return response;
|
|
1242
1256
|
};
|
|
1243
1257
|
//#endregion
|
|
1244
|
-
export { registerResponseFlashSweep as A, normalizeHeaderValue as B, parseCookies as C, attachViewState as D, signValue as E, Response$1 as F,
|
|
1258
|
+
export { registerResponseFlashSweep as A, normalizeHeaderValue as B, parseCookies as C, attachViewState as D, signValue as E, Response$1 as F, resolveMiddleware as H, Request$1 as I, isHeaders as L, Session as M, ErrorBag as N, ensureSession as O, FlashBag as P, isRecord as R, getCookie as S, setCookie as T, unwrapRequestSource as U, normalizeHeaders as V, decodeJson as _, kanunSessionPlugin as a, encodeSignedValue as b, getSessionDriver as c, CookieSessionDriver as d, BaseSessionDriver as f, encodeSessionPayload as g, decodeSessionPayload as h, arkstackHttpPlugin as i, old as j, getSession as k, FileSessionDriver as l, encryptSessionValue as m, redirectBackTarget as n, configureSession as o, decryptSessionValue as p, resolveRedirectTarget as r, createSessionDriver as s, redirect as t, DatabaseSessionDriver as u, decodeSignedValue as v, serializeCookie as w, generateSessionId as x, encodeJson as y, makeHeaders as z };
|
package/dist/setup.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as RequestHelper, D as SessionHelper, S as RedirectHelper, x as OldHelper, yt as Response } from "./index-CwN_oKs8.js";
|
|
2
2
|
//#region src/setup.d.ts
|
|
3
3
|
declare global {
|
|
4
4
|
var session: SessionHelper;
|
package/dist/setup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as Response$1, I as Request$1, a as kanunSessionPlugin, i as arkstackHttpPlugin, j as old, t as redirect } from "./redirect-
|
|
1
|
+
import { F as Response$1, I as Request$1, a as kanunSessionPlugin, i as arkstackHttpPlugin, j as old, t as redirect } from "./redirect-Bwrh6IHq.js";
|
|
2
2
|
import { CoreRouter } from "clear-router";
|
|
3
3
|
import { Validator } from "kanun";
|
|
4
4
|
import "dotenv/config";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/http",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.11",
|
|
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",
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"clear-router": "^2.8.
|
|
31
|
+
"clear-router": "^2.8.6",
|
|
32
32
|
"dotenv": "17.3.1",
|
|
33
|
-
"@arkstack/contract": "^0.12.
|
|
33
|
+
"@arkstack/contract": "^0.12.11",
|
|
34
|
+
"@arkstack/common": "^0.12.11"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
37
|
"arkormx": "^2.4.1",
|