integrate-sdk 0.9.43-dev.0 → 0.9.44-dev.0
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.
- package/dist/adapters/auto-routes.js +242 -79
- package/dist/adapters/base-handler.js +242 -79
- package/dist/adapters/index.js +242 -79
- package/dist/adapters/nextjs.js +242 -79
- package/dist/adapters/solid-start.js +242 -79
- package/dist/adapters/svelte-kit.js +242 -79
- package/dist/index.js +241 -78
- package/dist/oauth.js +242 -79
- package/dist/server.js +242 -79
- package/dist/src/oauth/email-fetcher.d.ts +17 -6
- package/dist/src/oauth/email-fetcher.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -740,104 +740,267 @@ var init_logger = __esm(() => {
|
|
|
740
740
|
|
|
741
741
|
// ../oauth/email-fetcher.ts
|
|
742
742
|
async function fetchUserEmail(provider, tokenData) {
|
|
743
|
+
const fetcher = EMAIL_FETCHERS[provider.toLowerCase()];
|
|
744
|
+
if (!fetcher) {
|
|
745
|
+
return tokenData.email;
|
|
746
|
+
}
|
|
743
747
|
try {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
return await fetchGitHubEmail(tokenData.accessToken);
|
|
747
|
-
case "gmail":
|
|
748
|
-
case "google":
|
|
749
|
-
return await fetchGoogleEmail(tokenData.accessToken);
|
|
750
|
-
case "notion":
|
|
751
|
-
return await fetchNotionEmail(tokenData.accessToken);
|
|
752
|
-
default:
|
|
753
|
-
return tokenData.email;
|
|
754
|
-
}
|
|
748
|
+
const email = await fetcher(tokenData);
|
|
749
|
+
return email ?? tokenData.email;
|
|
755
750
|
} catch (error) {
|
|
756
751
|
logger.error(`Failed to fetch email for ${provider}:`, error);
|
|
757
|
-
return;
|
|
752
|
+
return tokenData.email;
|
|
758
753
|
}
|
|
759
754
|
}
|
|
760
|
-
async function fetchGitHubEmail(
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
755
|
+
async function fetchGitHubEmail(token) {
|
|
756
|
+
const headers = {
|
|
757
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
758
|
+
Accept: "application/vnd.github.v3+json"
|
|
759
|
+
};
|
|
760
|
+
const userResponse = await fetch("https://api.github.com/user", { headers });
|
|
761
|
+
if (!userResponse.ok)
|
|
762
|
+
return;
|
|
763
|
+
const user = await userResponse.json();
|
|
764
|
+
if (user.email)
|
|
765
|
+
return user.email;
|
|
766
|
+
const emailsResponse = await fetch("https://api.github.com/user/emails", { headers });
|
|
767
|
+
if (!emailsResponse.ok)
|
|
768
|
+
return;
|
|
769
|
+
const emails = await emailsResponse.json();
|
|
770
|
+
const primary = emails.find((e) => e.primary && e.verified);
|
|
771
|
+
if (primary)
|
|
772
|
+
return primary.email;
|
|
773
|
+
const verified = emails.find((e) => e.verified);
|
|
774
|
+
if (verified)
|
|
775
|
+
return verified.email;
|
|
776
|
+
return emails[0]?.email;
|
|
777
|
+
}
|
|
778
|
+
async function fetchGoogleEmail(token) {
|
|
779
|
+
const response = await fetch("https://www.googleapis.com/oauth2/v2/userinfo", {
|
|
780
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
781
|
+
});
|
|
782
|
+
if (!response.ok)
|
|
783
|
+
return;
|
|
784
|
+
const user = await response.json();
|
|
785
|
+
return user.email;
|
|
786
|
+
}
|
|
787
|
+
async function fetchNotionEmail(token) {
|
|
788
|
+
const response = await fetch("https://api.notion.com/v1/users/me", {
|
|
789
|
+
headers: {
|
|
790
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
791
|
+
"Notion-Version": "2022-06-28"
|
|
788
792
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
793
|
+
});
|
|
794
|
+
if (!response.ok)
|
|
795
|
+
return;
|
|
796
|
+
const user = await response.json();
|
|
797
|
+
return user.person?.email ?? user.bot?.owner?.user?.person?.email;
|
|
798
|
+
}
|
|
799
|
+
async function fetchLinearEmail(token) {
|
|
800
|
+
const response = await fetch("https://api.linear.app/graphql", {
|
|
801
|
+
method: "POST",
|
|
802
|
+
headers: {
|
|
803
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
804
|
+
"Content-Type": "application/json"
|
|
805
|
+
},
|
|
806
|
+
body: JSON.stringify({ query: "{ viewer { email } }" })
|
|
807
|
+
});
|
|
808
|
+
if (!response.ok)
|
|
809
|
+
return;
|
|
810
|
+
const body = await response.json();
|
|
811
|
+
return body.data?.viewer?.email;
|
|
812
|
+
}
|
|
813
|
+
async function fetchHubSpotEmail(token) {
|
|
814
|
+
const url = `https://api.hubapi.com/oauth/v1/access-tokens/${encodeURIComponent(token.accessToken)}`;
|
|
815
|
+
const response = await fetch(url);
|
|
816
|
+
if (!response.ok)
|
|
817
|
+
return;
|
|
818
|
+
const body = await response.json();
|
|
819
|
+
return body.user;
|
|
820
|
+
}
|
|
821
|
+
async function fetchPolarEmail(token) {
|
|
822
|
+
const response = await fetch("https://api.polar.sh/v1/oauth2/userinfo", {
|
|
823
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
824
|
+
});
|
|
825
|
+
if (!response.ok)
|
|
826
|
+
return;
|
|
827
|
+
const body = await response.json();
|
|
828
|
+
return body.email;
|
|
829
|
+
}
|
|
830
|
+
async function fetchTodoistEmail(token) {
|
|
831
|
+
const response = await fetch("https://api.todoist.com/sync/v9/sync", {
|
|
832
|
+
method: "POST",
|
|
833
|
+
headers: {
|
|
834
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
835
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
836
|
+
},
|
|
837
|
+
body: 'sync_token=*&resource_types=["user"]'
|
|
838
|
+
});
|
|
839
|
+
if (!response.ok)
|
|
840
|
+
return;
|
|
841
|
+
const body = await response.json();
|
|
842
|
+
return body.user?.email;
|
|
843
|
+
}
|
|
844
|
+
async function fetchVercelEmail(token) {
|
|
845
|
+
const response = await fetch("https://api.vercel.com/v2/user", {
|
|
846
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
847
|
+
});
|
|
848
|
+
if (!response.ok)
|
|
849
|
+
return;
|
|
850
|
+
const body = await response.json();
|
|
851
|
+
return body.user?.email ?? body.email;
|
|
852
|
+
}
|
|
853
|
+
async function fetchSlackEmail(token) {
|
|
854
|
+
const response = await fetch("https://slack.com/api/users.identity", {
|
|
855
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
856
|
+
});
|
|
857
|
+
if (!response.ok)
|
|
858
|
+
return;
|
|
859
|
+
const body = await response.json();
|
|
860
|
+
if (!body.ok)
|
|
861
|
+
return;
|
|
862
|
+
return body.user?.email;
|
|
863
|
+
}
|
|
864
|
+
async function fetchIntercomEmail(token) {
|
|
865
|
+
const response = await fetch("https://api.intercom.io/me", {
|
|
866
|
+
headers: {
|
|
867
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
868
|
+
Accept: "application/json"
|
|
792
869
|
}
|
|
793
|
-
|
|
794
|
-
|
|
870
|
+
});
|
|
871
|
+
if (!response.ok)
|
|
872
|
+
return;
|
|
873
|
+
const body = await response.json();
|
|
874
|
+
return body.email;
|
|
875
|
+
}
|
|
876
|
+
async function fetchAtlassianEmail(token) {
|
|
877
|
+
const response = await fetch("https://api.atlassian.com/me", {
|
|
878
|
+
headers: {
|
|
879
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
880
|
+
Accept: "application/json"
|
|
795
881
|
}
|
|
882
|
+
});
|
|
883
|
+
if (!response.ok)
|
|
796
884
|
return;
|
|
797
|
-
|
|
798
|
-
|
|
885
|
+
const body = await response.json();
|
|
886
|
+
return body.email;
|
|
887
|
+
}
|
|
888
|
+
async function fetchZendeskEmail(token) {
|
|
889
|
+
const subdomain = token.providerConfig?.subdomain?.trim();
|
|
890
|
+
if (!subdomain)
|
|
799
891
|
return;
|
|
800
|
-
}
|
|
892
|
+
const response = await fetch(`https://${subdomain}.zendesk.com/api/v2/users/me.json`, {
|
|
893
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
894
|
+
});
|
|
895
|
+
if (!response.ok)
|
|
896
|
+
return;
|
|
897
|
+
const body = await response.json();
|
|
898
|
+
return body.user?.email;
|
|
801
899
|
}
|
|
802
|
-
async function
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
if (!response.ok) {
|
|
810
|
-
return;
|
|
811
|
-
}
|
|
812
|
-
const user = await response.json();
|
|
813
|
-
return user.email;
|
|
814
|
-
} catch (error) {
|
|
815
|
-
logger.error("Failed to fetch Google email:", error);
|
|
900
|
+
async function fetchAirtableEmail(token) {
|
|
901
|
+
const response = await fetch("https://api.airtable.com/v0/meta/whoami", {
|
|
902
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
903
|
+
});
|
|
904
|
+
if (!response.ok)
|
|
816
905
|
return;
|
|
817
|
-
|
|
906
|
+
const body = await response.json();
|
|
907
|
+
return body.email;
|
|
818
908
|
}
|
|
819
|
-
async function
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
909
|
+
async function fetchDiscordEmail(token) {
|
|
910
|
+
const response = await fetch("https://discord.com/api/users/@me", {
|
|
911
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
912
|
+
});
|
|
913
|
+
if (!response.ok)
|
|
914
|
+
return;
|
|
915
|
+
const body = await response.json();
|
|
916
|
+
return body.email;
|
|
917
|
+
}
|
|
918
|
+
async function fetchDropboxEmail(token) {
|
|
919
|
+
const response = await fetch("https://api.dropboxapi.com/2/users/get_current_account", {
|
|
920
|
+
method: "POST",
|
|
921
|
+
headers: {
|
|
922
|
+
Authorization: `Bearer ${token.accessToken}`
|
|
923
|
+
},
|
|
924
|
+
body: "null"
|
|
925
|
+
});
|
|
926
|
+
if (!response.ok)
|
|
927
|
+
return;
|
|
928
|
+
const body = await response.json();
|
|
929
|
+
return body.email;
|
|
930
|
+
}
|
|
931
|
+
async function fetchGitLabEmail(token) {
|
|
932
|
+
const response = await fetch("https://gitlab.com/api/v4/user", {
|
|
933
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
934
|
+
});
|
|
935
|
+
if (!response.ok)
|
|
936
|
+
return;
|
|
937
|
+
const body = await response.json();
|
|
938
|
+
return body.email;
|
|
939
|
+
}
|
|
940
|
+
async function fetchRedditEmail(token) {
|
|
941
|
+
const response = await fetch("https://oauth.reddit.com/api/v1/me", {
|
|
942
|
+
headers: {
|
|
943
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
944
|
+
"User-Agent": "integrate-sdk"
|
|
829
945
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
} catch (error) {
|
|
833
|
-
logger.error("Failed to fetch Notion email:", error);
|
|
946
|
+
});
|
|
947
|
+
if (!response.ok)
|
|
834
948
|
return;
|
|
835
|
-
|
|
949
|
+
const body = await response.json();
|
|
950
|
+
return body.name;
|
|
836
951
|
}
|
|
837
|
-
|
|
952
|
+
async function fetchMicrosoftEmail(token) {
|
|
953
|
+
const response = await fetch("https://graph.microsoft.com/v1.0/me", {
|
|
954
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
955
|
+
});
|
|
956
|
+
if (!response.ok)
|
|
957
|
+
return;
|
|
958
|
+
const body = await response.json();
|
|
959
|
+
return body.mail ?? body.userPrincipalName;
|
|
960
|
+
}
|
|
961
|
+
var logger, EMAIL_FETCHERS;
|
|
838
962
|
var init_email_fetcher = __esm(() => {
|
|
839
963
|
init_logger();
|
|
840
964
|
logger = createLogger("EmailFetcher");
|
|
965
|
+
EMAIL_FETCHERS = {
|
|
966
|
+
github: fetchGitHubEmail,
|
|
967
|
+
gmail: fetchGoogleEmail,
|
|
968
|
+
google: fetchGoogleEmail,
|
|
969
|
+
gcal: fetchGoogleEmail,
|
|
970
|
+
gdrive: fetchGoogleEmail,
|
|
971
|
+
gdocs: fetchGoogleEmail,
|
|
972
|
+
gsheets: fetchGoogleEmail,
|
|
973
|
+
gslides: fetchGoogleEmail,
|
|
974
|
+
gcontacts: fetchGoogleEmail,
|
|
975
|
+
gmeet: fetchGoogleEmail,
|
|
976
|
+
gchat: fetchGoogleEmail,
|
|
977
|
+
gtasks: fetchGoogleEmail,
|
|
978
|
+
ga4: fetchGoogleEmail,
|
|
979
|
+
youtube: fetchGoogleEmail,
|
|
980
|
+
notion: fetchNotionEmail,
|
|
981
|
+
linear: fetchLinearEmail,
|
|
982
|
+
hubspot: fetchHubSpotEmail,
|
|
983
|
+
polar: fetchPolarEmail,
|
|
984
|
+
todoist: fetchTodoistEmail,
|
|
985
|
+
vercel: fetchVercelEmail,
|
|
986
|
+
slack: fetchSlackEmail,
|
|
987
|
+
intercom: fetchIntercomEmail,
|
|
988
|
+
jira: fetchAtlassianEmail,
|
|
989
|
+
zendesk: fetchZendeskEmail,
|
|
990
|
+
airtable: fetchAirtableEmail,
|
|
991
|
+
discord: fetchDiscordEmail,
|
|
992
|
+
dropbox: fetchDropboxEmail,
|
|
993
|
+
gitlab: fetchGitLabEmail,
|
|
994
|
+
reddit: fetchRedditEmail,
|
|
995
|
+
outlook: fetchMicrosoftEmail,
|
|
996
|
+
teams: fetchMicrosoftEmail,
|
|
997
|
+
onedrive: fetchMicrosoftEmail,
|
|
998
|
+
sharepoint: fetchMicrosoftEmail,
|
|
999
|
+
excel: fetchMicrosoftEmail,
|
|
1000
|
+
word: fetchMicrosoftEmail,
|
|
1001
|
+
powerpoint: fetchMicrosoftEmail,
|
|
1002
|
+
planner: fetchMicrosoftEmail
|
|
1003
|
+
};
|
|
841
1004
|
});
|
|
842
1005
|
|
|
843
1006
|
// base-handler.ts
|
package/dist/index.js
CHANGED
|
@@ -1671,100 +1671,263 @@ class IndexedDBStorage {
|
|
|
1671
1671
|
|
|
1672
1672
|
// src/oauth/email-fetcher.ts
|
|
1673
1673
|
var logger3 = createLogger("EmailFetcher");
|
|
1674
|
+
var EMAIL_FETCHERS = {
|
|
1675
|
+
github: fetchGitHubEmail,
|
|
1676
|
+
gmail: fetchGoogleEmail,
|
|
1677
|
+
google: fetchGoogleEmail,
|
|
1678
|
+
gcal: fetchGoogleEmail,
|
|
1679
|
+
gdrive: fetchGoogleEmail,
|
|
1680
|
+
gdocs: fetchGoogleEmail,
|
|
1681
|
+
gsheets: fetchGoogleEmail,
|
|
1682
|
+
gslides: fetchGoogleEmail,
|
|
1683
|
+
gcontacts: fetchGoogleEmail,
|
|
1684
|
+
gmeet: fetchGoogleEmail,
|
|
1685
|
+
gchat: fetchGoogleEmail,
|
|
1686
|
+
gtasks: fetchGoogleEmail,
|
|
1687
|
+
ga4: fetchGoogleEmail,
|
|
1688
|
+
youtube: fetchGoogleEmail,
|
|
1689
|
+
notion: fetchNotionEmail,
|
|
1690
|
+
linear: fetchLinearEmail,
|
|
1691
|
+
hubspot: fetchHubSpotEmail,
|
|
1692
|
+
polar: fetchPolarEmail,
|
|
1693
|
+
todoist: fetchTodoistEmail,
|
|
1694
|
+
vercel: fetchVercelEmail,
|
|
1695
|
+
slack: fetchSlackEmail,
|
|
1696
|
+
intercom: fetchIntercomEmail,
|
|
1697
|
+
jira: fetchAtlassianEmail,
|
|
1698
|
+
zendesk: fetchZendeskEmail,
|
|
1699
|
+
airtable: fetchAirtableEmail,
|
|
1700
|
+
discord: fetchDiscordEmail,
|
|
1701
|
+
dropbox: fetchDropboxEmail,
|
|
1702
|
+
gitlab: fetchGitLabEmail,
|
|
1703
|
+
reddit: fetchRedditEmail,
|
|
1704
|
+
outlook: fetchMicrosoftEmail,
|
|
1705
|
+
teams: fetchMicrosoftEmail,
|
|
1706
|
+
onedrive: fetchMicrosoftEmail,
|
|
1707
|
+
sharepoint: fetchMicrosoftEmail,
|
|
1708
|
+
excel: fetchMicrosoftEmail,
|
|
1709
|
+
word: fetchMicrosoftEmail,
|
|
1710
|
+
powerpoint: fetchMicrosoftEmail,
|
|
1711
|
+
planner: fetchMicrosoftEmail
|
|
1712
|
+
};
|
|
1674
1713
|
async function fetchUserEmail(provider, tokenData) {
|
|
1714
|
+
const fetcher = EMAIL_FETCHERS[provider.toLowerCase()];
|
|
1715
|
+
if (!fetcher) {
|
|
1716
|
+
return tokenData.email;
|
|
1717
|
+
}
|
|
1675
1718
|
try {
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
return await fetchGitHubEmail(tokenData.accessToken);
|
|
1679
|
-
case "gmail":
|
|
1680
|
-
case "google":
|
|
1681
|
-
return await fetchGoogleEmail(tokenData.accessToken);
|
|
1682
|
-
case "notion":
|
|
1683
|
-
return await fetchNotionEmail(tokenData.accessToken);
|
|
1684
|
-
default:
|
|
1685
|
-
return tokenData.email;
|
|
1686
|
-
}
|
|
1719
|
+
const email = await fetcher(tokenData);
|
|
1720
|
+
return email ?? tokenData.email;
|
|
1687
1721
|
} catch (error) {
|
|
1688
1722
|
logger3.error(`Failed to fetch email for ${provider}:`, error);
|
|
1689
|
-
return;
|
|
1723
|
+
return tokenData.email;
|
|
1690
1724
|
}
|
|
1691
1725
|
}
|
|
1692
|
-
async function fetchGitHubEmail(
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1726
|
+
async function fetchGitHubEmail(token) {
|
|
1727
|
+
const headers = {
|
|
1728
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
1729
|
+
Accept: "application/vnd.github.v3+json"
|
|
1730
|
+
};
|
|
1731
|
+
const userResponse = await fetch("https://api.github.com/user", { headers });
|
|
1732
|
+
if (!userResponse.ok)
|
|
1733
|
+
return;
|
|
1734
|
+
const user = await userResponse.json();
|
|
1735
|
+
if (user.email)
|
|
1736
|
+
return user.email;
|
|
1737
|
+
const emailsResponse = await fetch("https://api.github.com/user/emails", { headers });
|
|
1738
|
+
if (!emailsResponse.ok)
|
|
1739
|
+
return;
|
|
1740
|
+
const emails = await emailsResponse.json();
|
|
1741
|
+
const primary = emails.find((e) => e.primary && e.verified);
|
|
1742
|
+
if (primary)
|
|
1743
|
+
return primary.email;
|
|
1744
|
+
const verified = emails.find((e) => e.verified);
|
|
1745
|
+
if (verified)
|
|
1746
|
+
return verified.email;
|
|
1747
|
+
return emails[0]?.email;
|
|
1748
|
+
}
|
|
1749
|
+
async function fetchGoogleEmail(token) {
|
|
1750
|
+
const response = await fetch("https://www.googleapis.com/oauth2/v2/userinfo", {
|
|
1751
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
1752
|
+
});
|
|
1753
|
+
if (!response.ok)
|
|
1754
|
+
return;
|
|
1755
|
+
const user = await response.json();
|
|
1756
|
+
return user.email;
|
|
1757
|
+
}
|
|
1758
|
+
async function fetchNotionEmail(token) {
|
|
1759
|
+
const response = await fetch("https://api.notion.com/v1/users/me", {
|
|
1760
|
+
headers: {
|
|
1761
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
1762
|
+
"Notion-Version": "2022-06-28"
|
|
1720
1763
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1764
|
+
});
|
|
1765
|
+
if (!response.ok)
|
|
1766
|
+
return;
|
|
1767
|
+
const user = await response.json();
|
|
1768
|
+
return user.person?.email ?? user.bot?.owner?.user?.person?.email;
|
|
1769
|
+
}
|
|
1770
|
+
async function fetchLinearEmail(token) {
|
|
1771
|
+
const response = await fetch("https://api.linear.app/graphql", {
|
|
1772
|
+
method: "POST",
|
|
1773
|
+
headers: {
|
|
1774
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
1775
|
+
"Content-Type": "application/json"
|
|
1776
|
+
},
|
|
1777
|
+
body: JSON.stringify({ query: "{ viewer { email } }" })
|
|
1778
|
+
});
|
|
1779
|
+
if (!response.ok)
|
|
1780
|
+
return;
|
|
1781
|
+
const body = await response.json();
|
|
1782
|
+
return body.data?.viewer?.email;
|
|
1783
|
+
}
|
|
1784
|
+
async function fetchHubSpotEmail(token) {
|
|
1785
|
+
const url = `https://api.hubapi.com/oauth/v1/access-tokens/${encodeURIComponent(token.accessToken)}`;
|
|
1786
|
+
const response = await fetch(url);
|
|
1787
|
+
if (!response.ok)
|
|
1788
|
+
return;
|
|
1789
|
+
const body = await response.json();
|
|
1790
|
+
return body.user;
|
|
1791
|
+
}
|
|
1792
|
+
async function fetchPolarEmail(token) {
|
|
1793
|
+
const response = await fetch("https://api.polar.sh/v1/oauth2/userinfo", {
|
|
1794
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
1795
|
+
});
|
|
1796
|
+
if (!response.ok)
|
|
1797
|
+
return;
|
|
1798
|
+
const body = await response.json();
|
|
1799
|
+
return body.email;
|
|
1800
|
+
}
|
|
1801
|
+
async function fetchTodoistEmail(token) {
|
|
1802
|
+
const response = await fetch("https://api.todoist.com/sync/v9/sync", {
|
|
1803
|
+
method: "POST",
|
|
1804
|
+
headers: {
|
|
1805
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
1806
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1807
|
+
},
|
|
1808
|
+
body: 'sync_token=*&resource_types=["user"]'
|
|
1809
|
+
});
|
|
1810
|
+
if (!response.ok)
|
|
1811
|
+
return;
|
|
1812
|
+
const body = await response.json();
|
|
1813
|
+
return body.user?.email;
|
|
1814
|
+
}
|
|
1815
|
+
async function fetchVercelEmail(token) {
|
|
1816
|
+
const response = await fetch("https://api.vercel.com/v2/user", {
|
|
1817
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
1818
|
+
});
|
|
1819
|
+
if (!response.ok)
|
|
1820
|
+
return;
|
|
1821
|
+
const body = await response.json();
|
|
1822
|
+
return body.user?.email ?? body.email;
|
|
1823
|
+
}
|
|
1824
|
+
async function fetchSlackEmail(token) {
|
|
1825
|
+
const response = await fetch("https://slack.com/api/users.identity", {
|
|
1826
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
1827
|
+
});
|
|
1828
|
+
if (!response.ok)
|
|
1829
|
+
return;
|
|
1830
|
+
const body = await response.json();
|
|
1831
|
+
if (!body.ok)
|
|
1832
|
+
return;
|
|
1833
|
+
return body.user?.email;
|
|
1834
|
+
}
|
|
1835
|
+
async function fetchIntercomEmail(token) {
|
|
1836
|
+
const response = await fetch("https://api.intercom.io/me", {
|
|
1837
|
+
headers: {
|
|
1838
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
1839
|
+
Accept: "application/json"
|
|
1724
1840
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1841
|
+
});
|
|
1842
|
+
if (!response.ok)
|
|
1843
|
+
return;
|
|
1844
|
+
const body = await response.json();
|
|
1845
|
+
return body.email;
|
|
1846
|
+
}
|
|
1847
|
+
async function fetchAtlassianEmail(token) {
|
|
1848
|
+
const response = await fetch("https://api.atlassian.com/me", {
|
|
1849
|
+
headers: {
|
|
1850
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
1851
|
+
Accept: "application/json"
|
|
1727
1852
|
}
|
|
1853
|
+
});
|
|
1854
|
+
if (!response.ok)
|
|
1728
1855
|
return;
|
|
1729
|
-
|
|
1730
|
-
|
|
1856
|
+
const body = await response.json();
|
|
1857
|
+
return body.email;
|
|
1858
|
+
}
|
|
1859
|
+
async function fetchZendeskEmail(token) {
|
|
1860
|
+
const subdomain = token.providerConfig?.subdomain?.trim();
|
|
1861
|
+
if (!subdomain)
|
|
1731
1862
|
return;
|
|
1732
|
-
}
|
|
1863
|
+
const response = await fetch(`https://${subdomain}.zendesk.com/api/v2/users/me.json`, {
|
|
1864
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
1865
|
+
});
|
|
1866
|
+
if (!response.ok)
|
|
1867
|
+
return;
|
|
1868
|
+
const body = await response.json();
|
|
1869
|
+
return body.user?.email;
|
|
1733
1870
|
}
|
|
1734
|
-
async function
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
}
|
|
1740
|
-
});
|
|
1741
|
-
if (!response.ok) {
|
|
1742
|
-
return;
|
|
1743
|
-
}
|
|
1744
|
-
const user = await response.json();
|
|
1745
|
-
return user.email;
|
|
1746
|
-
} catch (error) {
|
|
1747
|
-
logger3.error("Failed to fetch Google email:", error);
|
|
1871
|
+
async function fetchAirtableEmail(token) {
|
|
1872
|
+
const response = await fetch("https://api.airtable.com/v0/meta/whoami", {
|
|
1873
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
1874
|
+
});
|
|
1875
|
+
if (!response.ok)
|
|
1748
1876
|
return;
|
|
1749
|
-
|
|
1877
|
+
const body = await response.json();
|
|
1878
|
+
return body.email;
|
|
1750
1879
|
}
|
|
1751
|
-
async function
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1880
|
+
async function fetchDiscordEmail(token) {
|
|
1881
|
+
const response = await fetch("https://discord.com/api/users/@me", {
|
|
1882
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
1883
|
+
});
|
|
1884
|
+
if (!response.ok)
|
|
1885
|
+
return;
|
|
1886
|
+
const body = await response.json();
|
|
1887
|
+
return body.email;
|
|
1888
|
+
}
|
|
1889
|
+
async function fetchDropboxEmail(token) {
|
|
1890
|
+
const response = await fetch("https://api.dropboxapi.com/2/users/get_current_account", {
|
|
1891
|
+
method: "POST",
|
|
1892
|
+
headers: {
|
|
1893
|
+
Authorization: `Bearer ${token.accessToken}`
|
|
1894
|
+
},
|
|
1895
|
+
body: "null"
|
|
1896
|
+
});
|
|
1897
|
+
if (!response.ok)
|
|
1898
|
+
return;
|
|
1899
|
+
const body = await response.json();
|
|
1900
|
+
return body.email;
|
|
1901
|
+
}
|
|
1902
|
+
async function fetchGitLabEmail(token) {
|
|
1903
|
+
const response = await fetch("https://gitlab.com/api/v4/user", {
|
|
1904
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
1905
|
+
});
|
|
1906
|
+
if (!response.ok)
|
|
1907
|
+
return;
|
|
1908
|
+
const body = await response.json();
|
|
1909
|
+
return body.email;
|
|
1910
|
+
}
|
|
1911
|
+
async function fetchRedditEmail(token) {
|
|
1912
|
+
const response = await fetch("https://oauth.reddit.com/api/v1/me", {
|
|
1913
|
+
headers: {
|
|
1914
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
1915
|
+
"User-Agent": "integrate-sdk"
|
|
1761
1916
|
}
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
} catch (error) {
|
|
1765
|
-
logger3.error("Failed to fetch Notion email:", error);
|
|
1917
|
+
});
|
|
1918
|
+
if (!response.ok)
|
|
1766
1919
|
return;
|
|
1767
|
-
|
|
1920
|
+
const body = await response.json();
|
|
1921
|
+
return body.name;
|
|
1922
|
+
}
|
|
1923
|
+
async function fetchMicrosoftEmail(token) {
|
|
1924
|
+
const response = await fetch("https://graph.microsoft.com/v1.0/me", {
|
|
1925
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
1926
|
+
});
|
|
1927
|
+
if (!response.ok)
|
|
1928
|
+
return;
|
|
1929
|
+
const body = await response.json();
|
|
1930
|
+
return body.mail ?? body.userPrincipalName;
|
|
1768
1931
|
}
|
|
1769
1932
|
|
|
1770
1933
|
// src/oauth/refresh.ts
|