@bobfrankston/rmfmail 1.1.153 → 1.1.155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10210,8 +10210,25 @@ var OAUTH_CLIENT = {
10210
10210
  redirectUri: "com.googleusercontent.apps.884213380682-hcso64dcqmk4p98vsc7br2e6gvn7iv2u:/oauth2callback"
10211
10211
  };
10212
10212
  var OAUTH_SCOPES = "https://mail.google.com/ https://www.googleapis.com/auth/contacts.readonly https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/tasks";
10213
+ function canonEmail(email) {
10214
+ const s = (email || "").trim().toLowerCase();
10215
+ const at = s.indexOf("@");
10216
+ if (at < 0) return s;
10217
+ let local = s.slice(0, at);
10218
+ const domain = s.slice(at + 1);
10219
+ if (domain === "gmail.com" || domain === "googlemail.com") {
10220
+ const plus = local.indexOf("+");
10221
+ if (plus >= 0) local = local.slice(0, plus);
10222
+ local = local.replace(/\./g, "");
10223
+ return `${local}@gmail.com`;
10224
+ }
10225
+ return `${local}@${domain}`;
10226
+ }
10227
+ function tokenKey(email) {
10228
+ return `oauth-token-${canonEmail(email).replace(/[@.]/g, "_")}`;
10229
+ }
10213
10230
  async function getCachedToken(email) {
10214
- const key = `oauth-token-${email.replace(/[@.]/g, "_")}`;
10231
+ const key = tokenKey(email);
10215
10232
  const raw = localStorage.getItem(key);
10216
10233
  if (!raw) {
10217
10234
  console.log(`[oauth] no cached token for ${email} (localStorage key=${key} missing \u2014 fresh consent will follow)`);
@@ -10229,7 +10246,7 @@ async function getCachedToken(email) {
10229
10246
  }
10230
10247
  }
10231
10248
  async function setCachedToken(email, token) {
10232
- const key = `oauth-token-${email.replace(/[@.]/g, "_")}`;
10249
+ const key = tokenKey(email);
10233
10250
  localStorage.setItem(key, JSON.stringify(token));
10234
10251
  }
10235
10252
  async function exchangeCodeForTokens(code) {