mirror of
https://github.com/docmost/docmost.git
synced 2025-11-24 09:41:16 +10:00
feat: public page sharing (#1012)
* Share - WIP * - public attachment links - WIP * WIP * WIP * Share - WIP * WIP * WIP * include userRole in space object * WIP * Server render shared page meta tags * disable user select * Close Navbar on outside click on mobile * update shared page spaceId * WIP * fix * close sidebar on click * close sidebar * defaults * update copy * Store share key in lowercase * refactor page breadcrumbs * Change copy * add link ref * open link button * add meta og:title * add twitter tags * WIP * make shares/info endpoint public * fix * * add /p/ segment to share urls * minore fixes * change mobile breadcrumb icon
This commit is contained in:
@ -2,6 +2,7 @@ export enum JwtType {
|
||||
ACCESS = 'access',
|
||||
COLLAB = 'collab',
|
||||
EXCHANGE = 'exchange',
|
||||
ATTACHMENT = 'attachment',
|
||||
}
|
||||
export type JwtPayload = {
|
||||
sub: string;
|
||||
@ -21,3 +22,11 @@ export type JwtExchangePayload = {
|
||||
workspaceId: string;
|
||||
type: 'exchange';
|
||||
};
|
||||
|
||||
export type JwtAttachmentPayload = {
|
||||
attachmentId: string;
|
||||
pageId: string;
|
||||
workspaceId: string;
|
||||
type: 'attachment';
|
||||
};
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { EnvironmentService } from '../../../integrations/environment/environment.service';
|
||||
import {
|
||||
JwtAttachmentPayload,
|
||||
JwtCollabPayload,
|
||||
JwtExchangePayload,
|
||||
JwtPayload,
|
||||
@ -59,6 +60,21 @@ export class TokenService {
|
||||
return this.jwtService.sign(payload, { expiresIn: '10s' });
|
||||
}
|
||||
|
||||
async generateAttachmentToken(opts: {
|
||||
attachmentId: string;
|
||||
pageId: string;
|
||||
workspaceId: string;
|
||||
}): Promise<string> {
|
||||
const { attachmentId, pageId, workspaceId } = opts;
|
||||
const payload: JwtAttachmentPayload = {
|
||||
attachmentId: attachmentId,
|
||||
pageId: pageId,
|
||||
workspaceId: workspaceId,
|
||||
type: JwtType.ATTACHMENT,
|
||||
};
|
||||
return this.jwtService.sign(payload, { expiresIn: '1h' });
|
||||
}
|
||||
|
||||
async verifyJwt(token: string, tokenType: string) {
|
||||
const payload = await this.jwtService.verifyAsync(token, {
|
||||
secret: this.environmentService.getAppSecret(),
|
||||
|
||||
Reference in New Issue
Block a user