@kosha-ai/integration-zendesk 0.5.4 → 0.7.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-zendesk.d.ts","sourceRoot":"","sources":["../../src/lib/integration-zendesk.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAcnC,eAAO,MAAM,OAAO,GAAI,WAAW,MAAM,WACL,CAAC;
|
|
1
|
+
{"version":3,"file":"integration-zendesk.d.ts","sourceRoot":"","sources":["../../src/lib/integration-zendesk.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAcnC,eAAO,MAAM,OAAO,GAAI,WAAW,MAAM,WACL,CAAC;AAoKrC,wBAAgB,OAAO,IAAI,gBAAgB,CAuI1C;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -131,9 +131,15 @@ function subdomainFrom(fields) {
|
|
|
131
131
|
const COMMON = {
|
|
132
132
|
tokenRequest: 'json',
|
|
133
133
|
scopeSeparator: ' ',
|
|
134
|
+
clientCredentialsGrant: true,
|
|
134
135
|
scopesAvailable: SCOPES_AVAILABLE,
|
|
135
136
|
scopesRequested: SCOPES_REQUESTED,
|
|
136
137
|
};
|
|
138
|
+
function authMode(fields) {
|
|
139
|
+
return fields?.['authMode'] === 'client_credentials'
|
|
140
|
+
? 'client_credentials'
|
|
141
|
+
: 'authorization_code';
|
|
142
|
+
}
|
|
137
143
|
/**
|
|
138
144
|
* Zendesk is per-tenant: authorize and token both live on the account's own
|
|
139
145
|
* host, so neither endpoint is knowable until a configuration is in hand.
|
|
@@ -158,11 +164,28 @@ export function zendesk() {
|
|
|
158
164
|
authorizationUrl: 'https://{subdomain}.zendesk.com/oauth/authorizations/new',
|
|
159
165
|
tokenUrl: 'https://{subdomain}.zendesk.com/oauth/tokens',
|
|
160
166
|
});
|
|
161
|
-
auth.buildAuthorizationUrl = (args) =>
|
|
162
|
-
|
|
167
|
+
auth.buildAuthorizationUrl = (args) => {
|
|
168
|
+
if (authMode(args.client.fields) === 'client_credentials') {
|
|
169
|
+
throw new Error('This Zendesk configuration uses client credentials; no user redirect is required.');
|
|
170
|
+
}
|
|
171
|
+
return strategyFor(args.client.fields).buildAuthorizationUrl(args);
|
|
172
|
+
};
|
|
173
|
+
auth.clientCredentialsOnly = (fields) => authMode(fields) === 'client_credentials';
|
|
174
|
+
auth.exchangeCode = (args) => {
|
|
175
|
+
if (authMode(args.client.fields) === 'client_credentials') {
|
|
176
|
+
throw new Error('This Zendesk configuration uses client credentials; no authorization code is expected.');
|
|
177
|
+
}
|
|
178
|
+
return strategyFor(args.client.fields).exchangeCode(args);
|
|
179
|
+
};
|
|
163
180
|
// `refresh?` is optional for strategies that cannot refresh at all; one
|
|
164
181
|
// built by `oauth2()` always has it.
|
|
165
|
-
auth.refresh = (args) =>
|
|
182
|
+
auth.refresh = (args) => {
|
|
183
|
+
if (authMode(args.client.fields) === 'client_credentials') {
|
|
184
|
+
throw new Error('Client-credentials tokens do not use refresh tokens.');
|
|
185
|
+
}
|
|
186
|
+
return strategyFor(args.client.fields).refresh(args);
|
|
187
|
+
};
|
|
188
|
+
auth.clientCredentials = (args) => strategyFor(args.client.fields).clientCredentials(args);
|
|
166
189
|
return defineIntegration({
|
|
167
190
|
key: 'zendesk',
|
|
168
191
|
name: 'Zendesk',
|
|
@@ -185,6 +208,23 @@ export function zendesk() {
|
|
|
185
208
|
pattern: SUBDOMAIN_SOURCE,
|
|
186
209
|
help: 'The part before .zendesk.com, e.g. acme',
|
|
187
210
|
},
|
|
211
|
+
{
|
|
212
|
+
key: 'authMode',
|
|
213
|
+
label: 'OAuth mode',
|
|
214
|
+
type: 'select',
|
|
215
|
+
required: false,
|
|
216
|
+
options: [
|
|
217
|
+
{
|
|
218
|
+
label: 'Authorization code (user OAuth)',
|
|
219
|
+
value: 'authorization_code',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
label: 'Client credentials (server-to-server)',
|
|
223
|
+
value: 'client_credentials',
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
help: 'Choose client credentials for one organization-wide Zendesk connection.',
|
|
227
|
+
},
|
|
188
228
|
],
|
|
189
229
|
api: {
|
|
190
230
|
// No static base: every account is a different host. Resolved from the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosha-ai/integration-zendesk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Zendesk integration for Kosha",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kosha",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"key": "zendesk"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@kosha-ai/integration-sdk": "0.
|
|
51
|
+
"@kosha-ai/integration-sdk": "0.7.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@kosha-ai/integration-sdk": "0.
|
|
54
|
+
"@kosha-ai/integration-sdk": "0.7.0"
|
|
55
55
|
}
|
|
56
56
|
}
|