integrate-sdk 0.9.43-dev.0 → 0.9.45-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 +243 -80
- package/dist/adapters/base-handler.js +243 -80
- package/dist/adapters/index.js +243 -80
- package/dist/adapters/nextjs.js +243 -80
- package/dist/adapters/solid-start.js +243 -80
- package/dist/adapters/svelte-kit.js +243 -80
- package/dist/index.js +249 -80
- package/dist/oauth.js +243 -80
- package/dist/server.js +250 -81
- package/dist/src/integrations/clickup.d.ts.map +1 -1
- package/dist/src/integrations/ga4.d.ts.map +1 -1
- package/dist/src/integrations/mailchimp.d.ts.map +1 -1
- package/dist/src/integrations/planetscale.d.ts.map +1 -1
- package/dist/src/integrations/planner.d.ts.map +1 -1
- package/dist/src/integrations/reddit.d.ts.map +1 -1
- 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
|
@@ -591,7 +591,7 @@ var init_library_metadata = __esm(() => {
|
|
|
591
591
|
category: "Finance"
|
|
592
592
|
},
|
|
593
593
|
ga4: {
|
|
594
|
-
description: "Read Google Analytics
|
|
594
|
+
description: "Read Google Analytics reports, properties, and events",
|
|
595
595
|
category: "Analytics"
|
|
596
596
|
},
|
|
597
597
|
gchat: {
|
|
@@ -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;
|
|
951
|
+
}
|
|
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;
|
|
836
960
|
}
|
|
837
|
-
var logger;
|
|
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
|