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
package/dist/oauth.js
CHANGED
|
@@ -334,7 +334,7 @@ var init_library_metadata = __esm(() => {
|
|
|
334
334
|
category: "Finance"
|
|
335
335
|
},
|
|
336
336
|
ga4: {
|
|
337
|
-
description: "Read Google Analytics
|
|
337
|
+
description: "Read Google Analytics reports, properties, and events",
|
|
338
338
|
category: "Analytics"
|
|
339
339
|
},
|
|
340
340
|
gchat: {
|
|
@@ -486,104 +486,267 @@ var init_logger = __esm(() => {
|
|
|
486
486
|
|
|
487
487
|
// src/oauth/email-fetcher.ts
|
|
488
488
|
async function fetchUserEmail(provider, tokenData) {
|
|
489
|
+
const fetcher = EMAIL_FETCHERS[provider.toLowerCase()];
|
|
490
|
+
if (!fetcher) {
|
|
491
|
+
return tokenData.email;
|
|
492
|
+
}
|
|
489
493
|
try {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
return await fetchGitHubEmail(tokenData.accessToken);
|
|
493
|
-
case "gmail":
|
|
494
|
-
case "google":
|
|
495
|
-
return await fetchGoogleEmail(tokenData.accessToken);
|
|
496
|
-
case "notion":
|
|
497
|
-
return await fetchNotionEmail(tokenData.accessToken);
|
|
498
|
-
default:
|
|
499
|
-
return tokenData.email;
|
|
500
|
-
}
|
|
494
|
+
const email = await fetcher(tokenData);
|
|
495
|
+
return email ?? tokenData.email;
|
|
501
496
|
} catch (error) {
|
|
502
497
|
logger.error(`Failed to fetch email for ${provider}:`, error);
|
|
503
|
-
return;
|
|
498
|
+
return tokenData.email;
|
|
504
499
|
}
|
|
505
500
|
}
|
|
506
|
-
async function fetchGitHubEmail(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
501
|
+
async function fetchGitHubEmail(token) {
|
|
502
|
+
const headers = {
|
|
503
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
504
|
+
Accept: "application/vnd.github.v3+json"
|
|
505
|
+
};
|
|
506
|
+
const userResponse = await fetch("https://api.github.com/user", { headers });
|
|
507
|
+
if (!userResponse.ok)
|
|
508
|
+
return;
|
|
509
|
+
const user = await userResponse.json();
|
|
510
|
+
if (user.email)
|
|
511
|
+
return user.email;
|
|
512
|
+
const emailsResponse = await fetch("https://api.github.com/user/emails", { headers });
|
|
513
|
+
if (!emailsResponse.ok)
|
|
514
|
+
return;
|
|
515
|
+
const emails = await emailsResponse.json();
|
|
516
|
+
const primary = emails.find((e) => e.primary && e.verified);
|
|
517
|
+
if (primary)
|
|
518
|
+
return primary.email;
|
|
519
|
+
const verified = emails.find((e) => e.verified);
|
|
520
|
+
if (verified)
|
|
521
|
+
return verified.email;
|
|
522
|
+
return emails[0]?.email;
|
|
523
|
+
}
|
|
524
|
+
async function fetchGoogleEmail(token) {
|
|
525
|
+
const response = await fetch("https://www.googleapis.com/oauth2/v2/userinfo", {
|
|
526
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
527
|
+
});
|
|
528
|
+
if (!response.ok)
|
|
529
|
+
return;
|
|
530
|
+
const user = await response.json();
|
|
531
|
+
return user.email;
|
|
532
|
+
}
|
|
533
|
+
async function fetchNotionEmail(token) {
|
|
534
|
+
const response = await fetch("https://api.notion.com/v1/users/me", {
|
|
535
|
+
headers: {
|
|
536
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
537
|
+
"Notion-Version": "2022-06-28"
|
|
534
538
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
539
|
+
});
|
|
540
|
+
if (!response.ok)
|
|
541
|
+
return;
|
|
542
|
+
const user = await response.json();
|
|
543
|
+
return user.person?.email ?? user.bot?.owner?.user?.person?.email;
|
|
544
|
+
}
|
|
545
|
+
async function fetchLinearEmail(token) {
|
|
546
|
+
const response = await fetch("https://api.linear.app/graphql", {
|
|
547
|
+
method: "POST",
|
|
548
|
+
headers: {
|
|
549
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
550
|
+
"Content-Type": "application/json"
|
|
551
|
+
},
|
|
552
|
+
body: JSON.stringify({ query: "{ viewer { email } }" })
|
|
553
|
+
});
|
|
554
|
+
if (!response.ok)
|
|
555
|
+
return;
|
|
556
|
+
const body = await response.json();
|
|
557
|
+
return body.data?.viewer?.email;
|
|
558
|
+
}
|
|
559
|
+
async function fetchHubSpotEmail(token) {
|
|
560
|
+
const url = `https://api.hubapi.com/oauth/v1/access-tokens/${encodeURIComponent(token.accessToken)}`;
|
|
561
|
+
const response = await fetch(url);
|
|
562
|
+
if (!response.ok)
|
|
563
|
+
return;
|
|
564
|
+
const body = await response.json();
|
|
565
|
+
return body.user;
|
|
566
|
+
}
|
|
567
|
+
async function fetchPolarEmail(token) {
|
|
568
|
+
const response = await fetch("https://api.polar.sh/v1/oauth2/userinfo", {
|
|
569
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
570
|
+
});
|
|
571
|
+
if (!response.ok)
|
|
572
|
+
return;
|
|
573
|
+
const body = await response.json();
|
|
574
|
+
return body.email;
|
|
575
|
+
}
|
|
576
|
+
async function fetchTodoistEmail(token) {
|
|
577
|
+
const response = await fetch("https://api.todoist.com/sync/v9/sync", {
|
|
578
|
+
method: "POST",
|
|
579
|
+
headers: {
|
|
580
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
581
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
582
|
+
},
|
|
583
|
+
body: 'sync_token=*&resource_types=["user"]'
|
|
584
|
+
});
|
|
585
|
+
if (!response.ok)
|
|
586
|
+
return;
|
|
587
|
+
const body = await response.json();
|
|
588
|
+
return body.user?.email;
|
|
589
|
+
}
|
|
590
|
+
async function fetchVercelEmail(token) {
|
|
591
|
+
const response = await fetch("https://api.vercel.com/v2/user", {
|
|
592
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
593
|
+
});
|
|
594
|
+
if (!response.ok)
|
|
595
|
+
return;
|
|
596
|
+
const body = await response.json();
|
|
597
|
+
return body.user?.email ?? body.email;
|
|
598
|
+
}
|
|
599
|
+
async function fetchSlackEmail(token) {
|
|
600
|
+
const response = await fetch("https://slack.com/api/users.identity", {
|
|
601
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
602
|
+
});
|
|
603
|
+
if (!response.ok)
|
|
604
|
+
return;
|
|
605
|
+
const body = await response.json();
|
|
606
|
+
if (!body.ok)
|
|
607
|
+
return;
|
|
608
|
+
return body.user?.email;
|
|
609
|
+
}
|
|
610
|
+
async function fetchIntercomEmail(token) {
|
|
611
|
+
const response = await fetch("https://api.intercom.io/me", {
|
|
612
|
+
headers: {
|
|
613
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
614
|
+
Accept: "application/json"
|
|
538
615
|
}
|
|
539
|
-
|
|
540
|
-
|
|
616
|
+
});
|
|
617
|
+
if (!response.ok)
|
|
618
|
+
return;
|
|
619
|
+
const body = await response.json();
|
|
620
|
+
return body.email;
|
|
621
|
+
}
|
|
622
|
+
async function fetchAtlassianEmail(token) {
|
|
623
|
+
const response = await fetch("https://api.atlassian.com/me", {
|
|
624
|
+
headers: {
|
|
625
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
626
|
+
Accept: "application/json"
|
|
541
627
|
}
|
|
628
|
+
});
|
|
629
|
+
if (!response.ok)
|
|
542
630
|
return;
|
|
543
|
-
|
|
544
|
-
|
|
631
|
+
const body = await response.json();
|
|
632
|
+
return body.email;
|
|
633
|
+
}
|
|
634
|
+
async function fetchZendeskEmail(token) {
|
|
635
|
+
const subdomain = token.providerConfig?.subdomain?.trim();
|
|
636
|
+
if (!subdomain)
|
|
545
637
|
return;
|
|
546
|
-
}
|
|
638
|
+
const response = await fetch(`https://${subdomain}.zendesk.com/api/v2/users/me.json`, {
|
|
639
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
640
|
+
});
|
|
641
|
+
if (!response.ok)
|
|
642
|
+
return;
|
|
643
|
+
const body = await response.json();
|
|
644
|
+
return body.user?.email;
|
|
547
645
|
}
|
|
548
|
-
async function
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
if (!response.ok) {
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
const user = await response.json();
|
|
559
|
-
return user.email;
|
|
560
|
-
} catch (error) {
|
|
561
|
-
logger.error("Failed to fetch Google email:", error);
|
|
646
|
+
async function fetchAirtableEmail(token) {
|
|
647
|
+
const response = await fetch("https://api.airtable.com/v0/meta/whoami", {
|
|
648
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
649
|
+
});
|
|
650
|
+
if (!response.ok)
|
|
562
651
|
return;
|
|
563
|
-
|
|
652
|
+
const body = await response.json();
|
|
653
|
+
return body.email;
|
|
564
654
|
}
|
|
565
|
-
async function
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
655
|
+
async function fetchDiscordEmail(token) {
|
|
656
|
+
const response = await fetch("https://discord.com/api/users/@me", {
|
|
657
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
658
|
+
});
|
|
659
|
+
if (!response.ok)
|
|
660
|
+
return;
|
|
661
|
+
const body = await response.json();
|
|
662
|
+
return body.email;
|
|
663
|
+
}
|
|
664
|
+
async function fetchDropboxEmail(token) {
|
|
665
|
+
const response = await fetch("https://api.dropboxapi.com/2/users/get_current_account", {
|
|
666
|
+
method: "POST",
|
|
667
|
+
headers: {
|
|
668
|
+
Authorization: `Bearer ${token.accessToken}`
|
|
669
|
+
},
|
|
670
|
+
body: "null"
|
|
671
|
+
});
|
|
672
|
+
if (!response.ok)
|
|
673
|
+
return;
|
|
674
|
+
const body = await response.json();
|
|
675
|
+
return body.email;
|
|
676
|
+
}
|
|
677
|
+
async function fetchGitLabEmail(token) {
|
|
678
|
+
const response = await fetch("https://gitlab.com/api/v4/user", {
|
|
679
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
680
|
+
});
|
|
681
|
+
if (!response.ok)
|
|
682
|
+
return;
|
|
683
|
+
const body = await response.json();
|
|
684
|
+
return body.email;
|
|
685
|
+
}
|
|
686
|
+
async function fetchRedditEmail(token) {
|
|
687
|
+
const response = await fetch("https://oauth.reddit.com/api/v1/me", {
|
|
688
|
+
headers: {
|
|
689
|
+
Authorization: `Bearer ${token.accessToken}`,
|
|
690
|
+
"User-Agent": "integrate-sdk"
|
|
575
691
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
} catch (error) {
|
|
579
|
-
logger.error("Failed to fetch Notion email:", error);
|
|
692
|
+
});
|
|
693
|
+
if (!response.ok)
|
|
580
694
|
return;
|
|
581
|
-
|
|
695
|
+
const body = await response.json();
|
|
696
|
+
return body.name;
|
|
582
697
|
}
|
|
583
|
-
|
|
698
|
+
async function fetchMicrosoftEmail(token) {
|
|
699
|
+
const response = await fetch("https://graph.microsoft.com/v1.0/me", {
|
|
700
|
+
headers: { Authorization: `Bearer ${token.accessToken}` }
|
|
701
|
+
});
|
|
702
|
+
if (!response.ok)
|
|
703
|
+
return;
|
|
704
|
+
const body = await response.json();
|
|
705
|
+
return body.mail ?? body.userPrincipalName;
|
|
706
|
+
}
|
|
707
|
+
var logger, EMAIL_FETCHERS;
|
|
584
708
|
var init_email_fetcher = __esm(() => {
|
|
585
709
|
init_logger();
|
|
586
710
|
logger = createLogger("EmailFetcher");
|
|
711
|
+
EMAIL_FETCHERS = {
|
|
712
|
+
github: fetchGitHubEmail,
|
|
713
|
+
gmail: fetchGoogleEmail,
|
|
714
|
+
google: fetchGoogleEmail,
|
|
715
|
+
gcal: fetchGoogleEmail,
|
|
716
|
+
gdrive: fetchGoogleEmail,
|
|
717
|
+
gdocs: fetchGoogleEmail,
|
|
718
|
+
gsheets: fetchGoogleEmail,
|
|
719
|
+
gslides: fetchGoogleEmail,
|
|
720
|
+
gcontacts: fetchGoogleEmail,
|
|
721
|
+
gmeet: fetchGoogleEmail,
|
|
722
|
+
gchat: fetchGoogleEmail,
|
|
723
|
+
gtasks: fetchGoogleEmail,
|
|
724
|
+
ga4: fetchGoogleEmail,
|
|
725
|
+
youtube: fetchGoogleEmail,
|
|
726
|
+
notion: fetchNotionEmail,
|
|
727
|
+
linear: fetchLinearEmail,
|
|
728
|
+
hubspot: fetchHubSpotEmail,
|
|
729
|
+
polar: fetchPolarEmail,
|
|
730
|
+
todoist: fetchTodoistEmail,
|
|
731
|
+
vercel: fetchVercelEmail,
|
|
732
|
+
slack: fetchSlackEmail,
|
|
733
|
+
intercom: fetchIntercomEmail,
|
|
734
|
+
jira: fetchAtlassianEmail,
|
|
735
|
+
zendesk: fetchZendeskEmail,
|
|
736
|
+
airtable: fetchAirtableEmail,
|
|
737
|
+
discord: fetchDiscordEmail,
|
|
738
|
+
dropbox: fetchDropboxEmail,
|
|
739
|
+
gitlab: fetchGitLabEmail,
|
|
740
|
+
reddit: fetchRedditEmail,
|
|
741
|
+
outlook: fetchMicrosoftEmail,
|
|
742
|
+
teams: fetchMicrosoftEmail,
|
|
743
|
+
onedrive: fetchMicrosoftEmail,
|
|
744
|
+
sharepoint: fetchMicrosoftEmail,
|
|
745
|
+
excel: fetchMicrosoftEmail,
|
|
746
|
+
word: fetchMicrosoftEmail,
|
|
747
|
+
powerpoint: fetchMicrosoftEmail,
|
|
748
|
+
planner: fetchMicrosoftEmail
|
|
749
|
+
};
|
|
587
750
|
});
|
|
588
751
|
|
|
589
752
|
// src/adapters/session-detector.ts
|