diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5373630..c0cd7ab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog for TrustedLogin Client
+## 1.10 (March 10, 2025)
+
+- Added postMessage response to the opener when access is granted or revoked
+- Added hidden input to store the expiration date of the support user
+- Added expiration to the message sent to the opener when access is granted
+
## 1.9.0 (August 25, 2024)
- Added a minimum `vendor/namespace` length of five characters to help prevent collisions with other instances
diff --git a/src/Client.php b/src/Client.php
index 478cb33..ec67466 100644
--- a/src/Client.php
+++ b/src/Client.php
@@ -322,6 +322,7 @@ public function grant_access( $include_debug_data = false, $ticket_data = null )
$return_data = array(
'type' => 'new',
+ 'key' => $this->site_access->get_access_key(),
'site_url' => get_site_url(),
'endpoint' => $endpoint_hash,
'identifier' => $site_identifier_hash,
diff --git a/src/Form.php b/src/Form.php
index 343ff28..63df0a8 100644
--- a/src/Form.php
+++ b/src/Form.php
@@ -1472,6 +1472,7 @@ public function output_support_users( $print_and_return = true ) {
+
%6\$s>
@@ -1494,7 +1495,9 @@ public function output_support_users( $print_and_return = true ) {
esc_html__( 'Copy the access key to your clipboard', 'trustedlogin' ),
// %8$s
// translators: %s is the display name of the TrustedLogin support user.
- sprintf( esc_html__( 'The access key is not a password; only %1$s will be able to access your site using this code. You may share this access key on support forums.', 'trustedlogin' ), esc_html( $this->support_user->get_first()->display_name ) )
+ sprintf( esc_html__( 'The access key is not a password; only %1$s will be able to access your site using this code. You may share this access key on support forums.', 'gk-gravitycalendar' ), esc_html( $this->support_user->get_first()->display_name ) ),
+ /* %9$s */
+ esc_attr( $this->support_user->get_expiration( $this->support_user->get_first() ) )
);
}
diff --git a/src/assets/trustedlogin.js b/src/assets/trustedlogin.js
index 0cacb4a..00a97fb 100644
--- a/src/assets/trustedlogin.js
+++ b/src/assets/trustedlogin.js
@@ -3,9 +3,35 @@
'use strict';
- var $body = $( 'body' ), namespace = tl_obj.vendor.namespace,
- $tl_container = $( '.tl-' + namespace + '-auth' ), copy_button_timer = null,
- second_status = null;
+ var $body = $( 'body' ),
+ namespace = tl_obj.vendor.namespace,
+ $tl_container = $( '.tl-' + namespace + '-auth' ),
+ copy_button_timer = null,
+ second_status = null,
+ key = $( '#tl-' + namespace + '-access-key', $tl_container ).val(),
+ expiration = $( '#tl-' + namespace + '-access-expiration', $tl_container ).val(),
+ urlParams = new URLSearchParams( window.location.search );
+
+ if ( window.opener && key && ! urlParams.has( 'revoking' ) ) {
+ window.opener.postMessage( {
+ key: key,
+ expiration: expiration,
+ type: 'granted'
+ }, '*' );
+ }
+
+ function hideWindow() {
+ window.resizeTo( 1, 1 );
+ window.moveTo( screen.width + 500, screen.height + 500 );
+ window.opener.focus();
+ }
+
+ $body.on( 'click', '.tl-client-revoke-button', function ( e ) {
+ if ( window.opener ) {
+ window.opener.postMessage( { type: 'revoking' }, '*' );
+ hideWindow();
+ }
+ } );
$body.on( 'click', tl_obj.selector, function ( e ) {
@@ -27,6 +53,10 @@
} );
function grantAccess( $button ) {
+ if ( window.opener ) {
+ window.opener.postMessage( { type: 'granting' }, '*' );
+ hideWindow();
+ }
$button.addClass( 'disabled' );
@@ -104,6 +134,15 @@
success: remote_success,
error: remote_error
} ).always( function ( response ) {
+ if ( window.opener ) {
+ var key = response && response.data && response.data.key ? response.data.key : '';
+ var expiry = response && response.data && response.data.expiry ? response.data.expiry : '';
+ window.opener.postMessage( {
+ key: key,
+ expiration: expiry,
+ type: 'granted'
+ }, '*' );
+ }
if ( !tl_obj.debug ) {
return;