@@ -176,6 +176,38 @@ const getParams = () => {
176176
177177const getUrlVars = ( ) => new URL ( window . location . href ) . searchParams ;
178178
179+ // Surfaces the one-time pad deletion token when the server sends it in
180+ // clientVars (creator session, first CLIENT_READY). The token is cleared from
181+ // clientVars on acknowledgement so it is not re-exposed to later code paths.
182+ const showDeletionTokenModalIfPresent = ( ) => {
183+ const token : string | null = ( window as any ) . clientVars ?. padDeletionToken ;
184+ if ( ! token ) return ;
185+ const $modal = $ ( '#deletiontoken-modal' ) ;
186+ const $input = $ ( '#deletiontoken-value' ) ;
187+ const $copy = $ ( '#deletiontoken-copy' ) ;
188+ const $ack = $ ( '#deletiontoken-ack' ) ;
189+ if ( $modal . length === 0 ) return ;
190+
191+ $input . val ( token ) ;
192+ $modal . prop ( 'hidden' , false ) . addClass ( 'popup-show' ) ;
193+
194+ $copy . off ( 'click.gdpr' ) . on ( 'click.gdpr' , async ( ) => {
195+ try {
196+ await navigator . clipboard . writeText ( token ) ;
197+ } catch ( _e ) {
198+ ( $input [ 0 ] as HTMLInputElement ) . select ( ) ;
199+ document . execCommand ( 'copy' ) ;
200+ }
201+ $copy . text ( html10n . get ( 'pad.deletionToken.copied' ) ) ;
202+ } ) ;
203+
204+ $ack . off ( 'click.gdpr' ) . on ( 'click.gdpr' , ( ) => {
205+ $input . val ( '' ) ;
206+ $modal . prop ( 'hidden' , true ) . removeClass ( 'popup-show' ) ;
207+ ( window as any ) . clientVars . padDeletionToken = null ;
208+ } ) ;
209+ } ;
210+
179211const sendClientReady = ( isReconnect ) => {
180212 let padId = document . location . pathname . substring ( document . location . pathname . lastIndexOf ( '/' ) + 1 ) ;
181213 // unescape necessary due to Safari and Opera interpretation of spaces
@@ -497,6 +529,8 @@ const pad = {
497529 skinVariants . updateSkinVariantsClasses ( [ 'super-dark-editor' , 'dark-background' , 'super-dark-toolbar' ] ) ;
498530 }
499531
532+ showDeletionTokenModalIfPresent ( ) ;
533+
500534 hooks . aCallAll ( 'postAceInit' , { ace : padeditor . ace , clientVars, pad} ) ;
501535 } ;
502536
0 commit comments