Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hidemyemail extension #16015

Merged
merged 5 commits into from
Jan 10, 2025
Merged

Conversation

svenhofman
Copy link
Contributor

@svenhofman svenhofman commented Dec 23, 2024

Description

  • Improved user experience through caching and optimistic updates
  • Increased timeout limit for network requests to reduce failed requests
  • Added icons for some actions
  • Handled situation where session expires while using the extension
  • Added more information in metadata section

Screencast

Checklist

- improved user experience through caching and optimistic updates, ncreased timeout limit, added icons
- Initial commit
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: hidemyemail Issues related to the hidemyemail extension OP is author The OP of the PR is the author of the extension labels Dec 23, 2024
@raycastbot
Copy link
Collaborator

raycastbot commented Dec 23, 2024

Thank you for the update! 🎉

Due to our current reduced availability, the initial review may take up to 10-15 business days 🎄

- added information to list item metadata, fixed bugs
- improved login / session expired handling
Copy link
Collaborator

@pernielsentikaer pernielsentikaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It feels a bit weird that I see the login screen everythime I open the command, do you have a good idea on how we can improve this?
Raycast02012025-VTiRD8gH.png.mp4

- linting fix
- Fixed issue useCachedPromise() not fetching last cached state
@svenhofman
Copy link
Contributor Author

svenhofman commented Jan 2, 2025

I think I've found and fixed the issue although I'm not sure if it's me using hooks incorrectly or a bug when using both the useCachedPromise and useCachedState hook: if no namespace is provided in useCachedState, the useCachedPromise isn't able to retrieve the cached data (see MWE1 below).

Also, why is there a short moment of the "No Results" view even when rendering the List component with List.Items? This happens when opening List Emails, and also happens in MWE2 below.

MWE1:

import { Detail } from "@raycast/api";
import { useCachedPromise, useCachedState } from "@raycast/utils";

export default function Command() {
  const [cachedState, setCachedState] = useCachedState("cachedData", false);   // With this line enabled, useCachedPromise doesn't fetch the cached data
  // const [cachedState, setCachedState] = useCachedState("cachedData", false, {cacheNamespace: "test"}); // With this line enabled, it works

  const {data} = useCachedPromise(async () => {
    await new Promise(resolve => setTimeout(resolve, 1000));
    return "Data!";
  },
  [],
  {
    initialData: "No data...",
  })


  return (
    <Detail markdown={data} />
  );
}

MWE2:

import { ActionPanel, Detail, Action, List } from "@raycast/api";

function Ping() {
  return (
    <Detail
      markdown="Ping"
      actions={
        <ActionPanel>
          <Action.Push title="Push Pong" target={<Pong />} />
        </ActionPanel>
      }
    />
  );
}

function Pong() {
  return (<List> 
      <List.Item id="pong" title="Pong"></List.Item>
    </List>);
}

export default function Command() {
  return <Ping />;
}

@pernielsentikaer
Copy link
Collaborator

I'll ask my collegaues about this next week since they're all on vacation until next week 🙂

In the latest change I keep getting logged out, I don't know if that's becaue of the latest change. In the video I just logged in and re-opened the command again.

Raycast02012025-Wp0Z8Zlv.png.mp4

@svenhofman
Copy link
Contributor Author

Haha, it seems you take working for a productivity tool very seriously ;)

I'm not able to reproduce the issue. Did you try clearing local storage & cache? If this didn't resolve it, could you show me what is logged to the console when you open the command?

@pernielsentikaer
Copy link
Collaborator

I removed some of the URLs so you can see output

14:36:01.830 ------- Error -------
14:36:01.830 ------- Request -------
14:36:01.830 Request URL: https://p121-maildomainws.icloud.com:443/v2/hme/list
14:36:01.830 Request Headers:
14:36:01.830 Accept: application/json, text/plain, */*
14:36:01.830 Content-Type: undefined
14:36:01.830 Origin: https://www.icloud.com
14:36:01.830 Referer: https://www.icloud.com/
14:36:01.830 User-Agent: axios/1.7.7
14:36:01.830 Accept-Encoding: gzip, compress, deflate, br
14:36:01.830 ------- Response -------
14:36:01.830 Status:  401
14:36:01.830 StatusText:  Unauthorized
14:36:01.830 Data:  { reason: 'Missing X-APPLE-WEBAUTH-USER cookie', error: 1 }
14:36:01.830 ------- ----- -------
14:36:32.249 ------- Error -------
14:36:32.249 ------- Request -------
14:36:32.250 Request URL: https://setup.icloud.com/setup/ws/1/validate
14:36:32.250 Request Headers:
14:36:32.250 Accept: application/json, text/plain, */*
14:36:32.250 Content-Type: application/x-www-form-urlencoded
14:36:32.250 Origin: https://www.icloud.com
14:36:32.250 Referer: https://www.icloud.com/
14:36:32.251 User-Agent: axios/1.7.7
14:36:32.251 Accept-Encoding: gzip, compress, deflate, br
14:36:32.251 ------- Response -------
14:36:32.251 Status:  421
14:36:32.251 StatusText:  Misdirected Request
14:36:32.251 Data:  {
  success: false,
  requestInfo: [ { country: 'DK', timeZone: 'GMT+1' } ],
  configBag: {
    urls: {
      accountCreateUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9916b725108f5dde8d9d1a815d#!create',
      accountVerifyUI: 'https://id.apple.com/identity?widgetKey=d39ba9916b725105b2ddecea8f5dde8d9d1a815d',
      accountLoginUI: 'https://idmsa.apple.com/appleauth/auth/signin?widgetKey=d39be65e98b2ddecea8f5dde8d9d1a815d',
      accountLogin: 'https://setup.icloud.com/setup/ws/1/accountLogin',
      accountRepairUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba99e65e98b2ddecea8f5dde8d9d1a815d#!repair',
      downloadICloudTerms: 'https://setup.icloud.com/setup/ws/1/downloadLiteTerms',
      repairDone: 'https://setup.icloud.com/setup/ws/1/repairDone',
      accountAuthorizeUI: 'https://idmsa.apple.com/appleauth/auth/authorize/signin?client_id=d991<…>
14:36:32.251 ------- ----- -------
14:36:32.266 Invalid authentication token, will log in from scratch.
14:39:07.342 ------- Error -------
14:39:07.342 ------- Request -------
14:39:07.342 Request URL: https://p121-maildomainws.icloud.com:443/v2/hme/list
14:39:07.343 Request Headers:
14:39:07.343 Accept: application/json, text/plain, */*
14:39:07.343 Content-Type: undefined
14:39:07.343 Origin: https://www.icloud.com
14:39:07.343 Referer: https://www.icloud.com/
14:39:07.343 User-Agent: axios/1.7.7
14:39:07.343 Accept-Encoding: gzip, compress, deflate, br
14:39:07.343 ------- Response -------
14:39:07.343 Status:  401
14:39:07.343 StatusText:  Unauthorized
14:39:07.343 Data:  { reason: 'Missing X-APPLE-WEBAUTH-USER cookie', error: 1 }
14:39:07.343 ------- ----- -------
14:39:12.001 ------- Error -------
14:39:12.001 ------- Request -------
14:39:12.001 Request URL: https://setup.icloud.com/setup/ws/1/validate
14:39:12.001 Request Headers:
14:39:12.001 Accept: application/json, text/plain, */*
14:39:12.001 Content-Type: application/x-www-form-urlencoded
14:39:12.001 Origin: https://www.icloud.com
14:39:12.001 Referer: https://www.icloud.com/
14:39:12.001 User-Agent: axios/1.7.7
14:39:12.002 Accept-Encoding: gzip, compress, deflate, br
14:39:12.002 ------- Response -------
14:39:12.002 Status:  421
14:39:12.002 StatusText:  Misdirected Request
14:39:12.003 Data:  {
  success: false,
  requestInfo: [ { country: 'DK', timeZone: 'GMT+1' } ],
  configBag: {
    urls: {
      accountCreateUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9916b7252ea796ee65e98b2ddecea8f5dde8d9d1a815d#!create',
      accountVerifyUI: 'https://id.apple.com/identity?widgetKey=d39ba9916b7251055b22c7f91e98b2ddecea8f5dde8d9d1a815d',
      accountLoginUI: 'https://idmsa.apple.com/appleauth/auth/signin?widgetKey=d39ba9916b0e2ea796ee65e98b2ddecea8f5dde8d9d1a815d',
      accountLogin: 'https://setup.icloud.com/setup/ws/1/accountLogin',
      accountRepairUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba991910e2ea796ee65e98b2ddecea8f5dde8d9d1a815d#!repair',
      downloadICloudTerms: 'https://setup.icloud.com/setup/ws/1/downloadLiteTerms',
      repairDone: 'https://setup.icloud.com/setup/ws/1/repairDone',
      accountAuthorizeUI: 'https://idmsa.apple.com/appleauth/auth/authorize/signin?client_id=d3991<…>
14:39:12.003 ------- ----- -------
14:39:12.003 Invalid authentication token, will log in from scratch.

@svenhofman
Copy link
Contributor Author

And what happens if you open the command, log in, and perform some action (e.g. deactivating an address). Does this work? If this does work, but on subsequent openings of the command it fails to log in, it seems to be an issue with loading/storing the cookies to local storage.

Could you replace iCloudSession.init() (not to be confused with iCloudService.init()) with the function below? (It logs cookies from local storage, but no sensitive data).
Then perform the following sequence of actions:

  1. clear local storage & cache,
  2. open List Emails and log in,
  3. escape the command and open List Emails again

and share the logs made to the console?

async init() {
    const cookieJarData = await LocalStorage.getItem<string>(this.service.cookieJarKey);
    console.log("CookieJarData", cookieJarData);
    if (cookieJarData) {
      const parsedCookies = JSON.parse(cookieJarData);
      for (const cookie of parsedCookies.cookies) {
        console.log("Cookie: ", cookie.key, cookie.value !== "");
      }
      this.jar = CookieJar.deserializeSync(parsedCookies);
    } else {
      this.jar = new CookieJar();
    }

    this.instance = wrapper(
      axios.create({
        jar: this.jar,
        timeout: 10000,
      }),
    );

    // Handles 409 status code
    this.instance.interceptors.response.use(
      (response) => {
        return response;
      },
      (error) => {
        if (error.response && error.response.status === 409) {
          return Promise.resolve(error.response);
        }
        return Promise.reject(error);
      },
    );

    this.instance.interceptors.response.use(
      (response) => {
        return response;
      },
      (error) => {
        console.log("------- Error -------");
        console.log("------- Request -------");
        console.log("Request URL:", error.config.url);
        console.log("Request Headers:");
        for (const key in error.config.headers) {
          console.log(`${key}: ${error.config.headers[key]}`);
        }
        console.log("------- Response -------");
        const response = error?.response;
        if (response) {
          console.log("Status: ", response.status);
          console.log("StatusText: ", response.statusText);
          console.log("Data: ", response.data);
        } else {
          console.log("error.code: ", error.code);
          console.log("error.message: ", error.message);
        }
        console.log("------- ----- -------");

        return Promise.reject(error);
      },
    );
  }

@pernielsentikaer
Copy link
Collaborator

Here you go 🙂 I get prompted to insert the 2FA just fine

> dev
> ray develop

info  -  entry points [src/list-emails.tsx src/create-new-email.tsx]
info  -  compiled entry points
info  -  generated extension's TypeScript definitions
ready -  built extension successfully
07:03:11.983 CookieJarData {"version":"[email protected]","storeType":"MemoryCookieStore","rejectPublicSuffixes":true,"enableLooseMode":false,"allowSpecialUseDomain":true,"prefixSecurity":"silent","cookies":[]}
07:03:12.280 ------- Error -------
07:03:12.281 ------- Request -------
07:03:12.281 Request URL: https://setup.icloud.com/setup/ws/1/validate
07:03:12.281 Request Headers:
07:03:12.281 Accept: application/json, text/plain, */*
07:03:12.281 Content-Type: application/x-www-form-urlencoded
07:03:12.281 Origin: https://www.icloud.com
07:03:12.283 Referer: https://www.icloud.com/
07:03:12.283 User-Agent: axios/1.7.7
07:03:12.283 Accept-Encoding: gzip, compress, deflate, br
07:03:12.283 ------- Response -------
07:03:12.283 Status:  421
07:03:12.283 StatusText:  Misdirected Request
07:03:12.283 Data:  {
  success: false,
  requestInfo: [ { country: 'DK', timeZone: 'GMT+1' } ],
  configBag: {
    urls: {
      accountCreateUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9916b7251055b2e65e98b2ddecea8f5dde8d9d1a815d#!create',
      accountVerifyUI: 'https://id.apple.com/identity?widgetKey=d39ba9916b7251055b2e65e98b2ddecea8f5dde8d9d1a815d',
      accountLoginUI: 'https://idmsa.apple.com/appleauth/auth/signin?widgetKey=d39ba9916b7251055b2e65e98b2ddecea8f5dde8d9d1a815d',
      accountLogin: 'https://setup.icloud.com/setup/ws/1/accountLogin',
      accountRepairUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9916b7251055b2e65e98b2ddecea8f5dde8d9d1a815d#!repair',
      downloadICloudTerms: 'https://setup.icloud.com/setup/ws/1/downloadLiteTerms',
      repairDone: 'https://setup.icloud.com/setup/ws/1/repairDone',
      accountAuthorizeUI: 'https://idmsa.apple.com/appleauth/auth/authorize/signin?client_id=d3991<…>
07:03:12.284 ------- ----- -------
07:03:12.284 Invalid authentication token, will log in from scratch.
07:03:29.390 CookieJarData {"version":"[email protected]","storeType":"MemoryCookieStore","rejectPublicSuffixes":true,"enableLooseMode":false,"allowSpecialUseDomain":true,"prefixSecurity":"silent","cookies":[]}
07:03:47.795 ------- Error -------
07:03:47.795 ------- Request -------
07:03:47.795 Request URL: https://p121-maildomainws.icloud.com:443/v2/hme/list
07:03:47.795 Request Headers:
07:03:47.795 Accept: application/json, text/plain, */*
07:03:47.795 Content-Type: undefined
07:03:47.795 Origin: https://www.icloud.com
07:03:47.795 Referer: https://www.icloud.com/
07:03:47.795 User-Agent: axios/1.7.7
07:03:47.796 Accept-Encoding: gzip, compress, deflate, br
07:03:47.796 ------- Response -------
07:03:47.796 Status:  401
07:03:47.796 StatusText:  Unauthorized
07:03:47.796 Data:  { reason: 'Missing X-APPLE-WEBAUTH-USER cookie', error: 1 }
07:03:47.796 ------- ----- -------
07:03:53.247 CookieJarData {"version":"[email protected]","storeType":"MemoryCookieStore","rejectPublicSuffixes":true,"enableLooseMode":false,"allowSpecialUseDomain":true,"prefixSecurity":"silent","cookies":[]}
07:03:53.578 ------- Error -------
07:03:53.578 ------- Request -------
07:03:53.578 Request URL: https://setup.icloud.com/setup/ws/1/validate
07:03:53.578 Request Headers:
07:03:53.578 Accept: application/json, text/plain, */*
07:03:53.578 Content-Type: application/x-www-form-urlencoded
07:03:53.578 Origin: https://www.icloud.com
07:03:53.578 Referer: https://www.icloud.com/
07:03:53.578 User-Agent: axios/1.7.7
07:03:53.578 Accept-Encoding: gzip, compress, deflate, br
07:03:53.578 ------- Response -------
07:03:53.578 Status:  421
07:03:53.578 StatusText:  Misdirected Request
07:03:53.579 Data:  {
  success: false,
  requestInfo: [ { country: 'DK', timeZone: 'GMT+1' } ],
  configBag: {
    urls: {
      accountCreateUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39916b7251055b2e65e98b2ddecea8f5dde8d9d1a815d#!create',
      accountVerifyUI: 'https://id.apple.com/identity?widgetKey=d39916b7251055b2e65e98b2ddecea8f5dde8d9d1a815d',
      accountLoginUI: 'https://idmsa.apple.com/appleauth/auth/signin?widgetKey=d39916b7251055b2e65e98b2ddecea8f5dde8d9d1a815d',
      accountLogin: 'https://setup.icloud.com/setup/ws/1/accountLogin',
      accountRepairUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9916b7251055b2e65e98b2ddecea8f5dde8d9d1a815d#!repair',
      downloadICloudTerms: 'https://setup.icloud.com/setup/ws/1/downloadLiteTerms',
      repairDone: 'https://setup.icloud.com/setup/ws/1/repairDone',
      accountAuthorizeUI: 'https://idmsa.apple.com/appleauth/auth/authorize/signin?client_id=d39ba991<…>
07:03:53.579 ------- ----- -------
07:03:53.579 Invalid authentication token, will log in from scratch.

@svenhofman
Copy link
Contributor Author

So it is saving and loading the data from local storage, but no cookies are actually stored after making the requests. Could you add the following line below line 76 in connect.ts?

withCredentials: true

so it becomes

this.instance = wrapper(
      axios.create({
        jar: this.jar,
        timeout: 10000,
        withCredentials: true     // add this line
      }),
    );

I hope this solves the problem

@pernielsentikaer
Copy link
Collaborator

Still failed actually, said "logged in" but re-entering did the same

❯ npm run dev

> dev
> ray develop

info  -  entry points [src/list-emails.tsx src/create-new-email.tsx]
info  -  compiled entry points
info  -  generated extension's TypeScript definitions
ready -  built extension successfully
09:56:52.091 ------- Error -------
09:56:52.091 ------- Request -------
09:56:52.091 Request URL: https://setup.icloud.com/setup/ws/1/validate
09:56:52.091 Request Headers:
09:56:52.091 Accept: application/json, text/plain, */*
09:56:52.091 Content-Type: application/x-www-form-urlencoded
09:56:52.092 Origin: https://www.icloud.com
09:56:52.092 Referer: https://www.icloud.com/
09:56:52.092 User-Agent: axios/1.7.7
09:56:52.092 Accept-Encoding: gzip, compress, deflate, br
09:56:52.092 ------- Response -------
09:56:52.092 error.code:  ECONNREFUSED
09:56:52.092 error.message:  connect ECONNREFUSED 127.0.0.1:9090
09:56:52.092 ------- ----- -------
09:56:55.141 ------- Error -------
09:56:55.141 ------- Request -------
09:56:55.141 Request URL: https://setup.icloud.com/setup/ws/1/validate
09:56:55.141 Request Headers:
09:56:55.141 Accept: application/json, text/plain, */*
09:56:55.141 Content-Type: application/x-www-form-urlencoded
09:56:55.141 Origin: https://www.icloud.com
09:56:55.141 Referer: https://www.icloud.com/
09:56:55.141 User-Agent: axios/1.7.7
09:56:55.141 Accept-Encoding: gzip, compress, deflate, br
09:56:55.141 ------- Response -------
09:56:55.141 error.code:  ECONNREFUSED
09:56:55.141 error.message:  connect ECONNREFUSED 127.0.0.1:9090
09:56:55.141 ------- ----- -------
09:57:12.523 ------- Error -------
09:57:12.523 ------- Request -------
09:57:12.523 Request URL: https://idmsa.apple.com/appleauth/auth/signin/init
09:57:12.523 Request Headers:
09:57:12.523 Accept: application/json, text/javascript
09:57:12.523 Content-Type: application/json
09:57:12.523 Origin: https://www.icloud.com
09:57:12.523 Referer: https://www.icloud.com/
09:57:12.523 X-Apple-OAuth-Client-Id: d39ba9916b7251055b22c7f9d1a815d
09:57:12.523 X-Apple-OAuth-Client-Type: firstPartyAuth
09:57:12.523 X-Apple-OAuth-Redirect-URI: https://www.icloud.com
09:57:12.524 X-Apple-OAuth-Require-Grant-Code: true
09:57:12.524 X-Apple-OAuth-Response-Mode: web_message
09:57:12.524 X-Apple-OAuth-Response-Type: code
09:57:12.524 X-Apple-OAuth-State: auth-39c41b20-c998-11ef-860b-59641649ad0d
09:57:12.524 X-Apple-Widget-Key: d39ba9916b7251055b22c7f9d1a815d
09:57:12.524 User-Agent: axios/1.7.7
09:57:12.524 Content-Length: 78
09:57:12.524 Accept-Encoding: gzip, compress, deflate, br
09:57:12.524 ------- Response -------
09:57:12.525 error.code:  ECONNREFUSED
09:57:12.525 error.message:  connect ECONNREFUSED 127.0.0.1:9090
09:57:12.525 ------- ----- -------
09:57:14.898 ------- Error -------
09:57:14.898 ------- Request -------
09:57:14.898 Request URL: https://idmsa.apple.com/appleauth/auth/signin/init
09:57:14.898 Request Headers:
09:57:14.898 Accept: application/json, text/javascript
09:57:14.898 Content-Type: application/json
09:57:14.898 Origin: https://www.icloud.com
09:57:14.898 Referer: https://www.icloud.com/
09:57:14.898 X-Apple-OAuth-Client-Id: d39ba9916b7251055b22c7f9d1a815d
09:57:14.898 X-Apple-OAuth-Client-Type: firstPartyAuth
09:57:14.898 X-Apple-OAuth-Redirect-URI: https://www.icloud.com
09:57:14.900 X-Apple-OAuth-Require-Grant-Code: true
09:57:14.900 X-Apple-OAuth-Response-Mode: web_message
09:57:14.900 X-Apple-OAuth-Response-Type: code
09:57:14.901 X-Apple-OAuth-State: auth-39c41b20-c998-11ef-860b-59641649ad0d
09:57:14.902 X-Apple-Widget-Key: d39ba9916bc7f9d1a815d
09:57:14.903 User-Agent: axios/1.7.7
09:57:14.903 Content-Length: 78
09:57:14.903 Accept-Encoding: gzip, compress, deflate, br
09:57:14.903 ------- Response -------
09:57:14.903 error.code:  ECONNREFUSED
09:57:14.903 error.message:  connect ECONNREFUSED 127.0.0.1:9090
09:57:14.903 ------- ----- -------
09:57:39.515 ------- Error -------
09:57:39.515 ------- Request -------
09:57:39.516 Request URL: https://p121-maildomainws.icloud.com:443/v2/hme/list
09:57:39.516 Request Headers:
09:57:39.516 Accept: application/json, text/plain, */*
09:57:39.516 Content-Type: undefined
09:57:39.516 Origin: https://www.icloud.com
09:57:39.516 Referer: https://www.icloud.com/
09:57:39.516 User-Agent: axios/1.7.7
09:57:39.516 Accept-Encoding: gzip, compress, deflate, br
09:57:39.516 ------- Response -------
09:57:39.516 Status:  401
09:57:39.517 StatusText:  Unauthorized
09:57:39.517 Data:  { reason: 'Missing X-APPLE-WEBAUTH-USER cookie', error: 1 }
09:57:39.517 ------- ----- -------
09:57:47.854 ------- Error -------
09:57:47.854 ------- Request -------
09:57:47.856 Request URL: https://setup.icloud.com/setup/ws/1/validate
09:57:47.856 Request Headers:
09:57:47.856 Accept: application/json, text/plain, */*
09:57:47.857 Content-Type: application/x-www-form-urlencoded
09:57:47.857 Origin: https://www.icloud.com
09:57:47.857 Referer: https://www.icloud.com/
09:57:47.857 User-Agent: axios/1.7.7
09:57:47.857 Accept-Encoding: gzip, compress, deflate, br
09:57:47.857 ------- Response -------
09:57:47.857 Status:  421
09:57:47.857 StatusText:  Misdirected Request
09:57:47.857 Data:  {
  success: false,
  requestInfo: [ { country: 'DK', timeZone: 'GMT+1' } ],
  configBag: {
    urls: {
      accountCreateUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9916bc7f9d1a815d#!create',
      accountVerifyUI: 'https://id.apple.com/identity?widgetKey=d39ba9916bc7f9d1a815d',
      accountLoginUI: 'https://idmsa.apple.com/appleauth/auth/signin?widgetKey=d39ba9916bc7f9d1a815d',
      accountLogin: 'https://setup.icloud.com/setup/ws/1/accountLogin',
      accountRepairUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9916bc7f9d1a815d#!repair',
      downloadICloudTerms: 'https://setup.icloud.com/setup/ws/1/downloadLiteTerms',
      repairDone: 'https://setup.icloud.com/setup/ws/1/repairDone',
      accountAuthorizeUI: 'https://idmsa.apple.com/appleauth/auth/authorize/signin?client_id=d39ba991<…>
09:57:47.857 ------- ----- -------
  event -  stopped development mode

@pernielsentikaer
Copy link
Collaborator

One where my proxy was disabled

❯ npm run dev

> dev
> ray develop

info  -  entry points [src/list-emails.tsx src/create-new-email.tsx]
info  -  compiled entry points
info  -  generated extension's TypeScript definitions
ready -  built extension successfully
10:01:16.502 ------- Error -------
10:01:16.502 ------- Request -------
10:01:16.502 Request URL: https://setup.icloud.com/setup/ws/1/validate
10:01:16.502 Request Headers:
10:01:16.502 Accept: application/json, text/plain, */*
10:01:16.502 Content-Type: application/x-www-form-urlencoded
10:01:16.502 Origin: https://www.icloud.com
10:01:16.502 Referer: https://www.icloud.com/
10:01:16.502 User-Agent: axios/1.7.7
10:01:16.502 Accept-Encoding: gzip, compress, deflate, br
10:01:16.502 ------- Response -------
10:01:16.502 Status:  421
10:01:16.502 StatusText:  Misdirected Request
10:01:16.502 Data:  {
  success: false,
  requestInfo: [ { country: 'DK', timeZone: 'GMT+1' } ],
  configBag: {
    urls: {
      accountCreateUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9d9d1a815d#!create',
      accountVerifyUI: 'https://id.apple.com/identity?widgetKey=d39ba9d9d1a815d',
      accountLoginUI: 'https://idmsa.apple.com/appleauth/auth/signin?widgetKey=d39ba9d9d1a815d',
      accountLogin: 'https://setup.icloud.com/setup/ws/1/accountLogin',
      accountRepairUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9d9d1a815d#!repair',
      downloadICloudTerms: 'https://setup.icloud.com/setup/ws/1/downloadLiteTerms',
      repairDone: 'https://setup.icloud.com/setup/ws/1/repairDone',
      accountAuthorizeUI: 'https://idmsa.apple.com/appleauth/auth/authorize/signin?client_id=d39ba991<…>
10:01:16.502 {
  "message": "Request failed with status code 421",
  "name": "AxiosError",
  "stack": "AxiosError: Request failed with status code 421\n    at settle (/Users/pernielsentikaer/.config/raycast/extensions/hidemyemail/list-emails.js:24747:12)\n    at Unzip.handleStreamEnd (/Users/pernielsentikaer/.config/raycast/extensions/hidemyemail/list-emails.js:25614:11)\n    at Unzip.emit (node:events:531:35)\n    at Unzip.emit (node:domain:488:12)\n    at endReadableNT (node:internal/streams/readable:1696:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)",
  "config": {
    "transitional": {
      "silentJSONParsing": true,
      "forcedJSONParsing": true,
      "clarifyTimeoutError": false
    },
    "adapter": [
      "xhr",
      "http",
      "fetch"
    ],
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "timeout": 10000,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": -1,
   <…>
10:01:16.502 ------- ----- -------
10:01:16.502 Invalid authentication token, will log in from scratch.
10:01:53.406 ------- Error -------
10:01:53.406 ------- Request -------
10:01:53.407 Request URL: https://p121-maildomainws.icloud.com:443/v2/hme/list
10:01:53.407 Request Headers:
10:01:53.407 Accept: application/json, text/plain, */*
10:01:53.407 Content-Type: undefined
10:01:53.407 Origin: https://www.icloud.com
10:01:53.407 Referer: https://www.icloud.com/
10:01:53.407 User-Agent: axios/1.7.7
10:01:53.407 Accept-Encoding: gzip, compress, deflate, br
10:01:53.407 ------- Response -------
10:01:53.407 Status:  401
10:01:53.408 StatusText:  Unauthorized
10:01:53.408 Data:  { reason: 'Missing X-APPLE-WEBAUTH-USER cookie', error: 1 }
10:01:53.408 {
  "message": "Request failed with status code 401",
  "name": "AxiosError",
  "stack": "AxiosError: Request failed with status code 401\n    at settle (/Users/pernielsentikaer/.config/raycast/extensions/hidemyemail/list-emails.js:24747:12)\n    at IncomingMessage.handleStreamEnd (/Users/pernielsentikaer/.config/raycast/extensions/hidemyemail/list-emails.js:25614:11)\n    at IncomingMessage.emit (node:events:531:35)\n    at IncomingMessage.emit (node:domain:488:12)\n    at endReadableNT (node:internal/streams/readable:1696:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)",
  "config": {
    "transitional": {
      "silentJSONParsing": true,
      "forcedJSONParsing": true,
      "clarifyTimeoutError": false
    },
    "adapter": [
      "xhr",
      "http",
      "fetch"
    ],
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "timeout": 10000,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
 <…>
10:01:53.408 ------- ----- -------
10:01:57.724 ------- Error -------
10:01:57.724 ------- Request -------
10:01:57.724 Request URL: https://setup.icloud.com/setup/ws/1/validate
10:01:57.724 Request Headers:
10:01:57.724 Accept: application/json, text/plain, */*
10:01:57.725 Content-Type: application/x-www-form-urlencoded
10:01:57.725 Origin: https://www.icloud.com
10:01:57.725 Referer: https://www.icloud.com/
10:01:57.725 User-Agent: axios/1.7.7
10:01:57.725 Accept-Encoding: gzip, compress, deflate, br
10:01:57.725 ------- Response -------
10:01:57.725 Status:  421
10:01:57.730 StatusText:  Misdirected Request
10:01:57.731 Data:  {
  success: false,
  requestInfo: [ { country: 'DK', timeZone: 'GMT+1' } ],
  configBag: {
    urls: {
      accountCreateUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9d9d1a815d#!create',
      accountVerifyUI: 'https://id.apple.com/identity?widgetKey=d39ba9d9d1a815d',
      accountLoginUI: 'https://idmsa.apple.com/appleauth/auth/signin?widgetKey=d39ba9d9d1a815d',
      accountLogin: 'https://setup.icloud.com/setup/ws/1/accountLogin',
      accountRepairUI: 'https://appleid.apple.com/widget/account/?widgetKey=d39ba9d9d1a815d#!repair',
      downloadICloudTerms: 'https://setup.icloud.com/setup/ws/1/downloadLiteTerms',
      repairDone: 'https://setup.icloud.com/setup/ws/1/repairDone',
      accountAuthorizeUI: 'https://idmsa.apple.com/appleauth/auth/authorize/signin?client_id=d39ba991<…>
10:01:57.732 {
  "message": "Request failed with status code 421",
  "name": "AxiosError",
  "stack": "AxiosError: Request failed with status code 421\n    at settle (/Users/pernielsentikaer/.config/raycast/extensions/hidemyemail/list-emails.js:24747:12)\n    at Unzip.handleStreamEnd (/Users/pernielsentikaer/.config/raycast/extensions/hidemyemail/list-emails.js:25614:11)\n    at Unzip.emit (node:events:531:35)\n    at Unzip.emit (node:domain:488:12)\n    at endReadableNT (node:internal/streams/readable:1696:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)",
  "config": {
    "transitional": {
      "silentJSONParsing": true,
      "forcedJSONParsing": true,
      "clarifyTimeoutError": false
    },
    "adapter": [
      "xhr",
      "http",
      "fetch"
    ],
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "timeout": 10000,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": -1,
   <…>
10:01:57.732 ------- ----- -------
  event -  stopped development mode
  ~/tmp/raycast-tmp-extension/hidemyemail ❯               

@svenhofman
Copy link
Contributor Author

svenhofman commented Jan 3, 2025

Could you replace the function on line 93 in connect.ts with the function below (keeping the withCredentials: true). Then clear local storage&cache and log in, close command and open it again and show the full logs of all these actions? You may need to obfuscate some of the data (you could also send it via Slack chat if you prefer)

I'm sorry for the many requests, I'm new to such problems and trying to figure out how to debug it.

this.instance.interceptors.response.use(
      (response) => {
        console.log("------- Response -------");
        console.log("Status: ", response.status);
        console.log("StatusText: ", response.statusText);
        console.log("Response Headers:");
        for (const key in response.headers) {
          if (key === "set-cookie") {
            for (const cookieKey in response.headers[key]) {
              console.log('\t\t' + response.headers[key][cookieKey]);
            }
          } else {
            console.log(`\t${key}: ${response.headers[key]}`);
          }
        }
        console.log("Data: ", response.data);
        console.log("------- --------- -------");
        return response;
      },
      (error) => {
        console.log("------- Error -------");
        console.log("------- Request -------");
        console.log("Request URL:", error.config.url);
        console.log("Request Headers:");
        for (const key in error.config.headers) {
          console.log(`${key}: ${error.config.headers[key]}`);
        }
        console.log("------- Response -------");
        const response = error?.response;
        if (response) {
          console.log("Status: ", response.status);
          console.log("StatusText: ", response.statusText);
          console.log("Response Headers:");
          for (const key in error.response.headers) {
            if (key === "set-cookie") {
              for (const cookieKey in error.response.headers[key]) {
                console.log('\t\t' + error.response.headers[key][cookieKey]);
              }
            } else {
              console.log(`\t${key}: ${error.response.headers[key]}`);
            }
          }
          console.log("Data: ", response.data);
        } else {
          console.log("error.code: ", error.code);
          console.log("error.message: ", error.message);
        }
        console.log("------- ----- -------\n\n");

        return Promise.reject(error);
      },
    );

@pernielsentikaer
Copy link
Collaborator

Can you ping me in Slack :)

@pernielsentikaer
Copy link
Collaborator

MWE1: Confirmed and will be in the next release

MWE2: Confirmed, we're looking into a fix 🙂

@pernielsentikaer pernielsentikaer added the Dont close Won't be closed by stalebot label Jan 7, 2025
@pernielsentikaer pernielsentikaer self-assigned this Jan 7, 2025
Copy link
Collaborator

@pernielsentikaer pernielsentikaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi 👋

Looks good to me, approved 🔥

@raycastbot raycastbot merged commit 741bade into raycast:main Jan 10, 2025
2 checks passed
Copy link
Contributor

Published to the Raycast Store:
https://raycast.com/svenhofman/hidemyemail

@raycastbot
Copy link
Collaborator

🎉 🎉 🎉

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dont close Won't be closed by stalebot extension fix / improvement Label for PRs with extension's fix improvements extension: hidemyemail Issues related to the hidemyemail extension OP is author The OP of the PR is the author of the extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants