♻️ Apply more accurate authentication naming

- “authenticate” instead of “connect”
- “withCredentials” instead of “direct”
- “OAuth” instead of “ISU”
This commit is contained in:
Philipp Stracker 2025-01-08 14:59:59 +01:00
parent ac68aa7968
commit 1bf6e488a3
No known key found for this signature in database
5 changed files with 22 additions and 22 deletions

View file

@ -19,8 +19,8 @@ export default {
// Controls - always start with "DO_".
DO_PERSIST_DATA: 'COMMON:DO_PERSIST_DATA',
DO_MANUAL_AUTHENTICATION: 'COMMON:DO_MANUAL_AUTHENTICATION',
DO_ISU_AUTHENTICATION: 'COMMON:DO_ISU_AUTHENTICATION',
DO_DIRECT_API_AUTHENTICATION: 'COMMON:DO_DIRECT_API_AUTHENTICATION',
DO_OAUTH_AUTHENTICATION: 'COMMON:DO_OAUTH_AUTHENTICATION',
DO_GENERATE_ONBOARDING_URL: 'COMMON:DO_GENERATE_ONBOARDING_URL',
DO_REFRESH_MERCHANT: 'COMMON:DO_REFRESH_MERCHANT',
DO_REFRESH_FEATURES: 'COMMON:DO_REFRESH_FEATURES',

View file

@ -177,12 +177,12 @@ export const productionOnboardingUrl = function* ( products = [] ) {
*
* @return {Action} The action.
*/
export const connectViaSecret = function* () {
export const authenticateWithCredentials = function* () {
const { clientId, clientSecret, useSandbox } =
yield select( STORE_NAME ).persistentData();
return yield {
type: ACTION_TYPES.DO_MANUAL_AUTHENTICATION,
type: ACTION_TYPES.DO_DIRECT_API_AUTHENTICATION,
clientId,
clientSecret,
useSandbox,
@ -197,12 +197,12 @@ export const connectViaSecret = function* () {
* parameters are dynamically generated during the authentication process, and not managed by our
* Redux store.
*
* @param {string} sharedId - OAuth client ID, provided via "sharedId" during onboarding.
* @param {string} sharedId - OAuth client ID; called "sharedId" to prevent confusion with the API client ID.
* @param {string} authCode - OAuth authorization code provided during onboarding.
* @param {string} environment - [production|sandbox].
* @return {Action} The action.
*/
export const connectViaAuthCode = function* (
export const authenticateWithOAuth = function* (
sharedId,
authCode,
environment
@ -210,7 +210,7 @@ export const connectViaAuthCode = function* (
const useSandbox = 'sandbox' === environment;
return yield {
type: ACTION_TYPES.DO_ISU_AUTHENTICATION,
type: ACTION_TYPES.DO_OAUTH_AUTHENTICATION,
sharedId,
authCode,
useSandbox,

View file

@ -52,7 +52,7 @@ export const controls = {
}
},
async [ ACTION_TYPES.DO_MANUAL_AUTHENTICATION ]( {
async [ ACTION_TYPES.DO_DIRECT_API_AUTHENTICATION ]( {
clientId,
clientSecret,
useSandbox,
@ -75,7 +75,7 @@ export const controls = {
}
},
async [ ACTION_TYPES.DO_ISU_AUTHENTICATION ]( {
async [ ACTION_TYPES.DO_OAUTH_AUTHENTICATION ]( {
sharedId,
authCode,
useSandbox,

View file

@ -32,8 +32,8 @@ const useHooks = () => {
setClientSecret,
sandboxOnboardingUrl,
productionOnboardingUrl,
connectViaSecret,
connectViaAuthCode,
authenticateWithCredentials,
authenticateWithOAuth,
startWebhookSimulation,
checkWebhookSimulationState,
} = useDispatch( STORE_NAME );
@ -81,8 +81,8 @@ const useHooks = () => {
},
sandboxOnboardingUrl,
productionOnboardingUrl,
connectViaSecret,
connectViaAuthCode,
authenticateWithCredentials,
authenticateWithOAuth,
merchant,
wooSettings,
webhooks,
@ -111,8 +111,8 @@ export const useAuthentication = () => {
setClientId,
clientSecret,
setClientSecret,
connectViaSecret,
connectViaAuthCode,
authenticateWithCredentials,
authenticateWithOAuth,
} = useHooks();
return {
@ -122,8 +122,8 @@ export const useAuthentication = () => {
setClientId,
clientSecret,
setClientSecret,
connectViaSecret,
connectViaAuthCode,
authenticateWithCredentials,
authenticateWithOAuth,
};
};

View file

@ -44,7 +44,7 @@ export const useHandleOnboardingButton = ( isSandbox ) => {
const { productionOnboardingUrl } = CommonHooks.useProduction();
const products = OnboardingHooks.useDetermineProducts();
const { withActivity } = CommonHooks.useBusyState();
const { connectViaAuthCode } = CommonHooks.useAuthentication();
const { authenticateWithOAuth } = CommonHooks.useAuthentication();
const [ onboardingUrl, setOnboardingUrl ] = useState( '' );
const [ scriptLoaded, setScriptLoaded ] = useState( false );
const timerRef = useRef( null );
@ -127,7 +127,7 @@ export const useHandleOnboardingButton = ( isSandbox ) => {
ACTIVITIES.CONNECT_ISU,
'Validating the connection details',
async () => {
await connectViaAuthCode(
await authenticateWithOAuth(
sharedId,
authCode,
environment
@ -148,7 +148,7 @@ export const useHandleOnboardingButton = ( isSandbox ) => {
// Ensure the onComplete handler is not removed by a PayPal init script.
timerRef.current = setInterval( addHandler, 250 );
},
[ connectViaAuthCode, withActivity ]
[ authenticateWithOAuth, withActivity ]
);
const removeCompleteHandler = useCallback( () => {
@ -211,7 +211,7 @@ export const useDirectAuthentication = () => {
useConnectionBase();
const { withActivity } = CommonHooks.useBusyState();
const {
connectViaSecret,
authenticateWithCredentials,
isManualConnectionMode,
setManualConnectionMode,
clientId,
@ -234,7 +234,7 @@ export const useDirectAuthentication = () => {
}
}
const res = await connectViaSecret();
const res = await authenticateWithCredentials();
if ( res.success ) {
await handleCompleted();