integrate-sdk 0.9.28-dev.1 → 0.9.29-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/oauth.js CHANGED
@@ -101,10 +101,18 @@ var init_library_metadata = __esm(() => {
101
101
  description: "Manage Polar products, orders, and subscriptions",
102
102
  category: "Business"
103
103
  },
104
+ posthog: {
105
+ description: "Read PostHog organizations, projects, insights, and feature flags",
106
+ category: "Analytics"
107
+ },
104
108
  ramp: {
105
109
  description: "Manage Ramp corporate cards, bills, and spend",
106
110
  category: "Business"
107
111
  },
112
+ railway: {
113
+ description: "Manage Railway workspaces, projects, services, deployments, variables, domains, and volumes",
114
+ category: "Infrastructure"
115
+ },
108
116
  slack: {
109
117
  description: "Send and manage Slack messages and channels",
110
118
  category: "Communication"
@@ -629,6 +637,21 @@ var exports_base_handler = {};
629
637
  __export(exports_base_handler, {
630
638
  OAuthHandler: () => OAuthHandler
631
639
  });
640
+ function getForwardableProviderConfig(config) {
641
+ if (!config) {
642
+ return {};
643
+ }
644
+ return Object.fromEntries(Object.entries(config).filter(([key, value]) => value !== undefined && value !== null && !OAUTH_CONFIG_FIELDS.has(key)).map(([key, value]) => [key, String(value)]));
645
+ }
646
+ function getStoredProviderConfig(config) {
647
+ const baseUrl = config?.baseUrl || config?.apiBaseUrl;
648
+ if (!baseUrl) {
649
+ return;
650
+ }
651
+ return {
652
+ baseUrl: String(baseUrl)
653
+ };
654
+ }
632
655
 
633
656
  class OAuthHandler {
634
657
  config;
@@ -700,25 +723,9 @@ class OAuthHandler {
700
723
  if (redirectUri) {
701
724
  url.searchParams.set("redirect_uri", redirectUri);
702
725
  }
703
- const OAUTH_FIELDS = new Set([
704
- "clientId",
705
- "clientSecret",
706
- "scopes",
707
- "optionalScopes",
708
- "redirectUri",
709
- "client_id",
710
- "client_secret",
711
- "scope",
712
- "optional_scope",
713
- "redirect_uri",
714
- "provider"
715
- ]);
716
- if (providerConfig.config) {
717
- for (const [key, value] of Object.entries(providerConfig.config)) {
718
- if (value !== undefined && value !== null && !OAUTH_FIELDS.has(key)) {
719
- url.searchParams.set(key, String(value));
720
- }
721
- }
726
+ const extraConfig = getForwardableProviderConfig(providerConfig.config);
727
+ for (const [key, value] of Object.entries(extraConfig)) {
728
+ url.searchParams.set(key, value);
722
729
  }
723
730
  const response = await fetch(url.toString(), {
724
731
  method: "GET",
@@ -805,7 +812,8 @@ class OAuthHandler {
805
812
  state: callbackRequest.state,
806
813
  client_id: providerConfig.clientId,
807
814
  client_secret: providerConfig.clientSecret,
808
- redirect_uri: providerConfig.redirectUri
815
+ redirect_uri: providerConfig.redirectUri,
816
+ ...getForwardableProviderConfig(providerConfig.config)
809
817
  })
810
818
  });
811
819
  if (!response.ok) {
@@ -823,7 +831,8 @@ class OAuthHandler {
823
831
  tokenType: result.tokenType,
824
832
  expiresIn: result.expiresIn,
825
833
  expiresAt: result.expiresAt,
826
- scopes: result.scopes ? result.scopes.flatMap((s) => s.split(" ").filter(Boolean)) : result.scopes
834
+ scopes: result.scopes ? result.scopes.flatMap((s) => s.split(" ").filter(Boolean)) : result.scopes,
835
+ providerConfig: getStoredProviderConfig(providerConfig.config)
827
836
  };
828
837
  const email = result.email || await fetchUserEmail(callbackRequest.provider, tokenData);
829
838
  if (email) {
@@ -940,6 +949,12 @@ class OAuthHandler {
940
949
  if (providerConfig.config?.subdomain) {
941
950
  body.subdomain = providerConfig.config.subdomain;
942
951
  }
952
+ const extraConfig = getForwardableProviderConfig(providerConfig.config);
953
+ for (const [key, value] of Object.entries(extraConfig)) {
954
+ if (body[key] === undefined) {
955
+ body[key] = value;
956
+ }
957
+ }
943
958
  const url = new URL("/oauth/refresh", this.serverUrl);
944
959
  const response = await fetch(url.toString(), {
945
960
  method: "POST",
@@ -966,7 +981,8 @@ class OAuthHandler {
966
981
  tokenType: result.tokenType,
967
982
  expiresIn: result.expiresIn,
968
983
  expiresAt: result.expiresAt,
969
- scopes: result.scopes ? result.scopes.flatMap((s) => s.split(" ").filter(Boolean)) : result.scopes
984
+ scopes: result.scopes ? result.scopes.flatMap((s) => s.split(" ").filter(Boolean)) : result.scopes,
985
+ providerConfig: getStoredProviderConfig(providerConfig.config)
970
986
  };
971
987
  const email = result.email || await fetchUserEmail(refreshRequest.provider, tokenData);
972
988
  if (email) {
@@ -1033,12 +1049,25 @@ class OAuthHandler {
1033
1049
  return jsonRpcResponse.result;
1034
1050
  }
1035
1051
  }
1036
- var SERVER_LOG_CONTEXT = "server", logger2, MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp";
1052
+ var SERVER_LOG_CONTEXT = "server", logger2, OAUTH_CONFIG_FIELDS, MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp";
1037
1053
  var init_base_handler = __esm(() => {
1038
1054
  init_integration_summary();
1039
1055
  init_email_fetcher();
1040
1056
  init_logger();
1041
1057
  logger2 = createLogger("OAuthHandler", SERVER_LOG_CONTEXT);
1058
+ OAUTH_CONFIG_FIELDS = new Set([
1059
+ "clientId",
1060
+ "clientSecret",
1061
+ "scopes",
1062
+ "optionalScopes",
1063
+ "redirectUri",
1064
+ "client_id",
1065
+ "client_secret",
1066
+ "scope",
1067
+ "optional_scope",
1068
+ "redirect_uri",
1069
+ "provider"
1070
+ ]);
1042
1071
  });
1043
1072
 
1044
1073
  // src/adapters/auto-routes.ts