From 7709544c54bdbba12ce075b57978e31a3d995d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Garc=C3=ADa?= Date: Thu, 13 Nov 2025 20:39:18 +0100 Subject: [PATCH 1/5] feat: exclude package managers dev files from dist archive --- .distignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.distignore b/.distignore index 84519f65..c4f986f7 100755 --- a/.distignore +++ b/.distignore @@ -23,11 +23,11 @@ behat.yml bitbucket-pipelines.yml bin .circleci/config.yml -# composer.json +composer.json composer.lock dependencies.yml Gruntfile.js -# package.json +package.json package-lock.json phpunit.xml phpunit.xml.dist From 9cfb7ef7262ed18be0d55fc1cda9012161a6bb30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Garc=C3=ADa?= Date: Fri, 14 Nov 2025 01:07:55 +0100 Subject: [PATCH 2/5] feat: bearer credential authorization based on refresh and access token + expiration date --- src/components/Credential/AuthorizeButton.jsx | 18 +++++++++++++++++- .../Wizard/useAuthorizedCredential.js | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/components/Credential/AuthorizeButton.jsx b/src/components/Credential/AuthorizeButton.jsx index 74679b04..54ac47bd 100644 --- a/src/components/Credential/AuthorizeButton.jsx +++ b/src/components/Credential/AuthorizeButton.jsx @@ -3,6 +3,7 @@ import { useError } from "../../providers/Error"; import { useFetchSettings } from "../../providers/Settings"; import { restUrl } from "../../lib/utils"; +const { useMemo } = wp.element; const { Button } = wp.components; const apiFetch = wp.apiFetch; const { __ } = wp.i18n; @@ -13,6 +14,21 @@ export default function AuthorizeButton({ addon, data }) { const fetchSettings = useFetchSettings(); + const authorized = useMemo(() => { + if (!(data.access_token && data.expires_at)) return false; + + if (data.refresh_token) { + return true; + } + + let expirationDate = new Date(data.expires_at); + if (expirationDate.getFullYear() === 1970) { + expirationDate = new Date(data.expires_at * 1000); + } + + return Date.now() < expirationDate.getTime(); + }, [data.access_token, data.expires_at]); + const revoke = () => { setLoading(true); @@ -65,7 +81,7 @@ export default function AuthorizeButton({ addon, data }) { .finally(() => setLoading(false)); }; - if (data.refresh_token) { + if (authorized) { return (