insite-cookie 2.5.0 → 2.5.1
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/server/Middleware.d.ts.map +1 -1
- package/dist/server/Setter.d.ts +11 -2
- package/dist/server/Setter.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +3 -3
- package/dist/server/tokenMap.d.ts +7 -1
- package/dist/server/tokenMap.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Middleware.d.ts","sourceRoot":"","sources":["../../src/server/Middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAuB,MAAM,aAAa,CAAC;AAEnE,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGrD,KAAK,OAAO,GAAG;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,YAAY,EAAE,OAAO,IAAI,uBAAuB,EAAE,CAAC;AAEnD,KAAK,OAAO,GAAG,aAAa,GAAG;IAC9B,IAAI,EAAE,MAAM,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,MAAM,CAAC,CAAC;CAC5B,CAAC;AAGF,qBAAa,gBAAiB,SAAQ,eAAe;;gBACxC,OAAO,GAAE,OAAY;
|
|
1
|
+
{"version":3,"file":"Middleware.d.ts","sourceRoot":"","sources":["../../src/server/Middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAuB,MAAM,aAAa,CAAC;AAEnE,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGrD,KAAK,OAAO,GAAG;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,YAAY,EAAE,OAAO,IAAI,uBAAuB,EAAE,CAAC;AAEnD,KAAK,OAAO,GAAG,aAAa,GAAG;IAC9B,IAAI,EAAE,MAAM,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,MAAM,CAAC,CAAC;CAC5B,CAAC;AAGF,qBAAa,gBAAiB,SAAQ,eAAe;;gBACxC,OAAO,GAAE,OAAY;IA+BjC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAU,EAAE,MAAa,EAAE,QAAe,EAAE,QAAmB,EAAE,EAAE,OAAO;IA0BhI,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;CAIrD"}
|
package/dist/server/Setter.d.ts
CHANGED
|
@@ -5,15 +5,24 @@ import type { Cookie, CookieOptions } from "./types";
|
|
|
5
5
|
export type Options<AS extends AbilitiesSchema> = {
|
|
6
6
|
usersServer: UsersServer<AS>;
|
|
7
7
|
domain?: string;
|
|
8
|
+
/** Cookie `Max-Age` in seconds. Defaults to the session TTL. */
|
|
8
9
|
maxAge?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Minimum seconds between cookie rewrites.
|
|
12
|
+
* `0` rewrites on every prolonged connect.
|
|
13
|
+
* Defaults to one day, or half of `maxAge` when that is shorter.
|
|
14
|
+
*/
|
|
15
|
+
updateAge?: number;
|
|
9
16
|
};
|
|
10
17
|
export declare class CookieSetter<AS extends AbilitiesSchema> {
|
|
11
18
|
#private;
|
|
12
|
-
constructor({ usersServer, domain, maxAge }: Options<AS>);
|
|
19
|
+
constructor({ usersServer, domain, maxAge, updateAge }: Options<AS>);
|
|
13
20
|
usersServer: UsersServer<AS>;
|
|
14
21
|
domain: string | undefined;
|
|
15
22
|
maxAge: number;
|
|
16
|
-
|
|
23
|
+
/** Seconds. A connect inside this window prolongs the document and leaves the cookie alone. */
|
|
24
|
+
updateAge: number;
|
|
25
|
+
set(wssc: WSSCWithUser<AS>, cookie: Cookie, options: CookieOptions, onSet?: () => void): void;
|
|
17
26
|
unset(wssc: WSSCWithUser<AS>, names: string[]): void;
|
|
18
27
|
static parse: typeof parseCookie;
|
|
19
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Setter.d.ts","sourceRoot":"","sources":["../../src/server/Setter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Setter.d.ts","sourceRoot":"","sources":["../../src/server/Setter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAQrD,MAAM,MAAM,OAAO,CAAC,EAAE,SAAS,eAAe,IAAI;IACjD,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAGF,qBAAa,YAAY,CAAC,EAAE,SAAS,eAAe;;gBACvC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,EAAE,CAAC;IAoBnE,WAAW,kBAAC;IACZ,MAAM,qBAAC;IACP,MAAM,SAAC;IAEP,+FAA+F;IAC/F,SAAS,SAAC;IAEV,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,MAAM,IAAI;IAUtF,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE;IA0E7C,MAAM,CAAC,KAAK,qBAAe;CAE3B"}
|
package/dist/server/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getWithTimeout as
|
|
1
|
+
import{getWithTimeout as g}from"@nesvet/n";import{ClassMiddleware as f}from"insite-http";var a=new Map;var m=class r extends f{constructor(e={}){super();let{path:t="/cookie"}=e;this.listeners={GET:[[t,this.#e]]}}#e=(e,t)=>{let i=e.querystring?g(a,e.querystring):void 0;if(i){let[s,n,p]=i;return p?.(),t.writeHead(200,{"Content-Type":"text/plain; charset=utf-8","Set-Cookie":r.cookify(s,n)}).end()}return!1};static make({name:e,value:t,maxAge:i,expiresAt:s,domain:n,path:p="/",secure:c=!0,httpOnly:k=!0,sameSite:h="Strict"}){let o=[`${e}=${t}`];return i!==void 0?o.push(`Max-Age=${i}`):s&&o.push(`Max-Age=${Math.round((s.getTime()-Date.now())/1e3)}`),n&&o.push(`Domain=${n}`),p&&o.push(`Path=${p}`),c&&o.push("Secure"),k&&o.push("HttpOnly"),h&&o.push(`SameSite=${h}`),o.join("; ")}static cookify(e,t){return Object.entries(e).map(([i,s])=>this.make({name:i,value:s,...t}))}};function d(r){return r?r.split(/;\s*/).reduce((e,t)=>{let[i,s]=t.split(/=/);try{e[i]=JSON.parse(s)}catch{e[i]=s}return e},{}):{}}import C from"node:crypto";import{random as A,setWithTimeout as y}from"@nesvet/n";var u={set:"~setcookie"};var S=2e3,x=86400,l=class{constructor({usersServer:e,domain:t,maxAge:i,updateAge:s}){this.usersServer=e,this.domain=t??process.env.INSITE_HOST,this.maxAge=i??this.usersServer.users.sessions.collection.expireAfterSeconds,this.updateAge=s??Math.min(x,Math.floor(this.maxAge/2)),this.usersServer.wss.on("client-connect",this.#o),this.usersServer.wss.on("client-session",this.#n),this.usersServer.users.on("session-delete",this.#r)}#e=new WeakMap;#t=new Map;#i=new Set;usersServer;domain;maxAge;updateAge;set(e,t,i,s){let n=`${Math.round(performance.now()*Number.MAX_SAFE_INTEGER).toString(36)}$${C.randomBytes(A(4,8)).toString("hex")}`;y(a,n,[t,i,s],S),e.sendMessage(u.set,n)}unset(e,t){this.set(e,t.reduce((i,s)=>(i[s]="",i),{}),{domain:this.domain,maxAge:0})}#o=(e,t)=>{if(this.#e.set(e,null),t.headers.cookie){let{sessionId:i=null}=d(t.headers.cookie);this.#e.set(e,i),i&&this.usersServer.setSession(e,i,!0)}};#n=(e,t)=>{let i=e.session?._id??null;this.#e.get(e)!==i?(this.#e.set(e,i),e.isOpen&&e.session?this.#s(e):this.unset(e,["sessionId"])):t&&e.isOpen&&e.session&&this.#p(e.session)&&this.#s(e)};#r=e=>{this.#t.delete(e._id),this.#i.delete(e._id)};#s(e){let{session:t}=e;if(!t||this.#i.has(t._id))return;this.#i.add(t._id);let i=setTimeout(()=>{this.#i.delete(t._id),this.#t.has(t._id)||this.#t.set(t._id,0)},S);this.set(e,{sessionId:t._id},{domain:this.domain,maxAge:this.maxAge},()=>{clearTimeout(i),this.#i.delete(t._id),this.#t.set(t._id,Date.now())})}#p(e){let t=this.#t.get(e._id)??e.createdAt;return Date.now()-t>=this.updateAge*1e3}static parse=d};export{m as CookieMiddleware,l as CookieSetter,d as parseCookie};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/server/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/server/Middleware.ts", "../../src/server/tokenMap.ts", "../../src/server/parse.ts", "../../src/server/Setter.ts", "../../src/common.ts"],
|
|
4
|
-
"sourcesContent": ["import { getWithTimeout } from \"@nesvet/n\";\nimport { ClassMiddleware, type RequestHandler } from \"insite-http\";\nimport { tokenMap } from \"./tokenMap\";\nimport type { Cookie, CookieOptions } from \"./types\";\n\n\ntype Options = {\n\tpath?: RegExp | string;\n};\n\nexport type { Options as CookieMiddlewareOptions };\n\ntype MakeArg = CookieOptions & {\n\tname: keyof Cookie;\n\tvalue: Cookie[keyof Cookie];\n};\n\n\nexport class CookieMiddleware extends ClassMiddleware {\n\tconstructor(options: Options = {}) {\n\t\tsuper();\n\t\t\n\t\tconst {\n\t\t\tpath = \"/cookie\"\n\t\t} = options;\n\t\t\n\t\tthis.listeners = {\n\t\t\tGET: [ [ path, this.#handler ] ]\n\t\t};\n\t\t\n\t}\n\t\n\t#handler: RequestHandler = (request, response) => {\n\t\tconst
|
|
5
|
-
"mappings": "AAAA,OAAS,kBAAAA,MAAsB,YAC/B,OAAS,mBAAAC,MAA4C,
|
|
6
|
-
"names": ["getWithTimeout", "ClassMiddleware", "tokenMap", "CookieMiddleware", "_CookieMiddleware", "ClassMiddleware", "options", "path", "#handler", "request", "response", "
|
|
4
|
+
"sourcesContent": ["import { getWithTimeout } from \"@nesvet/n\";\nimport { ClassMiddleware, type RequestHandler } from \"insite-http\";\nimport { tokenMap } from \"./tokenMap\";\nimport type { Cookie, CookieOptions } from \"./types\";\n\n\ntype Options = {\n\tpath?: RegExp | string;\n};\n\nexport type { Options as CookieMiddlewareOptions };\n\ntype MakeArg = CookieOptions & {\n\tname: keyof Cookie;\n\tvalue: Cookie[keyof Cookie];\n};\n\n\nexport class CookieMiddleware extends ClassMiddleware {\n\tconstructor(options: Options = {}) {\n\t\tsuper();\n\t\t\n\t\tconst {\n\t\t\tpath = \"/cookie\"\n\t\t} = options;\n\t\t\n\t\tthis.listeners = {\n\t\t\tGET: [ [ path, this.#handler ] ]\n\t\t};\n\t\t\n\t}\n\t\n\t#handler: RequestHandler = (request, response) => {\n\t\tconst pending = request.querystring ? getWithTimeout(tokenMap, request.querystring) : undefined;\n\t\t\n\t\tif (pending) {\n\t\t\tconst [ cookie, options, onSet ] = pending;\n\t\t\t\n\t\t\tonSet?.();\n\t\t\t\n\t\t\treturn response.writeHead(200, {\n\t\t\t\t\"Content-Type\": \"text/plain; charset=utf-8\",\n\t\t\t\t\"Set-Cookie\": CookieMiddleware.cookify(cookie, options)\n\t\t\t}).end();\n\t\t}\n\t\t\n\t\treturn false;\n\t};\n\t\n\t\n\tstatic make({ name, value, maxAge, expiresAt, domain, path = \"/\", secure = true, httpOnly = true, sameSite = \"Strict\" }: MakeArg) {\n\t\tconst cookie = [ `${name}=${value}` ];\n\t\t\n\t\tif (maxAge !== undefined)\n\t\t\tcookie.push(`Max-Age=${maxAge}`);\n\t\telse if (expiresAt)\n\t\t\tcookie.push(`Max-Age=${Math.round((expiresAt.getTime() - Date.now()) / 1000)}`);\n\t\t\n\t\tif (domain)\n\t\t\tcookie.push(`Domain=${domain}`);\n\t\t\n\t\tif (path)\n\t\t\tcookie.push(`Path=${path}`);\n\t\t\n\t\tif (secure)\n\t\t\tcookie.push(\"Secure\");\n\t\t\n\t\tif (httpOnly)\n\t\t\tcookie.push(\"HttpOnly\");\n\t\t\n\t\tif (sameSite)\n\t\t\tcookie.push(`SameSite=${sameSite}`);\n\t\t\n\t\treturn cookie.join(\"; \");\n\t}\n\t\n\tstatic cookify(cookie: Cookie, options: CookieOptions) {\n\t\treturn Object.entries(cookie).map(([ name, value ]) => this.make({ name, value, ...options }));\n\t}\n\t\n}\n", "import type { Cookie, CookieOptions } from \"./types\";\n\n\ntype PendingCookie = [\n\tcookie: Cookie,\n\toptions: CookieOptions,\n\tonSet?: () => void\n];\n\nexport const tokenMap = new Map<string, PendingCookie>();\n", "export function parseCookie(cookie: string) {\n\treturn cookie ? cookie.split(/;\\s*/).reduce((object, keyEqValue) => {\n\t\tconst [ key, value ] = keyEqValue.split(/=/);\n\t\t\n\t\ttry {\n\t\t\tobject[key] = JSON.parse(value);\n\t\t} catch {\n\t\t\tobject[key] = value;\n\t\t}\n\t\t\n\t\treturn object;\n\t}, {} as Record<string, unknown>) : {};\n}\n", "import crypto from \"node:crypto\";\nimport type { IncomingMessage } from \"node:http\";\nimport { random, setWithTimeout } from \"@nesvet/n\";\nimport type { AbilitiesSchema } from \"insite-common\";\nimport type { UsersServer, WSSCWithUser } from \"insite-users-server-ws\";\nimport { headers } from \"../common\";\nimport { parseCookie } from \"./parse\";\nimport { tokenMap } from \"./tokenMap\";\nimport type { Cookie, CookieOptions } from \"./types\";\n\n\nconst cookieTokenTimeout = 2000;\n\n/** Auth.js default: rewrite the session cookie at most once a day. */\nconst defaultUpdateAge = 86_400;\n\nexport type Options<AS extends AbilitiesSchema> = {\n\tusersServer: UsersServer<AS>;\n\tdomain?: string;\n\t/** Cookie `Max-Age` in seconds. Defaults to the session TTL. */\n\tmaxAge?: number;\n\t/**\n\t * Minimum seconds between cookie rewrites.\n\t * `0` rewrites on every prolonged connect.\n\t * Defaults to one day, or half of `maxAge` when that is shorter.\n\t */\n\tupdateAge?: number;\n};\n\n\nexport class CookieSetter<AS extends AbilitiesSchema> {\n\tconstructor({ usersServer, domain, maxAge, updateAge }: Options<AS>) {\n\t\tthis.usersServer = usersServer;\n\t\tthis.domain = domain ?? process.env.INSITE_HOST;\n\t\tthis.maxAge = maxAge ?? this.usersServer.users.sessions.collection.expireAfterSeconds;\n\t\tthis.updateAge = updateAge ?? Math.min(defaultUpdateAge, Math.floor(this.maxAge / 2));\n\t\t\n\t\tthis.usersServer.wss.on(\"client-connect\", this.#handleClientConnect);\n\t\tthis.usersServer.wss.on(\"client-session\", this.#handleClientSession);\n\t\tthis.usersServer.users.on(\"session-delete\", this.#handleSessionDelete);\n\t\t\n\t}\n\t\n\t#wsSessionIdMap = new WeakMap<WSSCWithUser<AS>, string | null>();\n\t\n\t/** When the cookie handoff last completed. Absent entries fall back to `createdAt`. `0` means the last attempt expired. */\n\t#cookieSetAtBySessionId = new Map<string, number>();\n\t\n\t/** Session ids with a cookie token that has not been redeemed or expired yet. */\n\t#cookieWritePending = new Set<string>();\n\t\n\tusersServer;\n\tdomain;\n\tmaxAge;\n\t\n\t/** Seconds. A connect inside this window prolongs the document and leaves the cookie alone. */\n\tupdateAge;\n\t\n\tset(wssc: WSSCWithUser<AS>, cookie: Cookie, options: CookieOptions, onSet?: () => void) {\n\t\t\n\t\tconst token = `${Math.round(performance.now() * Number.MAX_SAFE_INTEGER).toString(36)}$${crypto.randomBytes(random(4, 8)).toString(\"hex\")}`;\n\t\t\n\t\tsetWithTimeout(tokenMap, token, [ cookie, options, onSet ], cookieTokenTimeout);\n\t\t\n\t\twssc.sendMessage(headers.set, token);\n\t\t\n\t}\n\t\n\tunset(wssc: WSSCWithUser<AS>, names: string[]) {\n\t\tthis.set(wssc, names.reduce((cookie, name) => {\n\t\t\tcookie[name] = \"\";\n\t\t\t\n\t\t\treturn cookie;\n\t\t}, {} as Cookie), { domain: this.domain, maxAge: 0 });\n\t\t\n\t}\n\t\n\t#handleClientConnect = (wssc: WSSCWithUser<AS>, request: IncomingMessage) => {\n\t\tthis.#wsSessionIdMap.set(wssc, null);\n\t\t\n\t\tif (request.headers.cookie) {\n\t\t\tconst { sessionId = null } = parseCookie(request.headers.cookie) as { sessionId: string | null };\n\t\t\t\n\t\t\tthis.#wsSessionIdMap.set(wssc, sessionId);\n\t\t\t\n\t\t\tif (sessionId)\n\t\t\t\tthis.usersServer.setSession(wssc, sessionId, true);\n\t\t}\n\t\t\n\t};\n\t\n\t#handleClientSession = (wssc: WSSCWithUser<AS>, shouldProlong?: boolean) => {\n\t\tconst sessionId = wssc.session?._id ?? null;\n\t\t\n\t\tif (this.#wsSessionIdMap.get(wssc) !== sessionId) {\n\t\t\tthis.#wsSessionIdMap.set(wssc, sessionId);\n\t\t\t\n\t\t\tif (wssc.isOpen && wssc.session)\n\t\t\t\tthis.#writeSessionCookie(wssc);\n\t\t\telse\n\t\t\t\tthis.unset(wssc, [ \"sessionId\" ]);\n\t\t} else if (shouldProlong && wssc.isOpen && wssc.session && this.#isCookieStale(wssc.session))\n\t\t\tthis.#writeSessionCookie(wssc);\n\t\t\n\t};\n\t\n\t#handleSessionDelete = (session: { _id: string }) => {\n\t\tthis.#cookieSetAtBySessionId.delete(session._id);\n\t\tthis.#cookieWritePending.delete(session._id);\n\t\t\n\t};\n\t\n\t#writeSessionCookie(wssc: WSSCWithUser<AS>) {\n\t\tconst { session } = wssc;\n\t\t\n\t\tif (!session || this.#cookieWritePending.has(session._id))\n\t\t\treturn;\n\t\t\n\t\tthis.#cookieWritePending.add(session._id);\n\t\t\n\t\tconst pendingTimeout = setTimeout(() => {\n\t\t\tthis.#cookieWritePending.delete(session._id);\n\t\t\t\n\t\t\tif (!this.#cookieSetAtBySessionId.has(session._id))\n\t\t\t\tthis.#cookieSetAtBySessionId.set(session._id, 0);\n\t\t}, cookieTokenTimeout);\n\t\t\n\t\tthis.set(wssc, { sessionId: session._id }, { domain: this.domain, maxAge: this.maxAge }, () => {\n\t\t\tclearTimeout(pendingTimeout);\n\t\t\tthis.#cookieWritePending.delete(session._id);\n\t\t\tthis.#cookieSetAtBySessionId.set(session._id, Date.now());\n\t\t});\n\t\t\n\t}\n\t\n\t#isCookieStale(session: { _id: string; createdAt: number }) {\n\t\tconst setAt = this.#cookieSetAtBySessionId.get(session._id) ?? session.createdAt;\n\t\t\n\t\treturn Date.now() - setAt >= this.updateAge * 1000;\n\t}\n\t\n\t\n\tstatic parse = parseCookie;\n\t\n}\n", "export const headers = {\n\tset: \"~setcookie\"\n};\n\nexport type Method = \"GET\" | \"POST\";\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,kBAAAA,MAAsB,YAC/B,OAAS,mBAAAC,MAA4C,cCQ9C,IAAMC,EAAW,IAAI,IDSrB,IAAMC,EAAN,MAAMC,UAAyBC,CAAgB,CACrD,YAAYC,EAAmB,CAAC,EAAG,CAClC,MAAM,EAEN,GAAM,CACL,KAAAC,EAAO,SACR,EAAID,EAEJ,KAAK,UAAY,CAChB,IAAK,CAAE,CAAEC,EAAM,KAAKC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pB,GAAoB,OAAOmB,EAAQ,GAAG,EAEtC,KAAKpB,GAAwB,IAAIoB,EAAQ,GAAG,GAChD,KAAKpB,GAAwB,IAAIoB,EAAQ,IAAK,CAAC,CACjD,EAAG/B,CAAkB,EAErB,KAAK,IAAIa,EAAM,CAAE,UAAWkB,EAAQ,GAAI,EAAG,CAAE,OAAQ,KAAK,OAAQ,OAAQ,KAAK,MAAO,EAAG,IAAM,CAC9F,aAAaC,CAAc,EAC3B,KAAKpB,GAAoB,OAAOmB,EAAQ,GAAG,EAC3C,KAAKpB,GAAwB,IAAIoB,EAAQ,IAAK,KAAK,IAAI,CAAC,CACzD,CAAC,CAEF,CAEAD,GAAeC,EAA6C,CAC3D,IAAME,EAAQ,KAAKtB,GAAwB,IAAIoB,EAAQ,GAAG,GAAKA,EAAQ,UAEvE,OAAO,KAAK,IAAI,EAAIE,GAAS,KAAK,UAAY,GAC/C,CAGA,OAAO,MAAQN,CAEhB",
|
|
6
|
+
"names": ["getWithTimeout", "ClassMiddleware", "tokenMap", "CookieMiddleware", "_CookieMiddleware", "ClassMiddleware", "options", "path", "#handler", "request", "response", "pending", "getWithTimeout", "tokenMap", "cookie", "onSet", "name", "value", "maxAge", "expiresAt", "domain", "secure", "httpOnly", "sameSite", "parseCookie", "cookie", "object", "keyEqValue", "key", "value", "crypto", "random", "setWithTimeout", "headers", "cookieTokenTimeout", "defaultUpdateAge", "CookieSetter", "usersServer", "domain", "maxAge", "updateAge", "#handleClientConnect", "#handleClientSession", "#handleSessionDelete", "#wsSessionIdMap", "#cookieSetAtBySessionId", "#cookieWritePending", "wssc", "cookie", "options", "onSet", "token", "crypto", "random", "setWithTimeout", "tokenMap", "headers", "names", "name", "request", "sessionId", "parseCookie", "shouldProlong", "#writeSessionCookie", "#isCookieStale", "session", "pendingTimeout", "setAt"]
|
|
7
7
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Cookie, CookieOptions } from "./types";
|
|
2
|
-
|
|
2
|
+
type PendingCookie = [
|
|
3
|
+
cookie: Cookie,
|
|
4
|
+
options: CookieOptions,
|
|
5
|
+
onSet?: () => void
|
|
6
|
+
];
|
|
7
|
+
export declare const tokenMap: Map<string, PendingCookie>;
|
|
8
|
+
export {};
|
|
3
9
|
//# sourceMappingURL=tokenMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenMap.d.ts","sourceRoot":"","sources":["../../src/server/tokenMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGrD,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"tokenMap.d.ts","sourceRoot":"","sources":["../../src/server/tokenMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGrD,KAAK,aAAa,GAAG;IACpB,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,aAAa;IACtB,KAAK,CAAC,EAAE,MAAM,IAAI;CAClB,CAAC;AAEF,eAAO,MAAM,QAAQ,4BAAmC,CAAC"}
|