mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Converting server-side Comm.js to typescript
Summary: - Add app/common/CommTypes.ts to define types shared by client and server. - Include @types/ws npm package Test Plan: Intended to have no changes in behavior Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3467
This commit is contained in:
@@ -3,6 +3,7 @@ import {cookieName, SessionStore} from 'app/server/lib/gristSessions';
|
||||
import * as cookie from 'cookie';
|
||||
import * as cookieParser from 'cookie-parser';
|
||||
import {Request} from 'express';
|
||||
import {IncomingMessage} from 'http';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -74,14 +75,14 @@ export class Sessions {
|
||||
/**
|
||||
* Returns the sessionId from the signed grist cookie.
|
||||
*/
|
||||
public getSessionIdFromCookie(gristCookie: string) {
|
||||
public getSessionIdFromCookie(gristCookie: string): string|false {
|
||||
return cookieParser.signedCookie(gristCookie, this._sessionSecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session id from the grist cookie. Returns null if no cookie found.
|
||||
*/
|
||||
public getSessionIdFromRequest(req: Request): string|null {
|
||||
public getSessionIdFromRequest(req: Request|IncomingMessage): string|null {
|
||||
if (req.headers.cookie) {
|
||||
const cookies = cookie.parse(req.headers.cookie);
|
||||
const sessionId = this.getSessionIdFromCookie(cookies[cookieName]);
|
||||
|
||||
Reference in New Issue
Block a user