Skip to content

Commit 7a5b2f5

Browse files
committed
feat(gdpr): surface padDeletionToken in clientVars for creators only
Revision-0 author on their first CLIENT_READY visit receives the plaintext token; all subsequent CLIENT_READYs receive null because createDeletionTokenIfAbsent is idempotent. Readonly sessions and any other user never see the token.
1 parent e8c0935 commit 7a5b2f5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/node/handler/PadMessageHandler.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,16 @@ const handleClientReady = async (socket:any, message: ClientReadyMessage) => {
10211021
throw new Error('corrupt pad');
10221022
}
10231023

1024+
// Only the original creator of the pad (revision 0 author) receives the
1025+
// deletion token, and only on their first arrival — subsequent visits get
1026+
// null because createDeletionTokenIfAbsent() only emits a plaintext token
1027+
// once. Readonly sessions never see it.
1028+
const isCreator =
1029+
!sessionInfo.readonly && sessionInfo.author === await pad.getRevisionAuthor(0);
1030+
const padDeletionToken = isCreator
1031+
? await padDeletionManager.createDeletionTokenIfAbsent(sessionInfo.padId)
1032+
: null;
1033+
10241034
// Warning: never ever send sessionInfo.padId to the client. If the client is read only you
10251035
// would open a security hole 1 swedish mile wide...
10261036
const clientVars:MapArrayType<any> = {
@@ -1031,6 +1041,7 @@ const handleClientReady = async (socket:any, message: ClientReadyMessage) => {
10311041
maxRevisions: 100,
10321042
},
10331043
enableDarkMode: settings.enableDarkMode,
1044+
padDeletionToken,
10341045
automaticReconnectionTimeout: settings.automaticReconnectionTimeout,
10351046
initialRevisionList: [],
10361047
initialOptions: {},

0 commit comments

Comments
 (0)