@inixiative/integrations 0.4.0 → 0.4.1
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/package.json +1 -1
- package/src/catalog/refreshTokenRotates.ts +12 -0
- package/src/contracts.ts +4 -1
- package/src/integrationFamilies/atlassianIntegrationFamily.ts +1 -0
- package/src/integrationFamilies/githubIntegrationFamily.ts +1 -0
- package/src/integrationFamilies/googleIntegrationFamily.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inixiative/integrations",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IntegrationFamily, Provider } from '../contracts';
|
|
2
|
+
import { findProvider } from './findProvider';
|
|
3
|
+
import { integrationFamilyDefinition } from './integrationFamilyDefinition';
|
|
4
|
+
|
|
5
|
+
export const refreshTokenRotates = (
|
|
6
|
+
owner: { provider: Provider } | { integrationFamily: IntegrationFamily },
|
|
7
|
+
) => {
|
|
8
|
+
// why: an unknown refresh outcome may have spent a rotating token, so only a non-rotating one is safe to retry.
|
|
9
|
+
if ('integrationFamily' in owner)
|
|
10
|
+
return integrationFamilyDefinition(owner.integrationFamily)?.oauth?.refreshTokenRotates ?? true;
|
|
11
|
+
return findProvider(owner.provider)?.refreshTokenRotates ?? true;
|
|
12
|
+
};
|
package/src/contracts.ts
CHANGED
|
@@ -83,7 +83,9 @@ export const integrationFamilyDefinitionSchema = z
|
|
|
83
83
|
name: z.string(),
|
|
84
84
|
documentationUrl: z.url(),
|
|
85
85
|
authMethods: z.array(credentialMethodSchema),
|
|
86
|
-
oauth: z
|
|
86
|
+
oauth: z
|
|
87
|
+
.object({ authorizeUrl: z.url(), tokenUrl: z.url(), refreshTokenRotates: z.boolean() })
|
|
88
|
+
.optional(),
|
|
87
89
|
})
|
|
88
90
|
.refine((definition) => !definition.authMethods.includes('oauth2') || definition.oauth, {
|
|
89
91
|
message: 'an integration family with oauth2 auth needs its OAuth endpoints',
|
|
@@ -102,6 +104,7 @@ export const providerDefinitionSchema = z
|
|
|
102
104
|
subscription: z.boolean().optional(),
|
|
103
105
|
integrationFamily: integrationFamilySchema.optional(),
|
|
104
106
|
oauthScopes: z.array(z.string()).optional(),
|
|
107
|
+
refreshTokenRotates: z.boolean().optional(),
|
|
105
108
|
})
|
|
106
109
|
.refine(
|
|
107
110
|
(definition) =>
|