insite-cookie 2.2.2 → 2.3.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/dist/server/index.js +1 -1
- package/dist/server/index.js.map +4 -4
- package/package.json +42 -42
package/dist/server/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a(){}var S=new WeakMap,d=class r extends Promise{constructor(e,t){let o,n;if(super((i,s)=>{o=i,n=s}),S.set(this,{resolve:o,reject:n}),t?.signal)if(t.signal.aborted)this.reject(new DOMException("Aborted","AbortError"));else{let i=()=>this.reject(new DOMException("Aborted","AbortError"));t.signal.addEventListener("abort",i),this.finally(()=>t.signal?.removeEventListener("abort",i))}if(typeof t?.timeout=="number"&&Number.isFinite(t.timeout)){let i=setTimeout(()=>this.reject(new DOMException("Timeout exceeded","TimeoutError")),t.timeout);this.finally(()=>clearTimeout(i))}e?.(this.resolve,this.reject)}isPending=!0;isFulfilled=!1;isRejected=!1;state="pending";result;resolve=e=>{if(this.isPending){this.isPending=!1,this.isFulfilled=!0,this.state="fulfilled",this.result=e;let t=S.get(this);t&&(t.resolve.call(this,e),S.delete(this))}};reject=e=>{if(this.isPending){this.isPending=!1,this.isRejected=!0,this.state="rejected",this.result=e;let t=S.get(this);t&&(t.reject.call(this,e),S.delete(this))}};static resolved(e){return new r(t=>t(e))}static rejected(e){return new r((t,o)=>o(e))}};function D(r,e=0,t={}){let{leading:o=!1,trailing:n=!0}=t,{maxWait:i=1/0}=t,s,l,x,h,f,g,p,k,A=async()=>{let c=Date.now();c>=x?(s=void 0,x=void 0,clearTimeout(l),l=void 0,typeof p=="function"&&await p(),u.resolve(k),g=o):(clearTimeout(s),s=setTimeout(A,x-c))},v=Number.isFinite(i)?()=>{p===m&&(p=!1),m(),l=setTimeout(v,i)}:null;async function m(){try{return k=await r.apply(h,f),k}catch(c){throw u.reject(c),c}}o&&typeof o=="boolean"&&(o=m),g=o,n&&typeof n=="boolean"&&(n=m),p=n;let u=Object.assign(function(...c){return f=c,h=this,x=Date.now()+e,p=n,u.promise.isPending||(u.promise=new d((P,R)=>{u.resolve=P,u.reject=R,typeof g=="function"&&(g(),g=!1,p===m&&(p=!1)),s||(s=setTimeout(A,e),v&&(l=setTimeout(v,i)))})),u.promise},{callback:r,promise:d.resolved(void 0),resolve:a,reject:a,run:m,clear:async c=>{clearTimeout(s),s=void 0,clearTimeout(l),l=void 0,u.resolve(c?await m():k)}});return u}D.noop=Object.assign(()=>{},{callback:a,promise:d.resolved(void 0),resolve:a,reject:a,run:a,clear:a});var O=new Map;function T(r,e){r.delete(e);let t=O.get(r);if(t){let o=t.get(e);o&&(clearTimeout(o),t.delete(e)),t.size||O.delete(r)}}function w(r,e,t){let o=setTimeout(()=>T(r,e),t);O.get(r)?.set(e,o)??O.set(r,new Map([[e,o]]))}function b(r,e){let t=r.get(e);return T(r,e),t}function j(r,e,t,o,n=!0){return Array.isArray(r)&&(r=r.length),typeof o!="string"&&(n=o??!0,o=t),(n?`${r}\xA0`:"")+j.raw(r,e,t,o)}j.raw=(r,e,t,o=t)=>{r=Math.abs(r);let n=r%10,i=r%100;return n===1&&i!==11?e:n>=2&&n<=4&&!(i>=12&&i<=15)?t:o};function $(r,e){return Math.floor(Math.random()*(e-r+1)+r)}function C(r,e,t,o){return w(r,e,o),r.set(e,t)}import{ClassMiddleware as B}from"insite-http";var y=new Map;var E=class r extends B{constructor(e={}){super();let{path:t="/cookie"}=e;this.listeners={GET:[[t,this.#e]]}}#e=(e,t)=>{let o=e.querystring;return o&&y.has(o)?t.writeHead(200,{"Content-Type":"text/plain; charset=utf-8","Set-Cookie":r.cookify(...b(y,o))}).end():!1};static make({name:e,value:t,maxAge:o,expiresAt:n,domain:i,path:s="/",secure:l=!0,httpOnly:x=!0,sameSite:h="Strict"}){let f=[`${e}=${t}`];return o!==void 0?f.push(`Max-Age=${o}`):n&&f.push(`Max-Age=${Math.round((n.getTime()-Date.now())/1e3)}`),i&&f.push(`Domain=${i}`),s&&f.push(`Path=${s}`),l&&f.push("Secure"),x&&f.push("HttpOnly"),h&&f.push(`SameSite=${h}`),f.join("; ")}static cookify(e,t){return Object.entries(e).map(([o,n])=>this.make({name:o,value:n,...t}))}};function M(r){return r?r.split(/;\s*/).reduce((e,t)=>{let[o,n]=t.split(/=/);try{e[o]=JSON.parse(n)}catch{e[o]=n}return e},{}):{}}import N from"node:crypto";var I={set:"~setcookie"};var _=2e3,W=class{constructor({usersServer:e,domain:t,maxAge:o}){this.usersServer=e,this.domain=t??process.env.INSITE_HOST,this.maxAge=o??this.usersServer.users.sessions.collection.expireAfterSeconds,this.usersServer.wss.on("client-connect",this.#t),this.usersServer.wss.on("client-session",this.#o)}#e=new WeakMap;usersServer;domain;maxAge;set(e,t,o){let n=`${Math.round(performance.now()*Number.MAX_SAFE_INTEGER).toString(36)}$${N.randomBytes($(4,8)).toString("hex")}`;C(y,n,[t,o],_),e.sendMessage(I.set,n)}unset(e,t){this.set(e,t.reduce((o,n)=>(o[n]="",o),{}),{maxAge:0})}#t=(e,t)=>{if(this.#e.set(e,null),t.headers.cookie){let{sessionId:o=null}=M(t.headers.cookie);this.#e.set(e,o),o&&this.usersServer.setSession(e,o,!0)}};#o=e=>{this.#e.get(e)!==e.session?._id&&(this.#e.set(e,e.session?._id??null),e.isOpen&&e.session?this.set(e,{sessionId:e.session._id},{domain:this.domain,maxAge:this.maxAge}):this.unset(e,["sessionId"]))};static parse=M};export{E as CookieMiddleware,W as CookieSetter,M 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
|
-
"sources": ["../../../../../@nesvet/npm/n/src/noop.ts", "../../../../../@nesvet/npm/n/src/debounce.ts", "../../../../../@nesvet/npm/n/src/timeouts.ts", "../../../../../@nesvet/npm/n/src/getWithTimeout.ts", "../../../../../@nesvet/npm/n/src/howmuch.ts", "../../../../../@nesvet/npm/n/src/random.ts", "../../../../../@nesvet/npm/n/src/setWithTimeout.ts", "../../src/server/Middleware.ts", "../../src/server/tokenMap.ts", "../../src/server/parse.ts", "../../src/server/Setter.ts", "../../src/common.ts"],
|
|
4
|
-
"sourcesContent": ["export function noop() { /**/ }\n", "import { noop } from \"./noop.js\";\n\n\ntype Callback<Result> = (...args: unknown[]) => Result;\ntype FunctionOrBoolean = (() => unknown) | boolean;\ntype Options = { leading?: FunctionOrBoolean; maxWait?: number; trailing?: FunctionOrBoolean };\ntype NumberOrUndefined = number | undefined;\n\ntype DebouncedFunction<Result> = {\n\t(this: unknown, ..._args: unknown[]): Promise<Result>;\n};\n\nexport type Debounced<Result> = {\n\tcallback: Callback<Result>;\n\tpromise: {\n\t\tisResolved: boolean;\n\t} & Promise<unknown>;\n\tresolve: (value: Result) => void;\n\trun(): Promise<Result>;\n\tclear(shouldRun?: boolean): Promise<void>;\n} & DebouncedFunction<Result>;\n\n\nexport function debounce<Result>(callback: Callback<Result>, limit = 0, options: Options = {}) {\n\tlet { leading = false, trailing = true } = options;\n\tconst { maxWait = Infinity } = options;\n\t\n\tlet timeout: NumberOrUndefined;\n\tlet maxWaitTimeout: NumberOrUndefined;\n\tlet end: NumberOrUndefined;\n\tlet context: unknown;\n\tlet args: unknown[];\n\tlet initial: FunctionOrBoolean;\n\tlet final: FunctionOrBoolean;\n\tlet result: Result;\n\t\n\tconst expired = async () => {\n\t\t\n\t\tconst n = Date.now();\n\t\t\n\t\tif (n >= end!) {\n\t\t\ttimeout = undefined;\n\t\t\tend = undefined;\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tif (typeof final == \"function\")\n\t\t\t\tawait final();\n\t\t\tdebounced.resolve(result);\n\t\t\tdebounced.promise.isResolved = true;\n\t\t\tinitial = leading;\n\t\t} else {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = setTimeout(expired, end! - n);\n\t\t}\n\t\t\n\t};\n\t\n\tconst maxWaitExpired = Number.isFinite(maxWait) ? () => {\n\t\t\n\t\tif (final === run)\n\t\t\tfinal = false;\n\t\trun();\n\t\tmaxWaitTimeout = setTimeout(maxWaitExpired as TimerHandler, maxWait);\n\t\t\n\t} : null;\n\t\n\tasync function run() {\n\t\treturn (result = await callback.apply(context, args));\n\t}\n\t\n\tif (leading && typeof leading == \"boolean\")\n\t\tleading = run;\n\tinitial = leading;\n\t\n\tif (trailing && typeof trailing == \"boolean\")\n\t\ttrailing = run;\n\tfinal = trailing;\n\t\n\tconst debounced: Debounced<Result> = Object.assign(function (..._args) {\n\t\targs = _args;\n\t\tcontext = this;// eslint-disable-line no-invalid-this\n\t\t\n\t\tend = Date.now() + limit;\n\t\tfinal = trailing;\n\t\t\n\t\tif (debounced.promise.isResolved)\n\t\t\tdebounced.promise = Object.assign(new Promise(resolve => {\n\t\t\t\tdebounced.resolve = resolve;\n\t\t\t\t\n\t\t\t\tif (typeof initial == \"function\") {\n\t\t\t\t\tinitial();\n\t\t\t\t\tinitial = false;\n\t\t\t\t\tif (final === run)\n\t\t\t\t\t\tfinal = false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!timeout) {\n\t\t\t\t\ttimeout = setTimeout(expired, limit);\n\t\t\t\t\tif (maxWaitExpired)\n\t\t\t\t\t\tmaxWaitTimeout = setTimeout(maxWaitExpired, maxWait);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}), {\n\t\t\t\tisResolved: false\n\t\t\t});\n\t\t\n\t\treturn debounced.promise;\n\t} as DebouncedFunction<Result>, {\n\t\tcallback,\n\t\tpromise: Object.assign(Promise.resolve(), {\n\t\t\tisResolved: true\n\t\t}),\n\t\tresolve: noop,\n\t\trun,\n\t\tclear: async (shouldRun?: boolean) => {\n\t\t\t\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\t\n\t\t\tdebounced.promise.isResolved = true;\n\t\t\tdebounced.resolve(shouldRun ? await run() : result);\n\t\t\t\n\t\t}\n\t});\n\t\n\treturn debounced;\n}\n\n\ndebounce.noop = Object.assign(() => { /**/ }, {\n\tcallback: noop,\n\tpromise: Object.assign(Promise.resolve(), {\n\t\tisResolved: true\n\t}),\n\tresolve: noop,\n\trun: noop,\n\tclear: noop\n}) as unknown as Debounced<void>;\n\n\nexport function throttle<Result>(callback: Callback<Result>, limit?: number, options?: Options) {\n\treturn debounce(callback, limit, {\n\t\tmaxWait: limit,\n\t\tleading: true,\n\t\ttrailing: true,\n\t\t...options\n\t});\n}\n", "const timeoutsMapMap: Map<Map<any, any>, Map<any, number>> = new Map();// eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport function cleanup<K, V>(map: Map<K, V>, key: K) {\n\tmap.delete(key);\n\t\n\tconst timeoutsMap = timeoutsMapMap.get(map);\n\tif (timeoutsMap) {\n\t\t\n\t\tconst timeout = timeoutsMap.get(key);\n\t\tif (timeout) {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeoutsMap.delete(key);\n\t\t}\n\t\t\n\t\tif (!timeoutsMap.size)\n\t\t\ttimeoutsMapMap.delete(map);\n\t}\n\t\n}\n\nexport function setup<K, V>(map: Map<K, V>, key: K, ms: number) {\n\tconst timeout = setTimeout(() => cleanup(map, key), ms);\n\t\n\ttimeoutsMapMap.get(map)?.set(key, timeout) ??\n\ttimeoutsMapMap.set(map, new Map([ [ key, timeout ] ]));\n\t\n}\n", "import { cleanup } from \"./timeouts.js\";\n\n\nexport function getWithTimeout<K, V>(map: Map<K, V>, key: K) {\n\tconst value = map.get(key);\n\t\n\tcleanup(map, key);\n\t\n\treturn value;\n}\n", "export function howmuch(number: [] | number, one: string, two: string, five: boolean | string, shouldPrintNumber = true) {\n\tif (Array.isArray(number))\n\t\tnumber = number.length;\n\t\n\tif (typeof five != \"string\") {\n\t\tshouldPrintNumber = five ?? true;\n\t\tfive = two;\n\t}\n\t\n\t\n\treturn (shouldPrintNumber ? `${number}\u00A0` : \"\") + howmuch.raw(number, one, two, five);\n}\n\nhowmuch.raw = (number: number, one: string, two: string, five = two) => {\n\tnumber = Math.abs(number);\n\tconst u = number % 10;\n\tconst d = number % 100;\n\t\n\treturn (\n\t\t(u === 1 && d !== 11) ?\n\t\t\tone :\n\t\t\t((u >= 2 && u <= 4) && !(d >= 12 && d <= 15)) ?\n\t\t\t\ttwo :\n\t\t\t\tfive\n\t);\n};\n", "export function random(from: number, to: number) {\n\treturn Math.floor(Math.random() * (to - from + 1) + from);\n}\n", "import { setup } from \"./timeouts.js\";\n\n\nexport function setWithTimeout<K, V>(map: Map<K, V>, key: K, value: V, ms: number) {\n\tsetup(map, key, ms);\n\t\n\treturn map.set(key, value);\n}\n", "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 token = request.querystring;\n\t\t\n\t\tif (token && tokenMap.has(token))\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(...getWithTimeout(tokenMap, token)!)\n\t\t\t}).end();\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\nexport const tokenMap = new Map<string, [ cookie: Cookie, options: CookieOptions ]>();\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\nexport type Options<AS extends AbilitiesSchema> = {\n\tusersServer: UsersServer<AS>;\n\tdomain?: string;\n\tmaxAge?: number;\n};\n\n\nexport class CookieSetter<AS extends AbilitiesSchema> {\n\tconstructor({ usersServer, domain, maxAge }: 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\t\n\t\tthis.usersServer.wss.on(\"client-connect\", this.#handleClientConnect);\n\t\tthis.usersServer.wss.on(\"client-session\", this.#handleClientSession);\n\t\t\n\t}\n\t\n\t#wsSessionIdMap = new WeakMap<WSSCWithUser<AS>, null | string>();\n\t\n\tusersServer;\n\tdomain;\n\tmaxAge;\n\t\n\tset(wssc: WSSCWithUser<AS>, cookie: Cookie, options: CookieOptions) {\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 ], 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), { 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: null | string };\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>) => {\n\t\tif (this.#wsSessionIdMap.get(wssc) !== wssc.session?._id) {\n\t\t\tthis.#wsSessionIdMap.set(wssc, wssc.session?._id ?? null);\n\t\t\t\n\t\t\tif (wssc.isOpen && wssc.session)\n\t\t\t\tthis.set(wssc, { sessionId: wssc.session._id }, { domain: this.domain, maxAge: this.maxAge });\n\t\t\telse\n\t\t\t\tthis.unset(wssc, [ \"sessionId\" ]);\n\t\t}\n\t\t\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": "AAAM,SAAUA,GAAI,CAAU,
|
|
6
|
-
"names": ["noop", "debounce", "callback", "limit", "options", "leading", "trailing", "maxWait", "timeout", "maxWaitTimeout", "end", "context", "args", "initial", "final", "result", "expired", "n", "debounced", "maxWaitExpired", "run", "_args", "resolve", "noop", "shouldRun", "timeoutsMapMap", "cleanup", "map", "key", "timeoutsMap", "timeout", "setup", "ms", "getWithTimeout", "map", "key", "value", "cleanup", "howmuch", "number", "one", "two", "five", "shouldPrintNumber", "u", "d", "random", "from", "to", "setWithTimeout", "map", "key", "value", "ms", "setup", "ClassMiddleware", "tokenMap", "CookieMiddleware", "_CookieMiddleware", "ClassMiddleware", "options", "path", "#handler", "request", "response", "token", "tokenMap", "getWithTimeout", "name", "value", "maxAge", "expiresAt", "domain", "secure", "httpOnly", "sameSite", "cookie", "parseCookie", "cookie", "object", "keyEqValue", "key", "value", "crypto", "headers", "cookieTokenTimeout", "CookieSetter", "usersServer", "domain", "maxAge", "#handleClientConnect", "#handleClientSession", "#wsSessionIdMap", "wssc", "cookie", "options", "token", "crypto", "random", "setWithTimeout", "tokenMap", "headers", "names", "name", "request", "sessionId", "parseCookie"]
|
|
3
|
+
"sources": ["../../../../../@nesvet/npm/n/src/noop.ts", "../../../../../@nesvet/npm/n/src/StatefulPromise.ts", "../../../../../@nesvet/npm/n/src/debounce.ts", "../../../../../@nesvet/npm/n/src/timeouts.ts", "../../../../../@nesvet/npm/n/src/getWithTimeout.ts", "../../../../../@nesvet/npm/n/src/howmuch.ts", "../../../../../@nesvet/npm/n/src/random.ts", "../../../../../@nesvet/npm/n/src/setWithTimeout.ts", "../../src/server/Middleware.ts", "../../src/server/tokenMap.ts", "../../src/server/parse.ts", "../../src/server/Setter.ts", "../../src/common.ts"],
|
|
4
|
+
"sourcesContent": ["export function noop() { /**/ }\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype Value<T> = PromiseLike<T> | T;\ntype Resolve<T> = (value: Value<T>) => void;\ntype Reject = (reason?: any) => void;\n\ntype Options = {\n\tsignal?: AbortSignal;\n\ttimeout?: number;\n};\n\nconst nativesMap = new WeakMap<StatefulPromise<any>, { resolve: Resolve<any>; reject: Reject }>();\n\n\nexport class StatefulPromise<T> extends Promise<T> {\n\tconstructor(\n\t\texecutor?: (resolve: Resolve<T>, reject: Reject) => void,\n\t\toptions?: Options\n\t) {\n\t\tlet nativeResolve: Resolve<T>;\n\t\tlet nativeReject: Reject;\n\t\t\n\t\tsuper((resolve, reject) => {\n\t\t\tnativeResolve = resolve;\n\t\t\tnativeReject = reject;\n\t\t\t\n\t\t});\n\t\t\n\t\tnativesMap.set(this, { resolve: nativeResolve!, reject: nativeReject! });\n\t\t\n\t\tif (options?.signal)\n\t\t\tif (options.signal.aborted)\n\t\t\t\tthis.reject(new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\telse {\n\t\t\t\tconst abortListener = () => this.reject(new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\t\t\n\t\t\t\toptions.signal.addEventListener(\"abort\", abortListener);\n\t\t\t\t\n\t\t\t\tthis.finally(() => options.signal?.removeEventListener(\"abort\", abortListener));\n\t\t\t}\n\t\t\n\t\tif (typeof options?.timeout === \"number\" && Number.isFinite(options.timeout)) {\n\t\t\tconst timeout = setTimeout(() => this.reject(new DOMException(\"Timeout exceeded\", \"TimeoutError\")), options.timeout);\n\t\t\t\n\t\t\tthis.finally(() => clearTimeout(timeout));\n\t\t}\n\t\t\n\t\texecutor?.(this.resolve, this.reject);\n\t\t\n\t}\n\t\n\tisPending = true;\n\tisFulfilled = false;\n\tisRejected = false;\n\t\n\tstate: \"fulfilled\" | \"pending\" | \"rejected\" = \"pending\";\n\t\n\tresult?: T | unknown;\n\t\n\treadonly resolve = (value: Value<T>) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isFulfilled = true;\n\t\t\tthis.state = \"fulfilled\";\n\t\t\tthis.result = value;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.resolve.call(this, value);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\treadonly reject = (reason?: any) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isRejected = true;\n\t\t\tthis.state = \"rejected\";\n\t\t\tthis.result = reason;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.reject.call(this, reason);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\t\n\tstatic resolved<U>(value: U): StatefulPromise<U> {\n\t\treturn new StatefulPromise<U>(resolve => resolve(value));\n\t}\n\t\n\tstatic rejected(reason: unknown): StatefulPromise<never> {\n\t\treturn new StatefulPromise((_, reject) => reject(reason));\n\t}\n\t\n}\n", "import { noop } from \"./noop.js\";\nimport { StatefulPromise } from \"./StatefulPromise.js\";\n\n\ntype Callback = (...args: any[]) => unknown;// eslint-disable-line @typescript-eslint/no-explicit-any\ntype FunctionOrBoolean = (() => unknown) | boolean;\ntype Options = { leading?: FunctionOrBoolean; maxWait?: number; trailing?: FunctionOrBoolean };\n\ntype DebouncedFunction<C extends Callback> = {\n\t(this: ThisParameterType<C>, ...args: Parameters<C>): Promise<Awaited<ReturnType<C>>>;\n};\n\nexport type Debounced<C extends Callback, R extends ReturnType<C>> = DebouncedFunction<C> & {\n\tcallback: C;\n\tpromise: StatefulPromise<R>;\n\tresolve: (value: R) => void;\n\treject: (reason?: unknown) => void;\n\trun(): Promise<R>;\n\tclear(shouldRun?: boolean): Promise<void>;\n};\n\n\nexport function debounce<C extends Callback, R extends ReturnType<C>>(callback: C, limit = 0, options: Options = {}) {\n\tlet { leading = false, trailing = true } = options;\n\tconst { maxWait = Infinity } = options;\n\t\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tlet maxWaitTimeout: ReturnType<typeof setTimeout> | undefined;\n\tlet end: number | undefined;\n\tlet context: ThisParameterType<C>;\n\tlet args: unknown[];\n\tlet initial: FunctionOrBoolean;\n\tlet final: FunctionOrBoolean;\n\tlet result: R;\n\t\n\tconst expired = async () => {\n\t\t\n\t\tconst n = Date.now();\n\t\t\n\t\tif (n >= end!) {\n\t\t\ttimeout = undefined;\n\t\t\tend = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tmaxWaitTimeout = undefined;\n\t\t\t\n\t\t\tif (typeof final == \"function\")\n\t\t\t\tawait final();\n\t\t\t\n\t\t\tdebounced.resolve(result);\n\t\t\t\n\t\t\tinitial = leading;\n\t\t} else {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = setTimeout(expired, end! - n);\n\t\t}\n\t\t\n\t};\n\t\n\tconst maxWaitExpired = Number.isFinite(maxWait) ? () => {\n\t\t\n\t\tif (final === run)\n\t\t\tfinal = false;\n\t\t\n\t\trun();\n\t\t\n\t\tmaxWaitTimeout = setTimeout(maxWaitExpired as TimerHandler, maxWait);\n\t\t\n\t} : null;\n\t\n\tasync function run() {\n\t\ttry {\n\t\t\tresult = await callback.apply(context, args) as R;\n\t\t\t\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tdebounced.reject(error);\n\t\t\t\n\t\t\tthrow error;\n\t\t}\n\t}\n\t\n\tif (leading && typeof leading == \"boolean\")\n\t\tleading = run;\n\tinitial = leading;\n\t\n\tif (trailing && typeof trailing == \"boolean\")\n\t\ttrailing = run;\n\tfinal = trailing;\n\t\n\tconst debounced: Debounced<C, R> = Object.assign(function (..._args) {\n\t\targs = _args;\n\t\tcontext = this;// eslint-disable-line no-invalid-this\n\t\t\n\t\tend = Date.now() + limit;\n\t\tfinal = trailing;\n\t\t\n\t\tif (!debounced.promise.isPending)\n\t\t\tdebounced.promise = new StatefulPromise<R>((resolve, reject) => {\n\t\t\t\tdebounced.resolve = resolve;\n\t\t\t\tdebounced.reject = reject;\n\t\t\t\t\n\t\t\t\tif (typeof initial == \"function\") {\n\t\t\t\t\tinitial();\n\t\t\t\t\t\n\t\t\t\t\tinitial = false;\n\t\t\t\t\t\n\t\t\t\t\tif (final === run)\n\t\t\t\t\t\tfinal = false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!timeout) {\n\t\t\t\t\ttimeout = setTimeout(expired, limit);\n\t\t\t\t\t\n\t\t\t\t\tif (maxWaitExpired)\n\t\t\t\t\t\tmaxWaitTimeout = setTimeout(maxWaitExpired, maxWait);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\n\t\treturn debounced.promise;\n\t} as DebouncedFunction<C>, {\n\t\tcallback,\n\t\tpromise: StatefulPromise.resolved(undefined as unknown as R),\n\t\tresolve: noop,\n\t\treject: noop,\n\t\trun,\n\t\tclear: async (shouldRun?: boolean) => {\n\t\t\t\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tmaxWaitTimeout = undefined;\n\t\t\t\n\t\t\tdebounced.resolve(shouldRun ? await run() : result);\n\t\t\t\n\t\t}\n\t});\n\t\n\treturn debounced;\n}\n\n\ndebounce.noop = Object.assign(() => { /**/ }, {\n\tcallback: noop,\n\tpromise: StatefulPromise.resolved(undefined), // eslint-disable-line unicorn/no-useless-undefined\n\tresolve: noop,\n\treject: noop,\n\trun: noop,\n\tclear: noop\n}) as Debounced<() => void, void>;\n\n\nexport function throttle(callback: Callback, limit?: number, options?: Options) {\n\treturn debounce(callback, limit, {\n\t\tmaxWait: limit,\n\t\tleading: true,\n\t\ttrailing: true,\n\t\t...options\n\t});\n}\n", "const timeoutsMapMap: Map<Map<any, any>, Map<any, number>> = new Map();// eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport function cleanup<K, V>(map: Map<K, V>, key: K) {\n\tmap.delete(key);\n\t\n\tconst timeoutsMap = timeoutsMapMap.get(map);\n\tif (timeoutsMap) {\n\t\t\n\t\tconst timeout = timeoutsMap.get(key);\n\t\tif (timeout) {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeoutsMap.delete(key);\n\t\t}\n\t\t\n\t\tif (!timeoutsMap.size)\n\t\t\ttimeoutsMapMap.delete(map);\n\t}\n\t\n}\n\nexport function setup<K, V>(map: Map<K, V>, key: K, ms: number) {\n\tconst timeout = setTimeout(() => cleanup(map, key), ms);\n\t\n\ttimeoutsMapMap.get(map)?.set(key, timeout) ??\n\ttimeoutsMapMap.set(map, new Map([ [ key, timeout ] ]));\n\t\n}\n", "import { cleanup } from \"./timeouts.js\";\n\n\nexport function getWithTimeout<K, V>(map: Map<K, V>, key: K) {\n\tconst value = map.get(key);\n\t\n\tcleanup(map, key);\n\t\n\treturn value;\n}\n", "export function howmuch(number: [] | number, one: string, two: string, five: boolean | string, shouldPrintNumber = true) {\n\tif (Array.isArray(number))\n\t\tnumber = number.length;\n\t\n\tif (typeof five != \"string\") {\n\t\tshouldPrintNumber = five ?? true;\n\t\tfive = two;\n\t}\n\t\n\t\n\treturn (shouldPrintNumber ? `${number}\u00A0` : \"\") + howmuch.raw(number, one, two, five);\n}\n\nhowmuch.raw = (number: number, one: string, two: string, five = two) => {\n\tnumber = Math.abs(number);\n\tconst u = number % 10;\n\tconst d = number % 100;\n\t\n\treturn (\n\t\t(u === 1 && d !== 11) ?\n\t\t\tone :\n\t\t\t((u >= 2 && u <= 4) && !(d >= 12 && d <= 15)) ?\n\t\t\t\ttwo :\n\t\t\t\tfive\n\t);\n};\n", "export function random(from: number, to: number) {\n\treturn Math.floor(Math.random() * (to - from + 1) + from);\n}\n", "import { setup } from \"./timeouts.js\";\n\n\nexport function setWithTimeout<K, V>(map: Map<K, V>, key: K, value: V, ms: number) {\n\tsetup(map, key, ms);\n\t\n\treturn map.set(key, value);\n}\n", "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 token = request.querystring;\n\t\t\n\t\tif (token && tokenMap.has(token))\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(...getWithTimeout(tokenMap, token)!)\n\t\t\t}).end();\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\nexport const tokenMap = new Map<string, [ cookie: Cookie, options: CookieOptions ]>();\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\nexport type Options<AS extends AbilitiesSchema> = {\n\tusersServer: UsersServer<AS>;\n\tdomain?: string;\n\tmaxAge?: number;\n};\n\n\nexport class CookieSetter<AS extends AbilitiesSchema> {\n\tconstructor({ usersServer, domain, maxAge }: 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\t\n\t\tthis.usersServer.wss.on(\"client-connect\", this.#handleClientConnect);\n\t\tthis.usersServer.wss.on(\"client-session\", this.#handleClientSession);\n\t\t\n\t}\n\t\n\t#wsSessionIdMap = new WeakMap<WSSCWithUser<AS>, null | string>();\n\t\n\tusersServer;\n\tdomain;\n\tmaxAge;\n\t\n\tset(wssc: WSSCWithUser<AS>, cookie: Cookie, options: CookieOptions) {\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 ], 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), { 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: null | string };\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>) => {\n\t\tif (this.#wsSessionIdMap.get(wssc) !== wssc.session?._id) {\n\t\t\tthis.#wsSessionIdMap.set(wssc, wssc.session?._id ?? null);\n\t\t\t\n\t\t\tif (wssc.isOpen && wssc.session)\n\t\t\t\tthis.set(wssc, { sessionId: wssc.session._id }, { domain: this.domain, maxAge: this.maxAge });\n\t\t\telse\n\t\t\t\tthis.unset(wssc, [ \"sessionId\" ]);\n\t\t}\n\t\t\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": "AAAM,SAAUA,GAAI,CAAU,CCW9B,IAAMC,EAAa,IAAI,QAGVC,EAAP,MAAOC,UAA2B,OAAU,CACjD,YACCC,EACAC,EAAiB,CAEjB,IAAIC,EACAC,EAUJ,GARA,MAAM,CAACC,EAASC,IAAU,CACzBH,EAAgBE,EAChBD,EAAeE,CAEhB,CAAC,EAEDR,EAAW,IAAI,KAAM,CAAE,QAASK,EAAgB,OAAQC,CAAa,CAAE,EAEnEF,GAAS,OACZ,GAAIA,EAAQ,OAAO,QAClB,KAAK,OAAO,IAAI,aAAa,UAAW,YAAY,CAAC,MACjD,CACJ,IAAMK,EAAgB,IAAM,KAAK,OAAO,IAAI,aAAa,UAAW,YAAY,CAAC,EAEjFL,EAAQ,OAAO,iBAAiB,QAASK,CAAa,EAEtD,KAAK,QAAQ,IAAML,EAAQ,QAAQ,oBAAoB,QAASK,CAAa,CAAC,CAC/E,CAED,GAAI,OAAOL,GAAS,SAAY,UAAY,OAAO,SAASA,EAAQ,OAAO,EAAG,CAC7E,IAAMM,EAAU,WAAW,IAAM,KAAK,OAAO,IAAI,aAAa,mBAAoB,cAAc,CAAC,EAAGN,EAAQ,OAAO,EAEnH,KAAK,QAAQ,IAAM,aAAaM,CAAO,CAAC,CACzC,CAEAP,IAAW,KAAK,QAAS,KAAK,MAAM,CAErC,CAEA,UAAY,GACZ,YAAc,GACd,WAAa,GAEb,MAA8C,UAE9C,OAES,QAAWQ,GAAmB,CAEtC,GAAI,KAAK,UAAW,CACnB,KAAK,UAAY,GACjB,KAAK,YAAc,GACnB,KAAK,MAAQ,YACb,KAAK,OAASA,EAEd,IAAMC,EAASZ,EAAW,IAAI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EAAQS,KACpCT,EAAOS,CAAI,EAAI,GAERT,GACL,CAAC,CAAW,EAAG,CAAE,OAAQ,CAAE,CAAC,CAEhC,CAEAJ,GAAuB,CAACG,EAAwBW,IAA6B,CAG5E,GAFA,KAAKZ,GAAgB,IAAIC,EAAM,IAAI,EAE/BW,EAAQ,QAAQ,OAAQ,CAC3B,GAAM,CAAE,UAAAC,EAAY,IAAK,EAAIC,EAAYF,EAAQ,QAAQ,MAAM,EAE/D,KAAKZ,GAAgB,IAAIC,EAAMY,CAAS,EAEpCA,GACH,KAAK,YAAY,WAAWZ,EAAMY,EAAW,EAAI,CACnD,CAED,EAEAd,GAAwBE,GAA2B,CAC9C,KAAKD,GAAgB,IAAIC,CAAI,IAAMA,EAAK,SAAS,MACpD,KAAKD,GAAgB,IAAIC,EAAMA,EAAK,SAAS,KAAO,IAAI,EAEpDA,EAAK,QAAUA,EAAK,QACvB,KAAK,IAAIA,EAAM,CAAE,UAAWA,EAAK,QAAQ,GAAI,EAAG,CAAE,OAAQ,KAAK,OAAQ,OAAQ,KAAK,MAAO,CAAC,EAE5F,KAAK,MAAMA,EAAM,CAAE,WAAY,CAAC,EAGnC,EAGA,OAAO,MAAQa,CAEhB",
|
|
6
|
+
"names": ["noop", "nativesMap", "StatefulPromise", "_StatefulPromise", "executor", "options", "nativeResolve", "nativeReject", "resolve", "reject", "abortListener", "timeout", "value", "native", "reason", "_", "debounce", "callback", "limit", "options", "leading", "trailing", "maxWait", "timeout", "maxWaitTimeout", "end", "context", "args", "initial", "final", "result", "expired", "n", "debounced", "maxWaitExpired", "run", "error", "_args", "StatefulPromise", "resolve", "reject", "noop", "shouldRun", "timeoutsMapMap", "cleanup", "map", "key", "timeoutsMap", "timeout", "setup", "ms", "getWithTimeout", "map", "key", "value", "cleanup", "howmuch", "number", "one", "two", "five", "shouldPrintNumber", "u", "d", "random", "from", "to", "setWithTimeout", "map", "key", "value", "ms", "setup", "ClassMiddleware", "tokenMap", "CookieMiddleware", "_CookieMiddleware", "ClassMiddleware", "options", "path", "#handler", "request", "response", "token", "tokenMap", "getWithTimeout", "name", "value", "maxAge", "expiresAt", "domain", "secure", "httpOnly", "sameSite", "cookie", "parseCookie", "cookie", "object", "keyEqValue", "key", "value", "crypto", "headers", "cookieTokenTimeout", "CookieSetter", "usersServer", "domain", "maxAge", "#handleClientConnect", "#handleClientSession", "#wsSessionIdMap", "wssc", "cookie", "options", "token", "crypto", "random", "setWithTimeout", "tokenMap", "headers", "names", "name", "request", "sessionId", "parseCookie"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
2
|
+
"name": "insite-cookie",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "Cookie support for inSite",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/server.js",
|
|
7
|
+
"module": "./dist/server.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./server": "./dist/server/index.js",
|
|
10
|
+
"./client": "./dist/client/index.js"
|
|
11
|
+
},
|
|
12
|
+
"packageManager": "bun@1.2.11",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
15
|
+
"build": "bun .conveyer.js",
|
|
16
|
+
"postbuild": "tsc -p ."
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/nesvet/insite-cookie.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"insite",
|
|
24
|
+
"cookie",
|
|
25
|
+
"client",
|
|
26
|
+
"server"
|
|
27
|
+
],
|
|
28
|
+
"author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@nesvet/n": "^1.2.0",
|
|
32
|
+
"insite-common": "^2.3.0",
|
|
33
|
+
"insite-http": "^2.3.0",
|
|
34
|
+
"insite-users-server-ws": "^2.3.0",
|
|
35
|
+
"insite-ws": "^2.3.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@nesvet/conveyer": "^2.5.2",
|
|
39
|
+
"@nesvet/eslint-config": "^2.1.1",
|
|
40
|
+
"@types/node": "^22.15.3",
|
|
41
|
+
"@types/ws": "^8.18.1",
|
|
42
|
+
"typescript": "^5.8.3"
|
|
43
|
+
}
|
|
44
44
|
}
|