@inixiative/integrations 0.2.0 → 0.3.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.
Files changed (31) hide show
  1. package/package.json +3 -3
  2. package/src/catalog/acceptedCredentialMethods.ts +17 -0
  3. package/src/catalog/integrationFamilies.ts +12 -0
  4. package/src/catalog/integrationFamilyDefinition.ts +6 -0
  5. package/src/catalog/isAccountSuppliedByHost.ts +2 -2
  6. package/src/catalog/providerAuthenticatesThroughIntegrationFamily.ts +6 -0
  7. package/src/catalog/providers.ts +0 -4
  8. package/src/catalog/providersInIntegrationFamily.ts +5 -0
  9. package/src/contracts.ts +35 -15
  10. package/src/credentials/exchangeOauthCode.ts +11 -5
  11. package/src/credentials/refreshProviderCredential.ts +42 -20
  12. package/src/credentials/renewalOwner.ts +3 -0
  13. package/src/integrationFamilies/atlassianIntegrationFamily.ts +12 -0
  14. package/src/{providers/github/githubProvider.ts → integrationFamilies/githubIntegrationFamily.ts} +2 -3
  15. package/src/{providers/google/googleProvider.ts → integrationFamilies/googleIntegrationFamily.ts} +2 -3
  16. package/src/integrationFamilies/inixiativeIntegrationFamily.ts +8 -0
  17. package/src/operations/buildProviderRequest.ts +2 -1
  18. package/src/operations/operationHandlers.ts +1 -3
  19. package/src/providers/chorus/chorusProvider.ts +2 -0
  20. package/src/providers/confluence/confluenceProvider.ts +1 -0
  21. package/src/providers/drive/driveProvider.ts +2 -2
  22. package/src/providers/github/auth/githubUserAuthorizeUrl.ts +2 -2
  23. package/src/providers/github/githubOrganizationProvider.ts +1 -1
  24. package/src/providers/github/githubUserProvider.ts +2 -2
  25. package/src/providers/gmail/gmailProvider.ts +2 -2
  26. package/src/providers/google/auth/buildGoogleAuthorizationUrl.ts +2 -1
  27. package/src/providers/jira/jiraProvider.ts +1 -0
  28. package/src/providers/oracle/oracleProvider.ts +1 -0
  29. package/src/catalog/familyProducts.ts +0 -5
  30. package/src/catalog/isFamilyManaged.ts +0 -7
  31. package/src/catalog/providerFamily.ts +0 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inixiative/integrations",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The provider catalog behind Kingdom integrations: each provider's operations, events, resource kinds and scopes, with the request, webhook and credential code that reaches it.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -30,12 +30,12 @@
30
30
  ],
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@inixiative/signet": "^0.28.0",
33
+ "@inixiative/signet": "^0.29.0",
34
34
  "jose": "^6.2.3"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@biomejs/biome": "2.5.2",
38
- "@inixiative/config": "^0.5.237",
38
+ "@inixiative/config": "^0.5.254",
39
39
  "@types/bun": "1.4.4",
40
40
  "lefthook": "2.1.9",
41
41
  "typescript": "6.0.3",
@@ -0,0 +1,17 @@
1
+ import { type CredentialMethod, credentialMethodSchema, type Provider } from '../contracts';
2
+ import { findProvider } from './findProvider';
3
+ import { integrationFamilyDefinition } from './integrationFamilyDefinition';
4
+
5
+ export const acceptedCredentialMethods = (
6
+ provider: Provider | null | undefined,
7
+ ): CredentialMethod[] => {
8
+ const definition = findProvider(provider);
9
+ if (!definition) return [];
10
+ const ownMethods = definition.authMethods.flatMap(
11
+ (method) => credentialMethodSchema.safeParse(method).data ?? [],
12
+ );
13
+ if (!definition.authMethods.includes('integrationFamily')) return ownMethods;
14
+ const familyMethods =
15
+ integrationFamilyDefinition(definition.integrationFamily)?.authMethods ?? [];
16
+ return [...new Set([...ownMethods, ...familyMethods])];
17
+ };
@@ -0,0 +1,12 @@
1
+ import type { IntegrationFamilyDefinition } from '../contracts';
2
+ import { atlassianIntegrationFamily } from '../integrationFamilies/atlassianIntegrationFamily';
3
+ import { githubIntegrationFamily } from '../integrationFamilies/githubIntegrationFamily';
4
+ import { googleIntegrationFamily } from '../integrationFamilies/googleIntegrationFamily';
5
+ import { inixiativeIntegrationFamily } from '../integrationFamilies/inixiativeIntegrationFamily';
6
+
7
+ export const integrationFamilies: IntegrationFamilyDefinition[] = [
8
+ googleIntegrationFamily,
9
+ githubIntegrationFamily,
10
+ atlassianIntegrationFamily,
11
+ inixiativeIntegrationFamily,
12
+ ];
@@ -0,0 +1,6 @@
1
+ import type { IntegrationFamily } from '../contracts';
2
+ import { integrationFamilies } from './integrationFamilies';
3
+
4
+ export const integrationFamilyDefinition = (
5
+ integrationFamily: IntegrationFamily | null | undefined,
6
+ ) => integrationFamilies.find((definition) => definition.key === integrationFamily);
@@ -1,6 +1,6 @@
1
1
  import type { Provider } from '../contracts';
2
- import { isFamilyManaged } from './isFamilyManaged';
2
+ import { providerAuthenticatesThroughIntegrationFamily } from './providerAuthenticatesThroughIntegrationFamily';
3
3
  import { providerHasEvents } from './providerHasEvents';
4
4
 
5
5
  export const isAccountSuppliedByHost = (provider: Provider | null | undefined) =>
6
- isFamilyManaged(provider) || providerHasEvents(provider);
6
+ providerAuthenticatesThroughIntegrationFamily(provider) || providerHasEvents(provider);
@@ -0,0 +1,6 @@
1
+ import type { Provider } from '../contracts';
2
+ import { findProvider } from './findProvider';
3
+
4
+ export const providerAuthenticatesThroughIntegrationFamily = (
5
+ provider: Provider | null | undefined,
6
+ ) => Boolean(findProvider(provider)?.authMethods.includes('integrationFamily'));
@@ -10,10 +10,8 @@ import { driveProvider } from '../providers/drive/driveProvider';
10
10
  import { foundryProvider } from '../providers/foundry/foundryProvider';
11
11
  import { geminiApiProvider } from '../providers/geminiApi/geminiApiProvider';
12
12
  import { githubOrganizationProvider } from '../providers/github/githubOrganizationProvider';
13
- import { githubProvider } from '../providers/github/githubProvider';
14
13
  import { githubUserProvider } from '../providers/github/githubUserProvider';
15
14
  import { gmailProvider } from '../providers/gmail/gmailProvider';
16
- import { googleProvider } from '../providers/google/googleProvider';
17
15
  import { jiraProvider } from '../providers/jira/jiraProvider';
18
16
  import { linearProvider } from '../providers/linear/linearProvider';
19
17
  import { museProvider } from '../providers/muse/museProvider';
@@ -32,7 +30,6 @@ export const providers: ProviderDefinition[] = [
32
30
  linearProvider,
33
31
  notionProvider,
34
32
  jiraProvider,
35
- googleProvider,
36
33
  gmailProvider,
37
34
  driveProvider,
38
35
  confluenceProvider,
@@ -43,7 +40,6 @@ export const providers: ProviderDefinition[] = [
43
40
  foundryProvider,
44
41
  oracleProvider,
45
42
  chorusProvider,
46
- githubProvider,
47
43
  githubOrganizationProvider,
48
44
  githubUserProvider,
49
45
  railwayProvider,
@@ -0,0 +1,5 @@
1
+ import type { IntegrationFamily } from '../contracts';
2
+ import { providers } from './providers';
3
+
4
+ export const providersInIntegrationFamily = (integrationFamily: IntegrationFamily) =>
5
+ providers.filter((definition) => definition.integrationFamily === integrationFamily);
package/src/contracts.ts CHANGED
@@ -35,11 +35,14 @@ export const credentialSecretSchema = z.strictObject({
35
35
  });
36
36
  export type CredentialSecret = z.infer<typeof credentialSecretSchema>;
37
37
  export const credentialMethodSchema = z.enum(['bearer', 'apiKey', 'oauth2', 'clientCredentials']);
38
+ export type CredentialMethod = z.infer<typeof credentialMethodSchema>;
38
39
  export const renewableCredentialMethods: string[] = credentialMethodSchema.extract([
39
40
  'oauth2',
40
41
  'clientCredentials',
41
42
  ]).options;
42
43
  export const isRenewableMethod = (method: string) => renewableCredentialMethods.includes(method);
44
+ export const authMethodSchema = z.enum([...credentialMethodSchema.options, 'integrationFamily']);
45
+ export type AuthMethod = z.infer<typeof authMethodSchema>;
43
46
 
44
47
  export const catalogOperationSchema = z.object({
45
48
  key: operationKeySchema,
@@ -54,7 +57,6 @@ export const providerSchema = z.enum([
54
57
  'linear',
55
58
  'notion',
56
59
  'jira',
57
- 'google',
58
60
  'gmail',
59
61
  'drive',
60
62
  'confluence',
@@ -62,7 +64,6 @@ export const providerSchema = z.enum([
62
64
  'openai',
63
65
  'geminiApi',
64
66
  'archive',
65
- 'github',
66
67
  'githubOrganization',
67
68
  'githubUser',
68
69
  'foundry',
@@ -74,19 +75,38 @@ export const providerSchema = z.enum([
74
75
  'codex',
75
76
  'muse',
76
77
  ]);
77
- export const providerDefinitionSchema = z.object({
78
- key: providerSchema,
79
- name: z.string(),
80
- documentationUrl: z.url(),
81
- authMethods: z.array(credentialMethodSchema),
82
- operations: z.array(catalogOperationSchema),
83
- inbound: z.boolean().optional(),
84
- delivery: z.literal('installationSocket').optional(),
85
- subscription: z.boolean().optional(),
86
- family: providerSchema.optional(),
87
- oauthScopes: z.array(z.string()).optional(),
88
- oauth: z.object({ authorizeUrl: z.url(), tokenUrl: z.url() }).optional(),
89
- });
78
+ export const integrationFamilySchema = z.enum(['google', 'github', 'atlassian', 'inixiative']);
79
+ export type IntegrationFamily = z.infer<typeof integrationFamilySchema>;
80
+ export const integrationFamilyDefinitionSchema = z
81
+ .object({
82
+ key: integrationFamilySchema,
83
+ name: z.string(),
84
+ documentationUrl: z.url(),
85
+ authMethods: z.array(credentialMethodSchema),
86
+ oauth: z.object({ authorizeUrl: z.url(), tokenUrl: z.url() }).optional(),
87
+ })
88
+ .refine((definition) => !definition.authMethods.includes('oauth2') || definition.oauth, {
89
+ message: 'an integration family with oauth2 auth needs its OAuth endpoints',
90
+ });
91
+ export type IntegrationFamilyDefinition = z.infer<typeof integrationFamilyDefinitionSchema>;
92
+ export const providerDefinitionSchema = z
93
+ .object({
94
+ key: providerSchema,
95
+ name: z.string(),
96
+ documentationUrl: z.url(),
97
+ authMethods: z.array(authMethodSchema),
98
+ operations: z.array(catalogOperationSchema),
99
+ inbound: z.boolean().optional(),
100
+ delivery: z.literal('installationSocket').optional(),
101
+ subscription: z.boolean().optional(),
102
+ integrationFamily: integrationFamilySchema.optional(),
103
+ oauthScopes: z.array(z.string()).optional(),
104
+ })
105
+ .refine(
106
+ (definition) =>
107
+ !definition.authMethods.includes('integrationFamily') || definition.integrationFamily,
108
+ { message: 'integrationFamily auth needs the provider to name its integrationFamily' },
109
+ );
90
110
  export type Provider = z.infer<typeof providerSchema>;
91
111
  export type OAuthClient = { clientId: string; clientSecret: string };
92
112
  export type SigningClient = OAuthClient & { appId: string; privateKey: string };
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { findProvider } from '../catalog/findProvider';
3
- import type { OAuthClient, Provider } from '../contracts';
2
+ import { integrationFamilyDefinition } from '../catalog/integrationFamilyDefinition';
3
+ import type { IntegrationFamily, OAuthClient } from '../contracts';
4
4
  import { ProviderError } from '../utils/providerError';
5
5
  import type { ProviderSend } from '../utils/providerSend';
6
6
  import { readProviderJson } from '../utils/readProviderJson';
@@ -15,10 +15,16 @@ const tokenResponseSchema = z.object({
15
15
 
16
16
  export const exchangeOauthCode = async (
17
17
  { app, send = fetch }: { app: OAuthClient; send?: ProviderSend },
18
- input: { family: Provider; code: string; codeVerifier?: string; redirectUri?: string },
18
+ input: {
19
+ integrationFamily: IntegrationFamily;
20
+ code: string;
21
+ codeVerifier?: string;
22
+ redirectUri?: string;
23
+ },
19
24
  ) => {
20
- const { family } = input;
21
- const tokenUrl = z.url().parse(findProvider(family)?.oauth?.tokenUrl);
25
+ const tokenUrl = z
26
+ .url()
27
+ .parse(integrationFamilyDefinition(input.integrationFamily)?.oauth?.tokenUrl);
22
28
  let response: Response;
23
29
  try {
24
30
  response = await send(
@@ -1,13 +1,21 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  import { z } from 'zod';
3
- import { providers } from '../catalog/providers';
4
- import { type CredentialSecret, credentialSecretSchema, type OAuthClient } from '../contracts';
3
+ import { findProvider } from '../catalog/findProvider';
4
+ import { integrationFamilyDefinition } from '../catalog/integrationFamilyDefinition';
5
+ import {
6
+ type CredentialSecret,
7
+ credentialSecretSchema,
8
+ type IntegrationFamily,
9
+ type OAuthClient,
10
+ type Provider,
11
+ } from '../contracts';
5
12
  import { jwtClaims } from '../utils/jwtClaims';
6
13
  import { ProviderError } from '../utils/providerError';
7
14
  import { CODEX_TOKEN_URL } from './codexTokenUrl';
8
15
  import type { CredentialClient } from './credentialClient';
9
16
  import { fetchRenewalResponse } from './fetchRenewalResponse';
10
17
  import { mintProviderCredential } from './mintProviderCredential';
18
+ import type { RenewalOwner } from './renewalOwner';
11
19
  import type { RenewalRequest } from './renewalRequest';
12
20
 
13
21
  const secondsUntilJwtExpiry = (token: string) => {
@@ -21,8 +29,21 @@ const secondsUntilJwtExpiry = (token: string) => {
21
29
  .parse(exp.data - Math.floor(Date.now() / 1000));
22
30
  };
23
31
 
32
+ const renewalEndpointKey = (owner: RenewalOwner): Provider | IntegrationFamily => {
33
+ if ('integrationFamily' in owner) return owner.integrationFamily;
34
+ const definition = findProvider(owner.provider);
35
+ if (!definition?.integrationFamily || !definition.authMethods.includes('oauth2'))
36
+ return owner.provider;
37
+ return integrationFamilyDefinition(definition.integrationFamily)?.oauth
38
+ ? definition.integrationFamily
39
+ : owner.provider;
40
+ };
41
+
42
+ const familyTokenUrl = (integrationFamily: IntegrationFamily) =>
43
+ z.url().parse(integrationFamilyDefinition(integrationFamily)?.oauth?.tokenUrl);
44
+
24
45
  const refreshRequest = (
25
- provider: string,
46
+ provider: Provider | IntegrationFamily,
26
47
  secret: CredentialSecret,
27
48
  client?: OAuthClient,
28
49
  ): RenewalRequest => {
@@ -33,7 +54,6 @@ const refreshRequest = (
33
54
  const publicClient = provider === 'codex';
34
55
  if (!clientId || (!clientSecret && !publicClient))
35
56
  throw new ProviderError('renewal_unsupported', 409);
36
- const familyOAuth = providers.find((definition) => definition.key === provider)?.oauth;
37
57
  const fields = {
38
58
  grant_type: 'refresh_token',
39
59
  refresh_token: refreshToken,
@@ -51,11 +71,10 @@ const refreshRequest = (
51
71
  headers,
52
72
  body: new URLSearchParams(fields).toString(),
53
73
  };
54
- case 'githubUser':
74
+ case 'github':
75
+ case 'google':
55
76
  return {
56
- url: z
57
- .url()
58
- .parse(providers.find((definition) => definition.key === 'github')?.oauth?.tokenUrl),
77
+ url: familyTokenUrl(provider),
59
78
  headers,
60
79
  body: new URLSearchParams(fields).toString(),
61
80
  };
@@ -65,23 +84,16 @@ const refreshRequest = (
65
84
  headers,
66
85
  body: new URLSearchParams(fields).toString(),
67
86
  };
68
- case 'google':
69
- return {
70
- url: z.url().parse(familyOAuth?.tokenUrl),
71
- headers,
72
- body: new URLSearchParams(fields).toString(),
73
- };
74
87
  case 'teams':
75
88
  return {
76
89
  url: `https://login.microsoftonline.com/${z.uuid().parse(tenantId)}/oauth2/v2.0/token`,
77
90
  headers,
78
91
  body: new URLSearchParams(fields).toString(),
79
92
  };
80
- case 'jira':
81
- case 'confluence':
93
+ case 'atlassian':
82
94
  headers.set('Content-Type', 'application/json');
83
95
  return {
84
- url: 'https://auth.atlassian.com/oauth/token',
96
+ url: familyTokenUrl(provider),
85
97
  headers,
86
98
  body: JSON.stringify(fields),
87
99
  };
@@ -115,7 +127,7 @@ const refreshRequest = (
115
127
  };
116
128
 
117
129
  const refreshedSecret = (
118
- provider: string,
130
+ provider: Provider | IntegrationFamily,
119
131
  secret: CredentialSecret,
120
132
  data: Record<string, unknown>,
121
133
  ) => {
@@ -135,7 +147,16 @@ const refreshedSecret = (
135
147
  });
136
148
  if (!refreshed.success) throw new ProviderError('renewal_outcome_unknown', 409);
137
149
  if (
138
- ['slack', 'linear', 'jira', 'confluence', 'notion', 'codex', 'githubUser'].includes(provider) &&
150
+ [
151
+ 'slack',
152
+ 'linear',
153
+ 'atlassian',
154
+ 'jira',
155
+ 'confluence',
156
+ 'notion',
157
+ 'codex',
158
+ 'githubUser',
159
+ ].includes(provider) &&
139
160
  !data.refresh_token
140
161
  )
141
162
  throw new ProviderError('renewal_outcome_unknown', 409);
@@ -151,9 +172,10 @@ const refreshedSecret = (
151
172
 
152
173
  export const refreshProviderCredential = async (
153
174
  client: CredentialClient,
154
- { provider, secret: value }: { provider: string; secret: unknown },
175
+ { secret: value, ...owner }: RenewalOwner & { secret: unknown },
155
176
  ) => {
156
177
  const secret = credentialSecretSchema.parse(value);
178
+ const provider = renewalEndpointKey(owner);
157
179
  if (secret.clientCredentials)
158
180
  return await mintProviderCredential(client, {
159
181
  provider,
@@ -0,0 +1,3 @@
1
+ import type { IntegrationFamily, Provider } from '../contracts';
2
+
3
+ export type RenewalOwner = { provider: Provider } | { integrationFamily: IntegrationFamily };
@@ -0,0 +1,12 @@
1
+ import type { IntegrationFamilyDefinition } from '../contracts';
2
+
3
+ export const atlassianIntegrationFamily: IntegrationFamilyDefinition = {
4
+ key: 'atlassian',
5
+ name: 'Atlassian',
6
+ documentationUrl: 'https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/',
7
+ authMethods: ['oauth2'],
8
+ oauth: {
9
+ authorizeUrl: 'https://auth.atlassian.com/authorize',
10
+ tokenUrl: 'https://auth.atlassian.com/oauth/token',
11
+ },
12
+ };
@@ -1,11 +1,10 @@
1
- import type { ProviderDefinition } from '../../contracts';
1
+ import type { IntegrationFamilyDefinition } from '../contracts';
2
2
 
3
- export const githubProvider: ProviderDefinition = {
3
+ export const githubIntegrationFamily: IntegrationFamilyDefinition = {
4
4
  key: 'github',
5
5
  name: 'GitHub',
6
6
  documentationUrl: 'https://docs.github.com/en/apps/overview',
7
7
  authMethods: ['oauth2'],
8
- operations: [],
9
8
  oauth: {
10
9
  authorizeUrl: 'https://github.com/login/oauth/authorize',
11
10
  tokenUrl: 'https://github.com/login/oauth/access_token',
@@ -1,11 +1,10 @@
1
- import type { ProviderDefinition } from '../../contracts';
1
+ import type { IntegrationFamilyDefinition } from '../contracts';
2
2
 
3
- export const googleProvider: ProviderDefinition = {
3
+ export const googleIntegrationFamily: IntegrationFamilyDefinition = {
4
4
  key: 'google',
5
5
  name: 'Google',
6
6
  documentationUrl: 'https://developers.google.com/identity/protocols/oauth2/web-server',
7
7
  authMethods: ['oauth2'],
8
- operations: [],
9
8
  oauth: {
10
9
  authorizeUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
11
10
  tokenUrl: 'https://oauth2.googleapis.com/token',
@@ -0,0 +1,8 @@
1
+ import type { IntegrationFamilyDefinition } from '../contracts';
2
+
3
+ export const inixiativeIntegrationFamily: IntegrationFamilyDefinition = {
4
+ key: 'inixiative',
5
+ name: 'inixiative',
6
+ documentationUrl: 'https://github.com/inixiative/integrations',
7
+ authMethods: [],
8
+ };
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { acceptedCredentialMethods } from '../catalog/acceptedCredentialMethods';
2
3
  import { isUncalledLeaf } from '../catalog/isUncalledLeaf';
3
4
  import { providers } from '../catalog/providers';
4
5
  import type { ProviderContext } from '../contracts';
@@ -18,7 +19,7 @@ export const buildProviderRequest = (
18
19
  if (!definition || !operation || operation.resourceKind !== context.resource.kind)
19
20
  throw new ProviderError('unsupported_operation', 400);
20
21
  if (isUncalledLeaf(operation.key)) throw new ProviderError('unsupported_integration', 400);
21
- if (!definition.authMethods.includes(context.method))
22
+ if (!acceptedCredentialMethods(context.provider).includes(context.method))
22
23
  throw new ProviderError('unsupported_authentication', 400);
23
24
  const configuration = integrationConfigurationSchemas[definition.key].parse(
24
25
  context.configuration,
@@ -11,7 +11,7 @@ import { slackOperationHandler } from '../providers/slack/models/channel/slackOp
11
11
  import { teamsOperationHandler } from '../providers/teams/teamsOperationHandler';
12
12
  import type { OperationHandler } from './operationHandler';
13
13
 
14
- // why: null marks a provider reached outside the generic HTTP path (own client, Signet, family, or admitted elsewhere).
14
+ // why: null marks a provider reached outside the generic HTTP path (own client, Signet, or admitted elsewhere).
15
15
  export const operationHandlers: Record<Provider, OperationHandler | null> = {
16
16
  slack: slackOperationHandler,
17
17
  discord: discordOperationHandler,
@@ -21,10 +21,8 @@ export const operationHandlers: Record<Provider, OperationHandler | null> = {
21
21
  jira: jiraOperationHandler,
22
22
  drive: driveOperationHandler,
23
23
  confluence: confluenceOperationHandler,
24
- github: null,
25
24
  githubOrganization: githubOperationHandler,
26
25
  githubUser: githubOperationHandler,
27
- google: null,
28
26
  anthropic: null,
29
27
  openai: null,
30
28
  geminiApi: null,
@@ -11,8 +11,10 @@ export const chorusProvider: ProviderDefinition = {
11
11
  name: 'Chorus',
12
12
  documentationUrl: 'https://github.com/inixiative/chorus',
13
13
  authMethods: [],
14
+ integrationFamily: 'inixiative',
14
15
  inbound: true,
15
16
  delivery: 'installationSocket',
17
+ holderHandleKinds: [chorusResourceKind],
16
18
  operations: declaredOperations(
17
19
  chorusOperationNames,
18
20
  chorusResourceKind,
@@ -5,6 +5,7 @@ export const confluenceProvider: ProviderDefinition = {
5
5
  name: 'Confluence',
6
6
  documentationUrl: 'https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/',
7
7
  authMethods: ['bearer', 'oauth2'],
8
+ integrationFamily: 'atlassian',
8
9
  operations: [
9
10
  {
10
11
  key: 'pages.read',
@@ -4,8 +4,8 @@ export const driveProvider: ProviderDefinition = {
4
4
  key: 'drive',
5
5
  name: 'Google Drive',
6
6
  documentationUrl: 'https://developers.google.com/workspace/drive/api/reference/rest/v3/files/get',
7
- authMethods: ['oauth2'],
8
- family: 'google',
7
+ authMethods: ['integrationFamily'],
8
+ integrationFamily: 'google',
9
9
  oauthScopes: ['https://www.googleapis.com/auth/drive.metadata.readonly'],
10
10
  operations: [
11
11
  {
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { findProvider } from '../../../catalog/findProvider';
2
+ import { integrationFamilyDefinition } from '../../../catalog/integrationFamilyDefinition';
3
3
  import type { OAuthClient } from '../../../contracts';
4
4
 
5
5
  export const githubUserAuthorizeUrl = (app: Pick<OAuthClient, 'clientId'>, state: string) => {
6
- const url = new URL(z.url().parse(findProvider('github')?.oauth?.authorizeUrl));
6
+ const url = new URL(z.url().parse(integrationFamilyDefinition('github')?.oauth?.authorizeUrl));
7
7
  url.searchParams.set('client_id', app.clientId);
8
8
  url.searchParams.set('state', state);
9
9
  return url.toString();
@@ -7,7 +7,7 @@ export const githubOrganizationProvider: ProviderDefinition = {
7
7
  documentationUrl:
8
8
  'https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation',
9
9
  authMethods: ['clientCredentials'],
10
- family: 'github',
10
+ integrationFamily: 'github',
11
11
  operations: [...githubRepository.operations, ...githubRepository.events],
12
12
  eventResourceExternalId: githubRepository.externalIdOfEvent,
13
13
  };
@@ -7,7 +7,7 @@ export const githubUserProvider: ProviderDefinition = {
7
7
  name: 'GitHub user',
8
8
  documentationUrl:
9
9
  'https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-with-a-github-app-on-behalf-of-a-user',
10
- authMethods: ['oauth2', 'bearer'],
11
- family: 'github',
10
+ authMethods: ['integrationFamily', 'bearer'],
11
+ integrationFamily: 'github',
12
12
  operations: [...githubRepository.operations, ...githubAccount.events],
13
13
  };
@@ -5,8 +5,8 @@ export const gmailProvider: ProviderDefinition = {
5
5
  name: 'Gmail',
6
6
  documentationUrl:
7
7
  'https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.messages/list',
8
- authMethods: ['oauth2'],
9
- family: 'google',
8
+ authMethods: ['integrationFamily'],
9
+ integrationFamily: 'google',
10
10
  oauthScopes: ['https://www.googleapis.com/auth/gmail.readonly'],
11
11
  operations: [
12
12
  {
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { findProvider } from '../../../catalog/findProvider';
3
+ import { integrationFamilyDefinition } from '../../../catalog/integrationFamilyDefinition';
3
4
  import type { Provider } from '../../../contracts';
4
5
 
5
6
  export const buildGoogleAuthorizationUrl = (input: {
@@ -10,7 +11,7 @@ export const buildGoogleAuthorizationUrl = (input: {
10
11
  codeChallenge: string;
11
12
  loginHint?: string;
12
13
  }) => {
13
- const url = new URL(z.url().parse(findProvider('google')?.oauth?.authorizeUrl));
14
+ const url = new URL(z.url().parse(integrationFamilyDefinition('google')?.oauth?.authorizeUrl));
14
15
  const scopes = [
15
16
  ...new Set([
16
17
  ...input.products.flatMap((product) => findProvider(product)?.oauthScopes ?? []),
@@ -5,6 +5,7 @@ export const jiraProvider: ProviderDefinition = {
5
5
  name: 'Jira',
6
6
  documentationUrl: 'https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/',
7
7
  authMethods: ['bearer', 'oauth2'],
8
+ integrationFamily: 'atlassian',
8
9
  operations: [
9
10
  {
10
11
  key: 'issues.read',
@@ -5,6 +5,7 @@ export const oracleProvider: ProviderDefinition = {
5
5
  name: 'Oracle',
6
6
  documentationUrl: 'https://github.com/inixiative/oracle',
7
7
  authMethods: [],
8
+ integrationFamily: 'inixiative',
8
9
  inbound: true,
9
10
  operations: [],
10
11
  };
@@ -1,5 +0,0 @@
1
- import type { Provider } from '../contracts';
2
- import { providers } from './providers';
3
-
4
- export const familyProducts = (family: Provider) =>
5
- providers.filter((definition) => definition.family === family);
@@ -1,7 +0,0 @@
1
- import type { Provider } from '../contracts';
2
- import { findProvider } from './findProvider';
3
-
4
- export const isFamilyManaged = (provider: Provider | null | undefined) => {
5
- const definition = findProvider(provider);
6
- return Boolean(definition?.oauth || definition?.family);
7
- };
@@ -1,4 +0,0 @@
1
- import { providers } from './providers';
2
-
3
- export const providerFamily = <T extends string | null | undefined>(provider: T) =>
4
- providers.find((definition) => definition.key === provider)?.family ?? provider;