@arkstack/http 0.15.5 → 0.16.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.
|
@@ -377,7 +377,6 @@ declare class CookieSessionDriver extends BaseSessionDriver {
|
|
|
377
377
|
declare class DatabaseSessionDriver extends BaseSessionDriver {
|
|
378
378
|
readonly tableName: string;
|
|
379
379
|
constructor(options?: DatabaseSessionDriverOptions);
|
|
380
|
-
private table;
|
|
381
380
|
start(context: HttpContextLike): Promise<SessionDriverResult>;
|
|
382
381
|
}
|
|
383
382
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference path="./app.d.ts" />
|
|
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-
|
|
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-AYUuBkXH.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, 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 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-
|
|
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-BPQIvVtB.js";
|
|
2
2
|
//#region src/middlewares/web.ts
|
|
3
3
|
const webMiddlewareKey = Symbol.for("arkstack:http:web");
|
|
4
4
|
const markWebRequest = (target) => {
|
|
@@ -2,7 +2,6 @@ import { Request, Response } from "clear-router";
|
|
|
2
2
|
import { definePlugin } from "clear-router/core";
|
|
3
3
|
import { definePlugin as definePlugin$1 } from "kanun";
|
|
4
4
|
import { createCipheriv, createDecipheriv, createHash, createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
5
|
-
import { DB } from "arkormx";
|
|
6
5
|
import { dirname, join } from "node:path";
|
|
7
6
|
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
8
7
|
import { Arkstack } from "@arkstack/contract";
|
|
@@ -1142,13 +1141,12 @@ var DatabaseSessionDriver = class extends BaseSessionDriver {
|
|
|
1142
1141
|
super(options);
|
|
1143
1142
|
this.tableName = options.table || "sessions";
|
|
1144
1143
|
}
|
|
1145
|
-
table() {
|
|
1146
|
-
return DB.table(this.tableName);
|
|
1147
|
-
}
|
|
1148
1144
|
async start(context) {
|
|
1145
|
+
const { DB } = await import("arkormx");
|
|
1146
|
+
const table = () => DB.table(this.tableName);
|
|
1149
1147
|
const id = this.readSessionId(context) || generateSessionId();
|
|
1150
1148
|
this.writeSessionId(context, id);
|
|
1151
|
-
const row = await
|
|
1149
|
+
const row = await table().where({ id }).first();
|
|
1152
1150
|
const state = isRecord(row) && typeof row.payload === "string" ? decodeSessionPayload(this.decryptPayload(row.payload) ?? row.payload) ?? decodeJson(this.decryptPayload(row.payload) ?? row.payload) : isRecord(row?.payload) ? row.payload : void 0;
|
|
1153
1151
|
const save = async (payload) => {
|
|
1154
1152
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -1158,15 +1156,15 @@ var DatabaseSessionDriver = class extends BaseSessionDriver {
|
|
|
1158
1156
|
updatedAt: now,
|
|
1159
1157
|
expiresAt: this.ttl ? new Date(now.getTime() + this.ttl * 1e3) : null
|
|
1160
1158
|
};
|
|
1161
|
-
if (await
|
|
1162
|
-
else await
|
|
1159
|
+
if (await table().where({ id }).first()) await table().where({ id }).update(values);
|
|
1160
|
+
else await table().insert({
|
|
1163
1161
|
...values,
|
|
1164
1162
|
createdAt: now
|
|
1165
1163
|
});
|
|
1166
1164
|
this.writeSessionId(context, id);
|
|
1167
1165
|
};
|
|
1168
1166
|
const destroy = async () => {
|
|
1169
|
-
await
|
|
1167
|
+
await table().where({ id }).delete();
|
|
1170
1168
|
setCookie(context, this.cookie, "", {
|
|
1171
1169
|
...this.cookie_options,
|
|
1172
1170
|
maxAge: 0,
|
package/dist/setup.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as RequestHelper, D as SessionHelper, S as RedirectHelper, x as OldHelper, yt as Response } from "./index-
|
|
1
|
+
import { C as RequestHelper, D as SessionHelper, S as RedirectHelper, x as OldHelper, yt as Response } from "./index-AYUuBkXH.js";
|
|
2
2
|
import { User } from "@app/models/User";
|
|
3
3
|
|
|
4
4
|
//#region src/setup.d.ts
|
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-BPQIvVtB.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.
|
|
3
|
+
"version": "0.16.0",
|
|
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",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"clear-router": "^2.9.0",
|
|
32
32
|
"dotenv": "^17.4.2",
|
|
33
|
-
"@arkstack/contract": "^0.
|
|
34
|
-
"@arkstack/common": "^0.
|
|
33
|
+
"@arkstack/contract": "^0.16.0",
|
|
34
|
+
"@arkstack/common": "^0.16.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"arkormx": "^2.10.1",
|