File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
components/simple-transcription Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -876,6 +876,31 @@ export default class SimpleTranscriptionInterface extends HTMLElement {
876876 this . #postToTool( this . #buildTPENContext( ) , targetWindow )
877877 }
878878
879+ #sendIdTokenToTool( targetWindow = this . #activeToolIframe?. contentWindow ) {
880+ const idToken = TPEN . getAuthorization ( )
881+
882+ if ( ! idToken ) {
883+ TPEN . login ( )
884+ return
885+ }
886+
887+ const tool = this . getToolByName ( this . state . activeTool )
888+ const toolLabel = tool ?. label ?? tool ?. custom ?. tagName ?? 'Tool'
889+
890+ this . #postToTool(
891+ {
892+ type : 'TPEN_ID_TOKEN' ,
893+ idToken
894+ } ,
895+ targetWindow
896+ )
897+
898+ TPEN . eventDispatcher . dispatch ( 'tpen-toast' , {
899+ message : `Authorized ${ toolLabel } to act on your behalf` ,
900+ status : 'info'
901+ } )
902+ }
903+
879904 loadRightPaneContent ( ) {
880905 const rightPane = this . shadowRoot . querySelector ( '.tools' )
881906 let tool = this . getToolByName ( this . state . activeTool )
@@ -1017,6 +1042,11 @@ export default class SimpleTranscriptionInterface extends HTMLElement {
10171042 this . #sendTPENContextToTool( event . source )
10181043 return
10191044 }
1045+
1046+ if ( event . data ?. type === 'REQUEST_ID_TOKEN' || event . data ?. type === 'REQUEST_TPEN_ID_TOKEN' ) {
1047+ this . #sendIdTokenToTool( event . source )
1048+ return
1049+ }
10201050
10211051 // Handle incoming messages from tools
10221052 const lineId = event . data ?. lineId ?? event . data ?. lineid ?? event . data ?. annotation // handle different casing and properties
You can’t perform that action at this time.
0 commit comments